build_package.pl
changeset 32 11821242bc3e
parent 31 7d05cbb136ad
child 33 4d7642508510
equal deleted inserted replaced
31:7d05cbb136ad 32:11821242bc3e
    17 
    17 
    18 use Getopt::Long;
    18 use Getopt::Long;
    19 use File::Path;
    19 use File::Path;
    20 
    20 
    21 my $sBOOTSTRAP_DIR="C:\\Apps\\FBF\\bootstrap";
    21 my $sBOOTSTRAP_DIR="C:\\Apps\\FBF\\bootstrap";
    22 my $sJOB_BASE_DIR="D:\\fbf_project";
    22 my $sJOB_BASE_DIR="fbf_project";
    23 my $nMAX_JOBDIR_AGE_SECONDS = 86400; # max number of seconds after which the letter is forcibly released
    23 my $nMAX_JOBDIR_AGE_SECONDS = 86400; # max number of seconds after which the letter is forcibly released
    24 my $nLOCK_FILE_MAX_ATTEMPTS = 5;
    24 my $nLOCK_FILE_MAX_ATTEMPTS = 5;
    25 my $sNUMBERS_FILE="\\\\bishare\\SF_builds\\numbers2.txt";
    25 my $sNUMBERS_FILE="\\\\bishare\\SF_builds\\numbers2.txt";
    26 my $sLETTERS_FILE="D:\\letters.txt";
    26 my $sLETTERS_FILE="letters.txt";
    27 my $nMAX_LETTER_AGE_SECONDS = 86400; # max number of seconds after which the letter is forcibly released
    27 my $nMAX_LETTER_AGE_SECONDS = 86400; # max number of seconds after which the letter is forcibly released
    28 
    28 
    29 my $sFbfProjectRepo = "\\\\bishare\\mercurial_internal\\fbf\\projects\\packages";
    29 my $sFbfProjectRepo = "\\\\bishare\\mercurial_internal\\fbf\\projects\\packages";
    30 my $sFbfProjectDir = '';
    30 my $sFbfProjectDir = '';
    31 my $sSubProject = '';
    31 my $sSubProject = '';
    60 	#print "\t--model=FILE ...\n";
    60 	#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";
    61 	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";
    62 	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";
    63 	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";
    64 	print "\t--production Tag this build as 'production' (default: 'test') and use nnn numbering (default: Tnnn)\n";
    65 	print "\t--nopublish Use d:\\numbers_test.txt for numbers and disable publishing\n";
    65 	print "\t--nopublish Use numbers_test.txt for numbers and disable publishing\n";
    66 	exit(0);
    66 	exit(0);
    67 }
    67 }
    68 
    68 
    69 if ($sSubProject !~ m,^([^/]+)/[^/]+/([^/]+)$,)
    69 if ($sSubProject !~ m,^([^/]+)/[^/]+/([^/]+)$,)
    70 {
    70 {
    75 #if (!$sFbfProjectRepo and !$sFbfProjectDir and (!$sSourcesFile or !$sModelFile))
    75 #if (!$sFbfProjectRepo and !$sFbfProjectDir and (!$sSourcesFile or !$sModelFile))
    76 #{
    76 #{
    77 #	print "Error: If you don't provide --projectrepo or --projectdir then you have to provide both --sources and --model\n";
    77 #	print "Error: If you don't provide --projectrepo or --projectdir then you have to provide both --sources and --model\n";
    78 #	exit(0);
    78 #	exit(0);
    79 #}
    79 #}
       
    80 
       
    81 my $sWORKING_DRIVE = "G:";
       
    82 my $output = `G: 2>&1`;
       
    83 $sWORKING_DRIVE = "D:" if ($output =~ /The device is not ready./);
       
    84 print "Will use drive $sWORKING_DRIVE as working drive for this build\n";
    80 
    85 
    81 my $sFbfProjectRev = '';
    86 my $sFbfProjectRev = '';
    82 if ($sFbfProjectRepo =~ m,(.*)#(.*),)
    87 if ($sFbfProjectRepo =~ m,(.*)#(.*),)
    83 {
    88 {
    84 	$sFbfProjectRepo = $1;
    89 	$sFbfProjectRepo = $1;
   118 #	$sSourcesFile =~ m,/(adaptation|app|mw|os|ostools|tools)[\\/]([^\\^/]+),i;
   123 #	$sSourcesFile =~ m,/(adaptation|app|mw|os|ostools|tools)[\\/]([^\\^/]+),i;
   119 #	$sJobLabel = $2;
   124 #	$sJobLabel = $2;
   120 #	$sSourcesFile =~ m,(.*[\\/])?([^\\^/]+),;
   125 #	$sSourcesFile =~ m,(.*[\\/])?([^\\^/]+),;
   121 #	$sJobLabel = $2 if (!$sJobLabel);
   126 #	$sJobLabel = $2 if (!$sJobLabel);
   122 #}
   127 #}
   123 mkdir($sJOB_BASE_DIR) if (!-d$sJOB_BASE_DIR);
   128 mkdir("$sWORKING_DRIVE\\$sJOB_BASE_DIR") if (!-d "$sWORKING_DRIVE\\$sJOB_BASE_DIR");
   124 my $sJobDir = mkdir_unique("$sJOB_BASE_DIR\\$sJobLabel");
   129 my $sJobDir = mkdir_unique("$sWORKING_DRIVE\\$sJOB_BASE_DIR\\$sJobLabel");
   125 print "Created project dir $sJOB_BASE_DIR\\$sJobLabel\n";
   130 print "Created project dir $sWORKING_DRIVE\\$sJOB_BASE_DIR\\$sJobLabel\n";
   126 
   131 
   127 print("cd $sBOOTSTRAP_DIR\n");
   132 print("cd $sBOOTSTRAP_DIR\n");
   128 chdir("$sBOOTSTRAP_DIR");
   133 chdir("$sBOOTSTRAP_DIR");
   129 print "###### BOOTSTRAP ######\n";
   134 print "###### BOOTSTRAP ######\n";
   130 my $sConfigArg = "-Dsf.config.repo=$sFbfConfigRepo";
   135 my $sConfigArg = "-Dsf.config.repo=$sFbfConfigRepo";
   169 }
   174 }
   170 my $nJobNumber = sprintf("%.3d", $nUnformattedNumber);
   175 my $nJobNumber = sprintf("%.3d", $nUnformattedNumber);
   171 $nJobNumber = "T$nJobNumber" if (!$bProduction);
   176 $nJobNumber = "T$nJobNumber" if (!$bProduction);
   172 
   177 
   173 # check that $sLETTERS_FILE exists, otherwise create it
   178 # check that $sLETTERS_FILE exists, otherwise create it
   174 if (!-f $sLETTERS_FILE)
   179 if (!-f "$sWORKING_DRIVE\\$sLETTERS_FILE")
   175 {
   180 {
   176 	open FILE, ">$sLETTERS_FILE";
   181 	open FILE, ">$sWORKING_DRIVE\\$sLETTERS_FILE";
   177 	print FILE "\n";
   182 	print FILE "\n";
   178 	close FILE;
   183 	close FILE;
   179 }
   184 }
   180 
   185 
   181 # acquire drive letter
   186 # acquire drive letter
   289 	
   294 	
   290 	my $nAttempts = 0;
   295 	my $nAttempts = 0;
   291 	my $bAcquired = 0;
   296 	my $bAcquired = 0;
   292 	do
   297 	do
   293 	{
   298 	{
   294 		open(FILE, "+<$sLETTERS_FILE") or die("Can't open $sLETTERS_FILE");
   299 		open(FILE, "+<$sWORKING_DRIVE\\$sLETTERS_FILE") or die("Can't open $sWORKING_DRIVE\\$sLETTERS_FILE");
   295 		if ( flock(FILE, 6) )
   300 		if ( flock(FILE, 6) )
   296 		{
   301 		{
   297 			my $sLine;
   302 			my $sLine;
   298 			while ($sLine = <FILE>)
   303 			while ($sLine = <FILE>)
   299 			{
   304 			{
   360 	
   365 	
   361 	my $nAttempts = 0;
   366 	my $nAttempts = 0;
   362 	my $bAcquired = 0;
   367 	my $bAcquired = 0;
   363 	do
   368 	do
   364 	{
   369 	{
   365 		open(FILE, "+<$sLETTERS_FILE") or die("Can't open $sLETTERS_FILE");
   370 		open(FILE, "+<$sWORKING_DRIVE\\$sLETTERS_FILE") or die("Can't open $sWORKING_DRIVE\\$sLETTERS_FILE");
   366 		if ( flock(FILE, 6) )
   371 		if ( flock(FILE, 6) )
   367 		{
   372 		{
   368 			my $sLine;
   373 			my $sLine;
   369 			while ($sLine = <FILE>)
   374 			while ($sLine = <FILE>)
   370 			{
   375 			{