Support build RPM packages for incremental build
authorZhang Qiang <qiang.z.zhang@intel.com>
Wed, 7 Nov 2012 08:22:57 +0000 (16:22 +0800)
committerZhang Qiang <qiang.z.zhang@intel.com>
Fri, 9 Nov 2012 06:48:18 +0000 (14:48 +0800)
* call --short-circuit --stage=-bs to build PRMs
* copy RPMs to local repo
* make incremental build in scratch.{arch}.*

Change-Id: Idbe915bef86785776bfc755efb1399d232cd5f9a

depanneur

index b4ebab464c0cfe14e363c7c5f3d000c317600500..ff306630360e3d94ca9d7b33d0e61542dcb7f397 100755 (executable)
--- a/depanneur
+++ b/depanneur
@@ -968,70 +968,60 @@ sub build_package {
         push @args, "--repository $r";
     }
 
-    if ( ($clean || $cleanonce ) && ( ! grep $_ == $thread, @cleaned) &&
-          $incremental == 0)  {
+    if ( ($clean || $cleanonce ) && ( ! grep $_ == $thread, @cleaned) ) {
        push @args, "--clean";
        if ($cleanonce) {
             push(@cleaned, $thread);
        }
     }
     my $scratch = "$scratch_dir.$thread";
-
     my $redirect = "";
     if ($MAX_THREADS > 1 ) {
         $redirect = "> /dev/null 2>&1";
     }
-    @args_inc = @args;
+
+    push @args, "--root $scratch";
+    push @args, "--clean" if (-e "$scratch/not-ready");
+    push @args, $redirect;
+
     my $cmd = "";
+    my $builddir = "$scratch/home/abuild/rpmbuild/BUILD/$name-$version";
     if ($incremental == 1) {
         info("doing incremental build");
+        @args_inc = @args;
         my $buildcmd = "";
-        if ( -d "$scratch_dir.incremental/home/abuild/rpmbuild/BUILD/$name-$version" ) {
-            $scratch = "$scratch_dir.incremental";
-        } elsif ( ! -d "$scratch/home/abuild/rpmbuild/BUILD/$name-$version" ){
-            debug("Build directory exists");
-            $scratch = "$scratch_dir.incremental";
-            push @args, "--stage=\"-bp\"";
-            push @args, "--root $scratch";
-            push @args, "--clean";
-            push @args, $redirect;
-            $cmd = join(" ", @args);
+        if ( ! -d "$builddir" || grep($_ eq "--clean", @args_inc)){
+            debug("Build directory does not exist");
+            push @args_inc, "--stage=\"-bp\"";
+            push @args_inc, "--clean" if (! grep($_ eq "--clean", @args_inc));
+            $cmd = join(" ", @args_inc);
             return -1 if (my_system($cmd) != 0);
         } else {
-            info("build directory does not exist");
+            debug("build directory exists");
         }
         my $project_base_path = $to_build{$name}->{project_base_path};
-        my $mount = "sudo mount -o bind $project_base_path $scratch/home/abuild/rpmbuild/BUILD/$name-$version";
+        if (! -e "$builddir") {
+            my_system("sudo mkdir -p $builddir");
+        }
+        my $mount = "sudo mount -o bind $project_base_path $builddir";
         my_system($mount);
         if ($run_configure == 1 ) {
-            push @args_inc, "--define '%configure echo'";
-            push @args_inc, "--define '%reconfigure echo'";
-            push @args_inc, "--define '%autogen echo'";
+            push @args, "--define '%configure echo'";
+            push @args, "--define '%reconfigure echo'";
+            push @args, "--define '%autogen echo'";
         }
-        push @args_inc, "--stage=\"-bp\"";
-        push @args_inc, "--root $scratch";
-        push @args_inc, "--no-topdir-cleanup";
-        push @args_inc, "--no-init";
-        push @args_inc, "--short-circuit --stage=\"-bc\"";
-        push @args_inc, $redirect;
-        $cmd = join(" ", @args_inc);
-        my_system ($cmd);
-
-        $mount = "sudo umount $scratch/home/abuild/rpmbuild/BUILD/$name-$version";
-        my_system($mount);
-        info("finished incremental building $name");
-        info("building log can be found here: $scratch/.build.log");
-        $packages_built = 1;
-        return 0;
+        push @args, "--root $scratch";
+        push @args, "--no-topdir-cleanup";
+        push @args, "--no-init";
+        @args = grep { $_ ne "--clean"} @args;
+        push @args, "--short-circuit --stage=\"-bs\"";
     }
 
-    push @args, "--root $scratch";
-    push @args, "--clean" if (-e "$scratch/not-ready");
-    push @args, $redirect;
-
     $cmd = join(" ", @args);
     debug($cmd);
-    if (my_system ($cmd) == 0 ) {
+    my $ret = my_system ($cmd);
+    my_system("sudo umount $builddir") if ($incremental == 1);
+    if ($ret == 0) {
         if (bsd_glob "$scratch/home/abuild/rpmbuild/SRPMS/*.rpm") {
             my_system ("cp $scratch/home/abuild/rpmbuild/SRPMS/*.rpm $localrepo/$dist/src/SRPMS");
         }