build_package.pl
changeset 59 d41d4cdb97ad
parent 58 806b67128bee
child 60 6e2dd2cc846d
equal deleted inserted replaced
58:806b67128bee 59:d41d4cdb97ad
    38 my $nCmdLineNumber;
    38 my $nCmdLineNumber;
    39 my $sDiamondsTag = '';
    39 my $sDiamondsTag = '';
    40 my $bHudson = 0;
    40 my $bHudson = 0;
    41 my $bPublish = 1;
    41 my $bPublish = 1;
    42 my %hHlmDefines = ();
    42 my %hHlmDefines = ();
       
    43 my $bDisableAntiVirus = 0;
    43 my $bHelp = 0;
    44 my $bHelp = 0;
    44 GetOptions((
    45 GetOptions((
    45 	'configrepo=s' => \$sFbfConfigRepo,
    46 	'configrepo=s' => \$sFbfConfigRepo,
    46 	'configdir=s' => \$sFbfConfigDir,
    47 	'configdir=s' => \$sFbfConfigDir,
    47 	'projectrepo=s' => \$sFbfProjectRepo,
    48 	'projectrepo=s' => \$sFbfProjectRepo,
    54 	'number=s' => \$nCmdLineNumber,
    55 	'number=s' => \$nCmdLineNumber,
    55 	'tag=s' => \$sDiamondsTag,
    56 	'tag=s' => \$sDiamondsTag,
    56 	'hudson!' => \$bHudson,
    57 	'hudson!' => \$bHudson,
    57 	'publish!' => \$bPublish,
    58 	'publish!' => \$bPublish,
    58 	'define=s' => \%hHlmDefines,
    59 	'define=s' => \%hHlmDefines,
       
    60 	'disableav=s' => \$bDisableAntiVirus,
    59 	'help!' => \$bHelp
    61 	'help!' => \$bHelp
    60 ));
    62 ));
    61 
    63 
    62 if ($bHelp or !($sSubProject or $sFbfProjectRepo or $sFbfProjectDir))
    64 if ($bHelp or !($sSubProject or $sFbfProjectRepo or $sFbfProjectDir))
    63 {
    65 {
    76 	print "\t--number=N Force build number to N\n";
    78 	print "\t--number=N Force build number to N\n";
    77 	print "\t--tag=TAG Apply Diamonds tag TAG to this build\n";
    79 	print "\t--tag=TAG Apply Diamonds tag TAG to this build\n";
    78 	print "\t--hudson Checks that there is at least NUMBER_OF_PROCESSORS X 10 GB available on the working drive\n";
    80 	print "\t--hudson Checks that there is at least NUMBER_OF_PROCESSORS X 10 GB available on the working drive\n";
    79 	print "\t--nopublish Use \\numbers_test.txt for numbers and disable publishing\n";
    81 	print "\t--nopublish Use \\numbers_test.txt for numbers and disable publishing\n";
    80 	print "\t--define ATTRIBUTE=VALUE Pass -D statements to the Helium Framework\n";
    82 	print "\t--define ATTRIBUTE=VALUE Pass -D statements to the Helium Framework\n";
       
    83 	print "\t--disableav Disable Anti-Virus for the duration of the build (also sync with other concurrent package builds)\n";
    81 	exit(0);
    84 	exit(0);
    82 }
    85 }
    83 
    86 
    84 if ($sSubProject and $sSubProject !~ m,^([^/]+)/[^/]+/([^/]+)$,)
    87 if ($sSubProject and $sSubProject !~ m,^([^/]+)/[^/]+/([^/]+)$,)
    85 {
    88 {
   219 	close FILE;
   222 	close FILE;
   220 }
   223 }
   221 
   224 
   222 # acquire drive letter
   225 # acquire drive letter
   223 my $sDriveLetter = acquire_drive_letter();
   226 my $sDriveLetter = acquire_drive_letter();
       
   227 die "Could not acquire drive letter" if (!$sDriveLetter);
   224 print "acquired drive letter: $sDriveLetter\n";
   228 print "acquired drive letter: $sDriveLetter\n";
   225 die "Could not acquire drive letter" if (! $sDriveLetter);
   229 
       
   230 # disable antivirus:
       
   231 # done after the acquisition of the drive letter as letter file
       
   232 # is used as a means to sync with concurrent package builds
       
   233 if ($bDisableAntiVirus)
       
   234 {
       
   235 	print "disabling anti-virus\n";
       
   236 	my $disableav_cmd = "av.bat /stop";
       
   237 	print "$disableav_cmd\n";
       
   238 	system($disableav_cmd);
       
   239 }
   226 
   240 
   227 my $sJobRootDirArg = "-Dsf.spec.job.rootdir=$sWORKING_DRIVE\\fbf_job";
   241 my $sJobRootDirArg = "-Dsf.spec.job.rootdir=$sWORKING_DRIVE\\fbf_job";
   228 
   242 
   229 my $sSubProjArg = '';
   243 my $sSubProjArg = '';
   230 $sSubProjArg = "-Dsf.subproject.path=$sSubProject" if ($sSubProject);
   244 $sSubProjArg = "-Dsf.subproject.path=$sSubProject" if ($sSubProject);
   251 system($sBuildallCmd);
   265 system($sBuildallCmd);
   252 
   266 
   253 print("cd $sBOOTSTRAP_DIR\n");
   267 print("cd $sBOOTSTRAP_DIR\n");
   254 chdir("$sBOOTSTRAP_DIR");
   268 chdir("$sBOOTSTRAP_DIR");
   255 
   269 
   256 # release the drive letter
   270 # release the drive letter and optionally re-enable the AV
   257 release_drive_letter($sDriveLetter);
   271 release_drive_letter_and_reenable_av($sDriveLetter);
   258 system("subst $sDriveLetter: /d"); # this is not required, but it's a good idea to keep things in order
   272 system("subst $sDriveLetter: /d"); # this is not required, but it's a good idea to keep things in order
   259 print "drive letter $sDriveLetter released (and drive unsubsted)\n";
   273 print "drive letter $sDriveLetter released (and drive unsubsted)\n";
   260 
   274 
   261 if ($bHudson)
   275 if ($bHudson)
   262 {
   276 {
   435 	until ( $bAcquired or $nAttempts == $nLOCK_FILE_MAX_ATTEMPTS );
   449 	until ( $bAcquired or $nAttempts == $nLOCK_FILE_MAX_ATTEMPTS );
   436 	
   450 	
   437 	return $sLetterToRelease;
   451 	return $sLetterToRelease;
   438 }
   452 }
   439 
   453 
   440 sub release_drive_letter
   454 sub release_drive_letter_and_reenable_av
   441 {
   455 {
   442 	my ($sLetterToRelease) = @_;
   456 	my ($sLetterToRelease) = @_;
   443 	
   457 	
   444 	my %hsPidsAndTimestamps = ();
   458 	my %hsPidsAndTimestamps = ();
   445 	
   459 	
   457 			}
   471 			}
   458 			
   472 			
   459 			delete $hsPidsAndTimestamps{$sLetterToRelease};
   473 			delete $hsPidsAndTimestamps{$sLetterToRelease};
   460 			
   474 			
   461 			seek(FILE, 0, 0);
   475 			seek(FILE, 0, 0);
       
   476 			
       
   477 			# if there are no other builds at this time then enable back the antivirus
       
   478 			my $nConcurrentBuilds = scalar(keys(%hsPidsAndTimestamps));
       
   479 			if ($nConcurrentBuilds == 0)
       
   480 			{
       
   481 				if ($bDisableAntiVirus)
       
   482 				{
       
   483 					print "enabling anti-virus\n";
       
   484 					my $enableav_cmd = "av.bat /start";
       
   485 					print "$enableav_cmd\n";
       
   486 					system($enableav_cmd);
       
   487 				}
       
   488 			}
   462 
   489 
   463 			for my $sLetter ( keys(%hsPidsAndTimestamps) )
   490 			for my $sLetter ( keys(%hsPidsAndTimestamps) )
   464 			{
   491 			{
   465 				print FILE "$sLetter,$hsPidsAndTimestamps{$sLetter}\n";
   492 				print FILE "$sLetter,$hsPidsAndTimestamps{$sLetter}\n";
   466 			}
   493 			}