build_package.pl
changeset 45 61887c5ee9db
parent 44 1caba2ed8b35
child 47 4379a1e558cd
equal deleted inserted replaced
44:1caba2ed8b35 45:61887c5ee9db
    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,^([^/]+)/[^/]+/([^/]+)$,;
   264 	print $_;
   262 	print $_;
   265 }
   263 }
   266 close(PIPE);
   264 close(PIPE);
   267 close(LOG);
   265 close(LOG);
   268 
   266 
   269 # copy console outputs to remote log archive
   267 if ($bPublish)
   270 if (-d "$sREMOTE_LOG_ARCHIVE\\$sPackage\\builds\\$sPlatform\\$sPackage\_$sPlatform.$nJobNumber\\logs")
   268 {
   271 {
   269 	# copy console outputs to remote log archive
   272 	my $sTgtDir = "$sREMOTE_LOG_ARCHIVE\\$sPackage\\builds\\$sPlatform\\$sPackage\_$sPlatform.$nJobNumber\\logs\\console";
   270 	if (-d "$sREMOTE_LOG_ARCHIVE\\$sPackage\\builds\\$sPlatform\\$sPackage\_$sPlatform.$nJobNumber\\logs")
   273 	print "copying console output files to $sTgtDir\n";
   271 	{
   274 	system("mkdir $sTgtDir");
   272 		my $sTgtDir = "$sREMOTE_LOG_ARCHIVE\\$sPackage\\builds\\$sPlatform\\$sPackage\_$sPlatform.$nJobNumber\\logs\\console";
   275 	system("copy /Y $sBOOTSTRAP_DIR\\console_bootstrap_$$.txt $sTgtDir");
   273 		print "copying console output files to $sTgtDir\n";
   276 	system("del $sBOOTSTRAP_DIR\\console_bootstrap_$$.txt");
   274 		system("mkdir $sTgtDir");
   277 	system("copy $sJobDir\\sf-config\\console_sfprep_$$.txt $sTgtDir");
   275 		system("copy /Y $sBOOTSTRAP_DIR\\console_bootstrap_$$.txt $sTgtDir");
   278 	system("copy $sJobDir\\sf-config\\console_sfbuildall_$$.txt $sTgtDir");
   276 		system("del $sBOOTSTRAP_DIR\\console_bootstrap_$$.txt");
   279 }
   277 		system("copy $sJobDir\\sf-config\\console_sfprep_$$.txt $sTgtDir");
   280 else
   278 		system("copy $sJobDir\\sf-config\\console_sfbuildall_$$.txt $sTgtDir");
   281 {
   279 	}
   282 	print "directory $sREMOTE_LOG_ARCHIVE\\$sPackage\\builds\\$sPlatform\\$sPackage\_$sPlatform.$nJobNumber\\logs doesn't exist.\n";
   280 	else
       
   281 	{
       
   282 		print "directory $sREMOTE_LOG_ARCHIVE\\$sPackage\\builds\\$sPlatform\\$sPackage\_$sPlatform.$nJobNumber\\logs doesn't exist.\n";
       
   283 	}
   283 }
   284 }
   284 
   285 
   285 print("cd $sBOOTSTRAP_DIR\n");
   286 print("cd $sBOOTSTRAP_DIR\n");
   286 chdir("$sBOOTSTRAP_DIR");
   287 chdir("$sBOOTSTRAP_DIR");
   287 
   288 
   301 	if (-d "$sWORKING_DRIVE\\fbf_job\\$sPackage\_$sPlatform.$nJobNumber") # build drive
   302 	if (-d "$sWORKING_DRIVE\\fbf_job\\$sPackage\_$sPlatform.$nJobNumber") # build drive
   302 	{
   303 	{
   303 		print "rmdir /S $sWORKING_DRIVE\\fbf_job\\$sPackage\_$sPlatform.$nJobNumber\n";
   304 		print "rmdir /S $sWORKING_DRIVE\\fbf_job\\$sPackage\_$sPlatform.$nJobNumber\n";
   304 		system("rmdir /S /Q $sWORKING_DRIVE\\fbf_job\\$sPackage\_$sPlatform.$nJobNumber");
   305 		system("rmdir /S /Q $sWORKING_DRIVE\\fbf_job\\$sPackage\_$sPlatform.$nJobNumber");
   305 	}
   306 	}
       
   307 }
       
   308 
       
   309 sub find_working_drive
       
   310 {
       
   311 	my @drive_list = ('E', 'G', 'D', 'C');
       
   312 	
       
   313 	for my $drive (@drive_list)
       
   314 	{
       
   315 		return "$drive:" if (-d "$drive:/");
       
   316 	}
       
   317 	
       
   318 	die "Could not find suitable working drive.";
   306 }
   319 }
   307 
   320 
   308 sub mkdir_unique
   321 sub mkdir_unique
   309 {
   322 {
   310 	my ($sBaseDir) = @_;
   323 	my ($sBaseDir) = @_;