Support mock roots with --uniqueext (and thus no arch at its suffix).
[nethome.git] / bin / hammock
index 19ba50b..a25c20e 100755 (executable)
@@ -10,7 +10,7 @@ my $start=time();
 
 my $gdbcvsbare=$ENV{"HOME"}."/redhat/gdb-cvs-bare";
 my $binutilscvsbare=$ENV{"HOME"}."/redhat/binutils-cvs-bare";
-my $archermaster=$ENV{"HOME"}."/redhat/master";
+my $archermaster=$ENV{"HOME"}."/redhat/archer-master";
 my $fedoracvsroot=q{:pserver:anonymous:@cvs.fedoraproject.org:/cvs/pkgs};
 my $rhelcvsroot=q{:pserver:anonymous:@192.168.67.2:3401/cvs/dist};
 my $arch_i386=qr{(?:x86|i\d86|ia32)}io;
@@ -35,6 +35,7 @@ my $component;
 my $srcrpm;
 my @file;
 my @target;
+my $configure;
 # FIXME: Connect make paralellization to the children.
 my $distrojobs;
 die if !GetOptions(
@@ -52,6 +53,7 @@ die if !GetOptions(
     "file=s{,}"=>\@file,
     "target=s{,}"=>\@target,
   "D|distrojobs=s"=>\$distrojobs,
+    "configure=s"=>\$configure,
 );
 $component and ($component=~m{^(?:(?:fedora|rhel)(?:gdb|binutils|glibc)|gdbcvs|binutilscvs|archer-.*|/home/.*)$} or die "-c|--component required to be: fedoragdb|rhelgdb|fedorabinutils|rhelbinutils|fedoraglibc|rhelglibc|gdbcvs|binutilscvs|archer-*|/home/*");
 $component and $component=~m{^/home/} and (-f "$component/gdb/gdbtypes.c" or die "$component/gdb/gdbtypes.c not found");
@@ -76,9 +78,10 @@ error "Excessive arguments: @ARGV" if @ARGV;
 my $path=join(":",@path) if @path;
 @componentdistro and @componentdistro!=@distro and die "--cd|--componentdistro must have the same elements count as -d|--distro";
 
-sub distro_normalize($)
+sub distro_normalize($;$)
 {
-  local $_=$_[0];
+  my($name,$force)=@_;
+  local $_=$name;
 
   s{^/var/lib/mock/+}{};
   s{/+$}{};
@@ -87,12 +90,13 @@ sub distro_normalize($)
   s/^(?:epel|rhel|centos)-?(\d)/epel-$1/;
   s/^(?:f|fedora)-?(\d)/fedora-$1/;
   my @archuse;
+  @archuse="" if -d "/var/lib/mock/$_";
   @archuse="i386" if s/-$arch_i386$//o;
   @archuse="x86_64" if s/-$arch_x86_64$//o;
 
   for my $arch (@archuse?@archuse:@arch) {
-    my $dir="/var/lib/mock/$_-$arch";
-    -d $dir or error "No distro: $dir";
+    my $dir="/var/lib/mock/$_".(!$arch?"":"-$arch");
+    $force or -d $dir or error "No distro: $dir";
   }
 
   return ($_,@archuse);
@@ -105,7 +109,8 @@ for my $distroi (0..$#distro) {
   my $componentdistro=$componentdistro[$distroi];
   my @archuse;
   if ($componentdistro) {
-    ($componentdistro,@archuse)=distro_normalize $componentdistro;
+    my $force=($componentdistro=~s/!$//);
+    ($componentdistro,@archuse)=distro_normalize $componentdistro,$force;
     @archuse and die "--cd|--componentdistro must have no arch: ".join(" ",@archuse);
   }
   ($distro,@archuse)=distro_normalize $distro;
@@ -113,7 +118,7 @@ for my $distroi (0..$#distro) {
   @archuse=@arch if !@archuse;
   for my $archuse (@archuse) {
     for my $target (@target?@target:undef()) {
-      push @distrouse,{"distro"=>"$distro-$archuse","componentdistro"=>$componentdistro,"target"=>$target};
+      push @distrouse,{"distro"=>$distro.(!$archuse?"":"-$archuse"),"componentdistro"=>$componentdistro,"target"=>$target};
     }
   }
 }
@@ -175,6 +180,7 @@ my %dump=(
   "component"=>$component,
   "srcrpm"=>$srcrpm,
   "file"=>join("\n",@file),
+  "configure"=>$configure,
 );
 while (my($name,$val)=each(%dump)) {
   writefile "$dir/$name","$val\n" if $val;
@@ -346,16 +352,10 @@ while (@distrouse || keys(%child)) {
 
       my $errs1="errs1";
       $errs1.=" --target=$target" if $target;
+      $errs1.=" $configure" if $configure;
 
       if ($component eq "binutilscvs") {
        mockrun "cd $baretestsuite; $errs1; errs2; ulimit -c unlimited; orphanripper make -k check || :; mkdir $out; ".q{for file in {gas/testsuite/gas,ld/ld,binutils/binutils}.{sum,log};do ln $file}." $out/binutils-$distro-".q{$(basename $file) || :; done;};
-
-       # gdbunpack does:
-       #               perl -i -pe 's{\Q'"$HOME"'\E/.*?/build/[^/]*/}{}g' "$base"/*
-       my $HOME=$ENV{"HOME"};
-       for my $file (<$out/*>) {
-         subst sub { s{\Q$HOME\E/.*?/build/[^/]*/}{}g; },$file;
-       }
       } else {
        my @check=($distro=~/-x86_64/ ? qw(-m64 -m32) : -m32);
        @check=map("check//unix/$_",@check);
@@ -364,6 +364,12 @@ while (@distrouse || keys(%child)) {
        # for i in ".join(" ",@check).";do orphanripper make -k \$i || :;done
        mockrun "cd $baretestsuite; $errs1; errs2; cd gdb; ulimit -c unlimited; orphanripper make -k ".join(" ",@check)." || :; mkdir $out; ".q{for t in sum log;do for file in testsuite*/gdb.$t;do suffix="${file#testsuite.unix.}"; suffix="${suffix%/gdb.$t}"; ln $file}." $out/gdb-$distro".q{$suffix.$t || :; done; done;};
       }
+      # gdbunpack does:
+      #                perl -i -pe 's{\Q'"$HOME"'\E/.*?/build/[^/]*/}{}g' "$base"/*
+      my $HOME=$ENV{"HOME"};
+      for my $file (<$out/*>) {
+       subst sub { s{\Q$HOME\E/.*?/build/[^/]*/}{}g; },$file;
+      }
     } else {
       die "internal error" if @target;
     }