build_package.pl
changeset 34 d156d56b00c2
parent 33 4d7642508510
child 35 4d500511bf5a
equal deleted inserted replaced
33:4d7642508510 34:d156d56b00c2
    33 #my $sModelFile = '';
    33 #my $sModelFile = '';
    34 my $sFbfConfigRepo="\\\\bishare\\mercurial_internal\\fbf\\configs\\pkgbuild";
    34 my $sFbfConfigRepo="\\\\bishare\\mercurial_internal\\fbf\\configs\\pkgbuild";
    35 my $sFbfConfigDir = '';
    35 my $sFbfConfigDir = '';
    36 my $nCmdLineNumber;
    36 my $nCmdLineNumber;
    37 my $bProduction = 0;
    37 my $bProduction = 0;
       
    38 my $sDiamondsTag = '';
       
    39 my $bHudson = 0;
    38 my $bPublish = 1;
    40 my $bPublish = 1;
    39 GetOptions((
    41 GetOptions((
    40 	'configrepo=s' => \$sFbfConfigRepo,
    42 	'configrepo=s' => \$sFbfConfigRepo,
    41 	'configdir=s' => \$sFbfConfigDir,
    43 	'configdir=s' => \$sFbfConfigDir,
    42 	'projectrepo=s' => \$sFbfProjectRepo,
    44 	'projectrepo=s' => \$sFbfProjectRepo,
    44 	'subproj=s' => \$sSubProject,
    46 	'subproj=s' => \$sSubProject,
    45 	#'sources=s' => \$sSourcesFile,
    47 	#'sources=s' => \$sSourcesFile,
    46 	#'model=s' => \$sModelFile,
    48 	#'model=s' => \$sModelFile,
    47 	'number=s' => \$nCmdLineNumber,
    49 	'number=s' => \$nCmdLineNumber,
    48 	'production!' => \$bProduction,
    50 	'production!' => \$bProduction,
       
    51 	'tag=s' => \$sDiamondsTag,
       
    52 	'hudson!' => \$bHudson,
    49 	'publish!' => \$bPublish
    53 	'publish!' => \$bPublish
    50 ));
    54 ));
    51 
    55 
    52 if (!$sSubProject)
    56 if (!$sSubProject)
    53 {
    57 {
    60 	#print "\t--model=FILE ...\n";
    64 	#print "\t--model=FILE ...\n";
    61 	print "\t--configrepo=REPO[#REV] Use repository REPO at revision REV for the config (instead of \\\\bishare\\mercurial_internal\\fbf\\config\\pkgbuild)\n";
    65 	print "\t--configrepo=REPO[#REV] Use repository REPO at revision REV for the config (instead of \\\\bishare\\mercurial_internal\\fbf\\config\\pkgbuild)\n";
    62 	print "\t--configdir=DIR Use DIR location for the config (exclusive with --configrepo).\n";
    66 	print "\t--configdir=DIR Use DIR location for the config (exclusive with --configrepo).\n";
    63 	print "\t--number=N Force build number to N\n";
    67 	print "\t--number=N Force build number to N\n";
    64 	print "\t--production Tag this build as 'production' (default: 'test') and use nnn numbering (default: Tnnn)\n";
    68 	print "\t--production Tag this build as 'production' (default: 'test') and use nnn numbering (default: Tnnn)\n";
       
    69 	print "\t--tag=TAG Apply Diamonds tag TAG to this build (exclusive with --production)\n";
       
    70 	print "\t--hudson Checks that there is at least NUMBER_OF_PROCESSORS X 10 GB available on the working drive\n";
    65 	print "\t--nopublish Use numbers_test.txt for numbers and disable publishing\n";
    71 	print "\t--nopublish Use numbers_test.txt for numbers and disable publishing\n";
    66 	exit(0);
    72 	exit(0);
    67 }
    73 }
    68 
    74 
    69 if ($sSubProject !~ m,^([^/]+)/[^/]+/([^/]+)$,)
    75 if ($sSubProject !~ m,^([^/]+)/[^/]+/([^/]+)$,)
    70 {
    76 {
    71 	print "Error: Option --subproj must be in the format codeline/layer/package (e.g. MCL/os/boardsupport)\n";
    77 	print "ERROR: Option --subproj must be in the format codeline/layer/package (e.g. MCL/os/boardsupport)\n";
       
    78 	exit(0);
       
    79 }
       
    80 
       
    81 if ($bProduction and $sDiamondsTag)
       
    82 {
       
    83 	print "ERROR: Options --production and --tag are mutually exclusive.\n";
    72 	exit(0);
    84 	exit(0);
    73 }
    85 }
    74 
    86 
    75 #if (!$sFbfProjectRepo and !$sFbfProjectDir and (!$sSourcesFile or !$sModelFile))
    87 #if (!$sFbfProjectRepo and !$sFbfProjectDir and (!$sSourcesFile or !$sModelFile))
    76 #{
    88 #{
    81 my $sWORKING_DRIVE = "G:";
    93 my $sWORKING_DRIVE = "G:";
    82 my $output = `G: 2>&1`;
    94 my $output = `G: 2>&1`;
    83 $sWORKING_DRIVE = "D:" if ($output =~ /The device is not ready./);
    95 $sWORKING_DRIVE = "D:" if ($output =~ /The device is not ready./);
    84 print "Will use drive $sWORKING_DRIVE as working drive for this build\n";
    96 print "Will use drive $sWORKING_DRIVE as working drive for this build\n";
    85 
    97 
       
    98 if ($bHudson)
       
    99 {
       
   100 	my $nProcessors = $ENV{'NUMBER_OF_PROCESSORS'};
       
   101 	my $diroutput = `dir /-C $sWORKING_DRIVE`;
       
   102 	my $nBytesFree = 0;
       
   103 	$nBytesFree = $1 if ($diroutput =~ /(\d+) bytes free/);
       
   104 	my $nNeededSpace = 10*$nProcessors*1073741824;
       
   105 	#print "Needed space is $nNeededSpace\n";
       
   106 	if ($nBytesFree < $nNeededSpace)
       
   107 	{
       
   108 		print "ERROR: Available disk space on working drive ($nBytesFree bytes) is not enough to run a package build with Hudson.\n";
       
   109 		exit(1);
       
   110 	}
       
   111 }
       
   112 
    86 my $sFbfProjectRev = '';
   113 my $sFbfProjectRev = '';
    87 if ($sFbfProjectRepo =~ m,(.*)#(.*),)
   114 if ($sFbfProjectRepo =~ m,(.*)#(.*),)
    88 {
   115 {
    89 	$sFbfProjectRepo = $1;
   116 	$sFbfProjectRepo = $1;
    90 	$sFbfProjectRev = $2;
   117 	$sFbfProjectRev = $2;
    96 	$sFbfConfigRev = $2;
   123 	$sFbfConfigRev = $2;
    97 }
   124 }
    98 
   125 
    99 my $sTestBuildOpt = "";
   126 my $sTestBuildOpt = "";
   100 $sTestBuildOpt = "-Dsf.spec.publish.diamonds.tag=production" if ( $bProduction );
   127 $sTestBuildOpt = "-Dsf.spec.publish.diamonds.tag=production" if ( $bProduction );
       
   128 $sTestBuildOpt = "-Dsf.spec.publish.diamonds.tag=$sDiamondsTag" if ( $sDiamondsTag );
   101 my $sNoPublishOpt = "";
   129 my $sNoPublishOpt = "";
   102 $sNoPublishOpt = "-Dsf.spec.publish.enable=false" if ( !$bPublish );
   130 $sNoPublishOpt = "-Dsf.spec.publish.enable=false" if ( !$bPublish );
   103 $sNUMBERS_FILE = "d:\\numbers_test.txt" if ( !$bPublish );
   131 $sNUMBERS_FILE = "d:\\numbers_test.txt" if ( !$bPublish );
   104 
   132 
   105 my $sJobLabel = 'job';
   133 my $sJobLabel = 'job';