Add removal of job directories if build is run from build management system (i.e. --hudson is given)
authorDario Sestito <darios@symbian.org>
Wed, 05 Aug 2009 11:16:03 +0100
changeset 35 4d500511bf5a
parent 34 d156d56b00c2
child 36 c2062b9445d0
Add removal of job directories if build is run from build management system (i.e. --hudson is given)
build_package.pl
--- a/build_package.pl	Mon Aug 03 15:53:45 2009 +0100
+++ b/build_package.pl	Wed Aug 05 11:16:03 2009 +0100
@@ -155,7 +155,7 @@
 #}
 mkdir("$sWORKING_DRIVE\\$sJOB_BASE_DIR") if (!-d "$sWORKING_DRIVE\\$sJOB_BASE_DIR");
 my $sJobDir = mkdir_unique("$sWORKING_DRIVE\\$sJOB_BASE_DIR\\$sJobLabel");
-print "Created project dir $sWORKING_DRIVE\\$sJOB_BASE_DIR\\$sJobLabel\n";
+print "Created project dir $sWORKING_DRIVE\\$sJOB_BASE_DIR\\$sJobDir\n";
 
 print("cd $sBOOTSTRAP_DIR\n");
 chdir("$sBOOTSTRAP_DIR");
@@ -177,6 +177,7 @@
 	close FILE;
 }
 
+my $sJobNumberKey = '';
 my $nUnformattedNumber = 0;
 if ($nCmdLineNumber)
 {
@@ -184,7 +185,6 @@
 }
 elsif ($sFbfProjectRepo)
 {
-	my $sJobNumberKey = '';
 	if ($sSubProject)
 	{
 		# key = <package>_<codeline>, e.g. for subproj=MCL/os/boardsupport -> key=boardsupport_MCL
@@ -202,6 +202,7 @@
 }
 my $nJobNumber = sprintf("%.3d", $nUnformattedNumber);
 $nJobNumber = "T$nJobNumber" if (!$bProduction);
+print "For build key $sJobNumberKey got assigned number \"$nJobNumber\"\n";
 
 # check that $sLETTERS_FILE exists, otherwise create it
 if (!-f "$sWORKING_DRIVE\\$sLETTERS_FILE")
@@ -235,6 +236,21 @@
 system("subst $sDriveLetter: /d"); # this is not required, but it's a good idea to keep things in order
 print "drive letter $sDriveLetter released (and drive unsubsted)\n";
 
+if ($bHudson)
+{
+	print "cleaning job directories...\n";
+	if (-d "$sWORKING_DRIVE\\$sJOB_BASE_DIR\\$sJobLabel") # project dir
+	{
+		print "rmdir /S $sWORKING_DRIVE\\$sJOB_BASE_DIR\\$sJobLabel\n";
+		system("rmdir /S /Q $sWORKING_DRIVE\\$sJOB_BASE_DIR\\$sJobLabel");
+	}
+	if (-d "$sWORKING_DRIVE\\fbf_job\\$sJobNumberKey.$nJobNumber") # build drive
+	{
+		print "rmdir /S $sWORKING_DRIVE\\fbf_job\\$sJobNumberKey.$nJobNumber\n";
+		system("rmdir /S /Q $sWORKING_DRIVE\\fbf_job\\$sJobNumberKey.$nJobNumber");
+	}
+}
+
 sub mkdir_unique
 {
 	my ($sBaseDir) = @_;