build_package.pl
changeset 28 bf45384632b0
parent 27 d12bf27e4e0e
child 29 b9212509f335
equal deleted inserted replaced
27:d12bf27e4e0e 28:bf45384632b0
    30 my $sFbfProjectDir = '';
    30 my $sFbfProjectDir = '';
    31 my $sFbfConfigRepo="\\\\bishare\\mercurial_internal\\fbf\\configs\\pkgbuild";
    31 my $sFbfConfigRepo="\\\\bishare\\mercurial_internal\\fbf\\configs\\pkgbuild";
    32 my $sFbfConfigDir = '';
    32 my $sFbfConfigDir = '';
    33 my $nCmdLineNumber;
    33 my $nCmdLineNumber;
    34 my $bTestBuild = 0;
    34 my $bTestBuild = 0;
       
    35 my $bPublish = 1;
    35 GetOptions((
    36 GetOptions((
    36 	'configrepo:s' => \$sFbfConfigRepo,
    37 	'configrepo:s' => \$sFbfConfigRepo,
    37 	'configdir:s' => \$sFbfConfigDir,
    38 	'configdir:s' => \$sFbfConfigDir,
    38 	'projectrepo:s' => \$sFbfProjectRepo,
    39 	'projectrepo:s' => \$sFbfProjectRepo,
    39 	'projectdir:s' => \$sFbfProjectDir,
    40 	'projectdir:s' => \$sFbfProjectDir,
    40 	'number:s' => \$nCmdLineNumber,
    41 	'number:s' => \$nCmdLineNumber,
    41 	'testbuild!' => \$bTestBuild
    42 	'testbuild!' => \$bTestBuild,
       
    43 	'publish!' => \$bPublish
    42 ));
    44 ));
    43 
    45 
    44 if (!$sFbfProjectRepo and !$sFbfProjectDir)
    46 if (!$sFbfProjectRepo and !$sFbfProjectDir)
    45 {
    47 {
    46 	print "Usage: build_package.pl --projectrepo=REPO [OPTIONS]\n";
    48 	print "Usage: build_package.pl --projectrepo=REPO [OPTIONS]\n";
    47 	print "where OPTIONS are:\n";
    49 	print "where OPTIONS are:\n";
    48 	print "\t--projectrepo=REPO[#REV] Use repository REPO at revision REV for the project.\n";
    50 	print "\t--projectrepo=REPO[#REV] Use repository REPO at revision REV for the project.\n";
    49 	print "\t--projectdir=DIR Use DIR location for the project (exclusive with --projectrepo). Option --testbuild is required.\n";
    51 	print "\t--projectdir=DIR Use DIR location for the project (exclusive with --projectrepo). Option --nopublish is required.\n";
    50 	print "\t--configrepo=REPO[#REV] Use repository REPO at revision REV for the config (instead of \\\\bishare\\mercurial_internal\\fbf\\config\\pkgbuild)\n";
    52 	print "\t--configrepo=REPO[#REV] Use repository REPO at revision REV for the config (instead of \\\\bishare\\mercurial_internal\\fbf\\config\\pkgbuild)\n";
    51 	print "\t--configdir=DIR Use DIR location for the config (exclusive with --configrepo). Option --testbuild is required.\n";
    53 	print "\t--configdir=DIR Use DIR location for the config (exclusive with --configrepo). Option --nopublish is required.\n";
    52 	print "\t--number=N Force build number to N\n";
    54 	print "\t--number=N Force build number to N\n";
    53 	print "\t--testbuild Use d:\\numbers_test.txt for numbers and disable publishing\n";
    55 	print "\t--testbuild Set category to package.test and use Tnnn numbering\n";
       
    56 	print "\t--nopublish Use d:\\numbers_test.txt for numbers and disable publishing\n";
    54 	exit(0);
    57 	exit(0);
    55 }
    58 }
    56 
    59 
    57 if ($sFbfProjectDir and !$bTestBuild)
    60 if ($sFbfProjectDir and $bPublish)
    58 {
    61 {
    59 	print "Error: Option --projectdir requires --testbuild\n";
    62 	print "Error: Option --projectdir requires --nopublish\n";
    60 	exit(0);
    63 	exit(0);
    61 }
    64 }
    62 
    65 
    63 if ($sFbfConfigDir and !$bTestBuild)
    66 if ($sFbfConfigDir and $bPublish)
    64 {
    67 {
    65 	print "Error: Option --configdir requires --testbuild\n";
    68 	print "Error: Option --configdir requires --nopublish\n";
    66 	exit(0);
    69 	exit(0);
    67 }
    70 }
    68 
    71 
    69 my $sFbfProjectRev = '';
    72 my $sFbfProjectRev = '';
    70 if ($sFbfProjectRepo =~ m,(.*)#(.*),)
    73 if ($sFbfProjectRepo =~ m,(.*)#(.*),)
    77 {
    80 {
    78 	$sFbfConfigRepo = $1;
    81 	$sFbfConfigRepo = $1;
    79 	$sFbfConfigRev = $2;
    82 	$sFbfConfigRev = $2;
    80 }
    83 }
    81 
    84 
    82 my $sTestBuildOpts = "";
    85 my $sTestBuildOpt = "";
    83 $sTestBuildOpts = "-Dsf.spec.publish.enable=false" if ( $bTestBuild );
    86 $sTestBuildOpt = "-Dsf.spec.publish.diamonds.category=package.test" if ( $bTestBuild );
    84 $sNUMBERS_FILE = "d:\\numbers_test.txt" if ( $bTestBuild );
    87 my $sNoPublishOpt = "";
       
    88 $sNoPublishOpt = "-Dsf.spec.publish.enable=false" if ( !$bPublish );
       
    89 $sNUMBERS_FILE = "d:\\numbers_test.txt" if ( !$bPublish );
    85 
    90 
    86 my $sLabelBaseString = $sFbfProjectRepo;
    91 my $sLabelBaseString = $sFbfProjectRepo;
    87 $sLabelBaseString = $sFbfProjectDir if ($sFbfProjectDir);
    92 $sLabelBaseString = $sFbfProjectDir if ($sFbfProjectDir);
    88 $sLabelBaseString =~ m,.*[\\/]([^\\^/]+),;
    93 $sLabelBaseString =~ m,.*[\\/]([^\\^/]+),;
    89 my $sJobLabel = $1;
    94 my $sJobLabel = $1;
   118 	$nUnformattedNumber = $nCmdLineNumber;
   123 	$nUnformattedNumber = $nCmdLineNumber;
   119 }
   124 }
   120 elsif ($sFbfProjectRepo)
   125 elsif ($sFbfProjectRepo)
   121 {
   126 {
   122 	my $sRevZeroHash = get_rev_zero_hash($sFbfProjectRepo);
   127 	my $sRevZeroHash = get_rev_zero_hash($sFbfProjectRepo);
   123 	$nUnformattedNumber = get_job_number($sRevZeroHash);
   128 	my $sJobNumberKey = $sRevZeroHash;
       
   129 	$sJobNumberKey .= ".T" if ($bTestBuild);
       
   130 	$nUnformattedNumber = get_job_number($sJobNumberKey);
   124 }
   131 }
   125 my $nJobNumber = sprintf("%.3d", $nUnformattedNumber);
   132 my $nJobNumber = sprintf("%.3d", $nUnformattedNumber);
       
   133 $nJobNumber = "T$nJobNumber" if ($bTestBuild);
   126 
   134 
   127 # check that $sLETTERS_FILE exists, otherwise create it
   135 # check that $sLETTERS_FILE exists, otherwise create it
   128 if (!-f $sLETTERS_FILE)
   136 if (!-f $sLETTERS_FILE)
   129 {
   137 {
   130 	open FILE, ">$sLETTERS_FILE";
   138 	open FILE, ">$sLETTERS_FILE";
   138 die "Could not acquire drive letter" if (! $sDriveLetter);
   146 die "Could not acquire drive letter" if (! $sDriveLetter);
   139 
   147 
   140 print("cd $sJobDir\\sf-config\n");
   148 print("cd $sJobDir\\sf-config\n");
   141 chdir("$sJobDir\\sf-config");
   149 chdir("$sJobDir\\sf-config");
   142 print "###### BUILD PREPARATION ######\n";
   150 print "###### BUILD PREPARATION ######\n";
   143 print("hlm sf-prep -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTestBuildOpts\n");
   151 print("hlm sf-prep -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTestBuildOpt $sNoPublishOpt\n");
   144 system("hlm sf-prep -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTestBuildOpts");
   152 system("hlm sf-prep -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTestBuildOpt $sNoPublishOpt");
   145 
   153 
   146 print "###### EXECUTE BUILD ######\n";
   154 print "###### EXECUTE BUILD ######\n";
   147 print("hlm sf-build-all -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTestBuildOpts\n");
   155 print("hlm sf-build-all -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTestBuildOpt $sNoPublishOpt\n");
   148 system("hlm sf-build-all -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTestBuildOpts");
   156 system("hlm sf-build-all -Dsf.spec.job.number=$nJobNumber -Dsf.spec.job.drive=$sDriveLetter: $sTestBuildOpt $sNoPublishOpt");
   149 
   157 
   150 # release the drive letter
   158 # release the drive letter
   151 release_drive_letter($sDriveLetter);
   159 release_drive_letter($sDriveLetter);
   152 system("subst $sDriveLetter: /d"); # this is not required, but it's a good idea to keep things in order
   160 system("subst $sDriveLetter: /d"); # this is not required, but it's a good idea to keep things in order
   153 print "drive letter $sDriveLetter released (and drive unsubsted)\n";
   161 print "drive letter $sDriveLetter released (and drive unsubsted)\n";