bldsystemtools/commonbldutils/BuildStamp.pl
changeset 0 83f4b4db085c
child 1 d4b442d23379
equal deleted inserted replaced
-1:000000000000 0:83f4b4db085c
       
     1 # Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 # All rights reserved.
       
     3 # This component and the accompanying materials are made available
       
     4 # under the terms of "Eclipse Public License v1.0"
       
     5 # which accompanies this distribution, and is available
       
     6 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 #
       
     8 # Initial Contributors:
       
     9 # Nokia Corporation - initial contribution.
       
    10 #
       
    11 # Contributors:
       
    12 #
       
    13 # Description:
       
    14 # Script to create a timestamp for builds
       
    15 # 
       
    16 #
       
    17 
       
    18 use strict;
       
    19 use Getopt::Long;
       
    20 
       
    21 # For Date calculations
       
    22 use FindBin;		# for FindBin::Bin
       
    23 use lib "$FindBin::Bin/../tools/build/lib"; # For running in source
       
    24 use lib "$FindBin::Bin/../buildsystemtools/lib"; # For running in source (Foundation Structure)
       
    25 use Date::Manip;
       
    26 
       
    27 # Set TimeZone because Date:Manip needs it set and then tell it to IGNORE the TimeZone
       
    28 &Date_Init("TZ=GMT","ConvTZ=IGNORE");
       
    29 
       
    30 # Process the commandline
       
    31 my ($iBuildNum, $iDaysNum, $iPath) = ProcessCommandLine();
       
    32 
       
    33 # Gets today date then build the date stamp file by adding on the number of days given by the -d flag
       
    34 # The file name is of the format year_month_day.expiry
       
    35 my $date = &DateCalc("today","+ $iDaysNum days");
       
    36 my $Logfilename = &UnixDate($date,$iPath."\\".$iBuildNum."\\"."%Y_%m_%d"."\."."expiry");
       
    37 
       
    38 
       
    39 # Create the date stamp file
       
    40 open(FILE,">> $Logfilename");
       
    41 print FILE "Build to be deleted on this date\n";
       
    42 close FILE;
       
    43 
       
    44 if ($ENV{'BuildSubType'} eq "Test")
       
    45 {
       
    46   # Gets today date then build the date stamp file for devkit deletion and setting it to 3 days
       
    47   # The file name is of the format year_month_day.devkitExpiry
       
    48   my $date = &DateCalc("today","+ 3 days");
       
    49   my $Logfilename = &UnixDate($date,$iPath."\\".$iBuildNum."\\Product\\"."%Y_%m_%d"."\."."expiry");
       
    50 
       
    51   mkdir ($iPath."\\".$iBuildNum."\\Product");
       
    52 
       
    53   # Create the date stamp file
       
    54   open(FILE,">> $Logfilename");
       
    55   print FILE "Build to be deleted on this date\n";
       
    56   close FILE;
       
    57 }
       
    58 # End of script
       
    59 
       
    60 sub ProcessCommandLine {
       
    61   my ($iHelp, $iBuildNum, $iDaysNum, $iPath);
       
    62   GetOptions('h' => \$iHelp, 'b:s' =>\$iBuildNum, 'd:i' => \$iDaysNum, 'p:s' => \$iPath);
       
    63 
       
    64   if (($iHelp) || (!defined $iBuildNum) || (!defined $iPath) )
       
    65   {
       
    66     Usage();
       
    67   } 
       
    68   else 
       
    69   {
       
    70     if (!defined $iDaysNum)
       
    71     {
       
    72       $iDaysNum = 14;
       
    73     }
       
    74     return($iBuildNum, $iDaysNum, $iPath);
       
    75   };
       
    76 }
       
    77 
       
    78 # Usage
       
    79 #
       
    80 # Output Usage Information.
       
    81 #
       
    82 
       
    83 sub Usage {
       
    84   print <<USAGE_EOF;
       
    85 
       
    86 	Usage: BuildStamp.pl [options]
       
    87 
       
    88 	options:
       
    89 
       
    90 	-h Help
       
    91 	-b	%s Build number
       
    92 	-d	%n Number of days from today
       
    93 	-p	%s Path to publish directory
       
    94 
       
    95 USAGE_EOF
       
    96 	exit 1;
       
    97 }