build_package.pl
changeset 47 4379a1e558cd
parent 46 4db5e28df888
parent 45 61887c5ee9db
child 48 5e2200d13067
equal deleted inserted replaced
46:4db5e28df888 47:4379a1e558cd
    70 	print "\t--configdir=DIR Use DIR location for the config (exclusive with --configrepo).\n";
    70 	print "\t--configdir=DIR Use DIR location for the config (exclusive with --configrepo).\n";
    71 	print "\t--number=N Force build number to N\n";
    71 	print "\t--number=N Force build number to N\n";
    72 	print "\t--production Tag this build as 'production' (default: 'test') and use nnn numbering (default: Tnnn)\n";
    72 	print "\t--production Tag this build as 'production' (default: 'test') and use nnn numbering (default: Tnnn)\n";
    73 	print "\t--tag=TAG Apply Diamonds tag TAG to this build (exclusive with --production)\n";
    73 	print "\t--tag=TAG Apply Diamonds tag TAG to this build (exclusive with --production)\n";
    74 	print "\t--hudson Checks that there is at least NUMBER_OF_PROCESSORS X 10 GB available on the working drive\n";
    74 	print "\t--hudson Checks that there is at least NUMBER_OF_PROCESSORS X 10 GB available on the working drive\n";
    75 	print "\t--nopublish Use numbers_test.txt for numbers and disable publishing\n";
    75 	print "\t--nopublish Use \\numbers_test.txt for numbers and disable publishing\n";
    76 	exit(0);
    76 	exit(0);
    77 }
    77 }
    78 
    78 
    79 if ($sSubProject and $sSubProject !~ m,^([^/]+)/[^/]+/([^/]+)$,)
    79 if ($sSubProject and $sSubProject !~ m,^([^/]+)/[^/]+/([^/]+)$,)
    80 {
    80 {
    92 #{
    92 #{
    93 #	print "Error: If you don't provide --projectrepo or --projectdir then you have to provide both --sources and --model\n";
    93 #	print "Error: If you don't provide --projectrepo or --projectdir then you have to provide both --sources and --model\n";
    94 #	exit(0);
    94 #	exit(0);
    95 #}
    95 #}
    96 
    96 
    97 my $sWORKING_DRIVE = "G:";
    97 my $sWORKING_DRIVE = find_working_drive();
    98 my $output = `G: 2>&1`;
       
    99 $sWORKING_DRIVE = "D:" if ($output =~ /The device is not ready./);
       
   100 print "Will use drive $sWORKING_DRIVE as working drive for this build\n";
    98 print "Will use drive $sWORKING_DRIVE as working drive for this build\n";
   101 
    99 
   102 if ($bHudson)
   100 if ($bHudson)
   103 {
   101 {
   104 	my $nProcessors = $ENV{'NUMBER_OF_PROCESSORS'};
   102 	my $nProcessors = $ENV{'NUMBER_OF_PROCESSORS'};
   130 my $sTestBuildOpt = "";
   128 my $sTestBuildOpt = "";
   131 $sTestBuildOpt = "-Dsf.spec.publish.diamonds.tag=production" if ( $bProduction );
   129 $sTestBuildOpt = "-Dsf.spec.publish.diamonds.tag=production" if ( $bProduction );
   132 $sTestBuildOpt = "-Dsf.spec.publish.diamonds.tag=$sDiamondsTag" if ( $sDiamondsTag );
   130 $sTestBuildOpt = "-Dsf.spec.publish.diamonds.tag=$sDiamondsTag" if ( $sDiamondsTag );
   133 my $sNoPublishOpt = "";
   131 my $sNoPublishOpt = "";
   134 $sNoPublishOpt = "-Dsf.spec.publish.enable=false" if ( !$bPublish );
   132 $sNoPublishOpt = "-Dsf.spec.publish.enable=false" if ( !$bPublish );
   135 $sNUMBERS_FILE = "d:\\numbers_test.txt" if ( !$bPublish );
   133 $sNUMBERS_FILE = "$sWORKING_DRIVE\\numbers_test.txt" if ( !$bPublish );
   136 
   134 
   137 my $sJobLabel = 'job';
   135 my $sJobLabel = 'job';
   138 if ($sSubProject)
   136 if ($sSubProject)
   139 {
   137 {
   140 	$sSubProject =~ m,^([^/]+)/[^/]+/([^/]+)$,;
   138 	$sSubProject =~ m,^([^/]+)/[^/]+/([^/]+)$,;
   277 	print $_;
   275 	print $_;
   278 }
   276 }
   279 close(PIPE);
   277 close(PIPE);
   280 close(LOG);
   278 close(LOG);
   281 
   279 
   282 # copy console outputs to remote log archive
   280 if ($bPublish)
   283 if (-d "$sREMOTE_LOG_ARCHIVE\\$sPackage\\builds\\$sPlatform\\$sPackage\_$sPlatform.$nJobNumber\\logs")
   281 {
   284 {
   282 	# copy console outputs to remote log archive
   285 	my $sTgtDir = "$sREMOTE_LOG_ARCHIVE\\$sPackage\\builds\\$sPlatform\\$sPackage\_$sPlatform.$nJobNumber\\logs\\console";
   283 	if (-d "$sREMOTE_LOG_ARCHIVE\\$sPackage\\builds\\$sPlatform\\$sPackage\_$sPlatform.$nJobNumber\\logs")
   286 	print "copying console output files to $sTgtDir\n";
   284 	{
   287 	system("mkdir $sTgtDir");
   285 		my $sTgtDir = "$sREMOTE_LOG_ARCHIVE\\$sPackage\\builds\\$sPlatform\\$sPackage\_$sPlatform.$nJobNumber\\logs\\console";
   288 	system("copy /Y $sBOOTSTRAP_DIR\\console_bootstrap_$$.txt $sTgtDir");
   286 		print "copying console output files to $sTgtDir\n";
   289 	system("del $sBOOTSTRAP_DIR\\console_bootstrap_$$.txt");
   287 		system("mkdir $sTgtDir");
   290 	system("copy $sJobDir\\sf-config\\console_sfprep_$$.txt $sTgtDir");
   288 		system("copy /Y $sBOOTSTRAP_DIR\\console_bootstrap_$$.txt $sTgtDir");
   291 	system("copy $sJobDir\\sf-config\\console_sfbuildall_$$.txt $sTgtDir");
   289 		system("del $sBOOTSTRAP_DIR\\console_bootstrap_$$.txt");
   292 	system("copy $sJobDir\\sf-config\\console_sfsummary_$$.txt $sTgtDir");
   290 		system("copy $sJobDir\\sf-config\\console_sfprep_$$.txt $sTgtDir");
   293 }
   291 		system("copy $sJobDir\\sf-config\\console_sfbuildall_$$.txt $sTgtDir");
   294 else
   292 		system("copy $sJobDir\\sf-config\\console_sfsummary_$$.txt $sTgtDir");
   295 {
   293 	}
   296 	print "directory $sREMOTE_LOG_ARCHIVE\\$sPackage\\builds\\$sPlatform\\$sPackage\_$sPlatform.$nJobNumber\\logs doesn't exist.\n";
   294 	else
       
   295 	{
       
   296 		print "directory $sREMOTE_LOG_ARCHIVE\\$sPackage\\builds\\$sPlatform\\$sPackage\_$sPlatform.$nJobNumber\\logs doesn't exist.\n";
       
   297 	}
   297 }
   298 }
   298 
   299 
   299 print("cd $sBOOTSTRAP_DIR\n");
   300 print("cd $sBOOTSTRAP_DIR\n");
   300 chdir("$sBOOTSTRAP_DIR");
   301 chdir("$sBOOTSTRAP_DIR");
   301 
   302 
   315 	if (-d "$sWORKING_DRIVE\\fbf_job\\$sPackage\_$sPlatform.$nJobNumber") # build drive
   316 	if (-d "$sWORKING_DRIVE\\fbf_job\\$sPackage\_$sPlatform.$nJobNumber") # build drive
   316 	{
   317 	{
   317 		print "rmdir /S $sWORKING_DRIVE\\fbf_job\\$sPackage\_$sPlatform.$nJobNumber\n";
   318 		print "rmdir /S $sWORKING_DRIVE\\fbf_job\\$sPackage\_$sPlatform.$nJobNumber\n";
   318 		system("rmdir /S /Q $sWORKING_DRIVE\\fbf_job\\$sPackage\_$sPlatform.$nJobNumber");
   319 		system("rmdir /S /Q $sWORKING_DRIVE\\fbf_job\\$sPackage\_$sPlatform.$nJobNumber");
   319 	}
   320 	}
       
   321 }
       
   322 
       
   323 sub find_working_drive
       
   324 {
       
   325 	my @drive_list = ('E', 'G', 'D', 'C');
       
   326 	
       
   327 	for my $drive (@drive_list)
       
   328 	{
       
   329 		return "$drive:" if (-d "$drive:/");
       
   330 	}
       
   331 	
       
   332 	die "Could not find suitable working drive.";
   320 }
   333 }
   321 
   334 
   322 sub mkdir_unique
   335 sub mkdir_unique
   323 {
   336 {
   324 	my ($sBaseDir) = @_;
   337 	my ($sBaseDir) = @_;