implement incremental build
authorAnas Nashif <anas.nashif@intel.com>
Mon, 23 Jul 2012 23:48:16 +0000 (00:48 +0100)
committerAnas Nashif <anas.nashif@intel.com>
Mon, 23 Jul 2012 23:48:16 +0000 (00:48 +0100)
Change-Id: I87f8310a6f582e5d41de84e28a89d8aebabacc18

depanneur

index 3d83e6e..988b51e 100755 (executable)
--- a/depanneur
+++ b/depanneur
@@ -85,6 +85,7 @@ my $man = 0;
 my $cleanonce = 0;
 my $debug = 0;
 my $incremental = 0;
+my $run_configure = 0;
 my $overwrite = 0;
 my $MAX_THREADS = 1;
 my $suffix = "";
@@ -111,10 +112,10 @@ GetOptions (
     "suffix=s" => \$suffix,
     "debug" => \$debug,
     "incremental" => \$incremental,
+    "no-configure" => \$run_configure,
     "threads=s" => \$MAX_THREADS,
     );
 
-
 my $scratch_dir = "$build_root/local/scratch.$arch";
 
 if ( $exclude_from_file ne "" && -e $exclude_from_file ) {
@@ -697,8 +698,37 @@ sub build_package {
     if ($MAX_THREADS > 1 ) {
         $redirect = "> /dev/null 2>&1";
     }
-    if ($incremental) {
-        my $incremental_opt = "--short-circuit --stage -bc";
+    my $incremental_opt = "";
+    if ($incremental == 1) {
+        print "Doing incremental build\n";
+        my $buildcmd = "";
+        if ( ! -d "$scratch/home/abuild/rpmbuild/BUILD/$name-$version" ) {
+            print "Build directory exists\n";
+            my $incremental_opt = "--stage=\"-bp\"";
+            $scratch = "$scratch_dir.incremental";
+            $buildcmd = "sudo BUILD_ROOT=$scratch BUILD_DIR=\"$build_dir\" $virtualenv/usr/bin/build --uid $zuid:$zgid --jobs 4 $clean_option $incremental_opt --cachedir $cache_dir --dist $dist --configdir $dist_configs $repos $srpm_filename $redirect  ";
+            system ($buildcmd);
+        } else {
+            print "Build directory does not exist\n";
+        }
+        my $mount = "sudo mount -o bind $path $scratch/home/abuild/rpmbuild/BUILD/$name-$version";
+        system($mount);
+        my $incremental_opt = "--short-circuit --stage=\"-bc\"";
+        my $no_configure = "";
+        if ($run_configure == 1 ) {
+            $no_configure = "--define '%configure echo' --define '%autogen echo' --define '%reconfigure echo'";
+        }
+        $buildcmd = "sudo BUILD_ROOT=$scratch BUILD_DIR=\"$build_dir\" $virtualenv/usr/bin/build $no_configure --no-topdir-cleanup --no-init --uid $zuid:$zgid --jobs 4 $clean_option $incremental_opt --cachedir $cache_dir --dist $dist --configdir $dist_configs $repos $srpm_filename $redirect  ";
+        system ($buildcmd);
+        $mount = "sudo umount $scratch/home/abuild/rpmbuild/BUILD/$name-$version";
+        system($mount);
+        # Detach and terminate
+        {
+            lock($DETACHING);
+            threads->detach() if ! threads->is_detached();
+        }
+        print GREEN, "finished incremental building $name\n", RESET;
+        exit(1);
     }
     my $buildcmd = "sudo BUILD_ROOT=$scratch BUILD_DIR=\"$build_dir\" $virtualenv/usr/bin/build --uid $zuid:$zgid --jobs 4 $clean_option $incremental_opt --cachedir $cache_dir --dist $dist --configdir $dist_configs $repos $srpm_filename $redirect  ";
     debug("$buildcmd");