Adjust patch -p0 for binutils.
[nethome.git] / bin / hammock
index c0c9137..6a1c07b 100755 (executable)
@@ -9,6 +9,7 @@ use Carp qw(&carp);
 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 $fedoracvsroot=q{:pserver:anonymous:@cvs.fedoraproject.org:/cvs/pkgs};
 my $rhelcvsroot=q{:pserver:anonymous:@192.168.67.2:3401/cvs/dist};
@@ -46,7 +47,7 @@ die if !GetOptions(
   "s|srcrpm=s"=>\$srcrpm,
     "file=s{,}"=>\@file,
 );
-$component and ($component=~m{^(?:(?:fedora|rhel)(?:gdb|binutils|glibc)|gdbcvs|archer-.*|/home/.*)$} or die "-c|--component required to be: fedoragdb|rhelgdb|fedorabinutils|rhelbinutils|fedoraglibc|rhelglibc|gdbcvs|archer-*|/home/*");
+$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");
 $component and $srcrpm and die "-c|--component excludes -s|--srcrpm";
 $component or $srcrpm or die "-c|--component or -s|--srcrpm required";
@@ -208,9 +209,7 @@ for my $distro (@distrouse) {
     my($c)=@_;
 
     $c="export PATH=\"$path:\$PATH\"; $c" if $path;
-    $c="export MAKEFLAGS=\"-j\$[`getconf _NPROCESSORS_ONLN`*3/2]\"; $c"
-       # FIXME: The testsuite results from binutils.spec should be uuencoded.
-       if $component!~/^(?:fedora|rhel)binutils$/;
+    $c="export MAKEFLAGS=\"-j\$[`getconf _NPROCESSORS_ONLN`*3/2]\"; $c";
     $c="export http_proxy=http://127.0.0.1:3128/; $c";
     $c="set -ex; cd $builddir; $c";
     die "found ': $c" if $c=~/'/;
@@ -259,11 +258,13 @@ for my $distro (@distrouse) {
 
   my $baretestsuite;
 
-  if ($component eq "gdbcvs") {
-    if (-d $gdbcvsbare) {
-      spawn "cp -a $gdbcvsbare $builddir/src; cd $builddir/src; cvs update -A";
+  if ($component=~/^(gdb|binutils)cvs$/) {
+    my $which=$1;
+    my $cvsbare=$which eq "gdb" ? $gdbcvsbare : $binutilscvsbare;
+    if (-d $cvsbare) {
+      spawn "cp -a $cvsbare $builddir/src; cd $builddir/src; cvs update -A";
     } else {
-      spawn "cd $builddir; cvs -q -z3 -d :pserver:anoncvs:\@sourceware.org:/cvs/src co gdb";
+      spawn "cd $builddir; cvs -q -z3 -d :pserver:anoncvs:\@sourceware.org:/cvs/src co $which";
     }
     spawn "cd $builddir/src".q{; test -z "$(cvs update -A)"};
     $baretestsuite="$builddir/src";
@@ -287,22 +288,34 @@ for my $distro (@distrouse) {
   if ($baretestsuite) {
     for my $file (@file) {
       my $target="$baretestsuite/$file";
-      if ($file=~m{\Q.patch\E$}) {
+      if ($file=~m{[.](R?)patch$}) {
+       my $R=$1;
        my $fileabs=$file;
        $fileabs=$ENV{"PWD"}."/$fileabs" if $fileabs!~m{^/};
-       spawn "cd $baretestsuite; patch -p1 <$fileabs";
+       spawn "cd $baretestsuite; patch -${R}p".($component=~/binutils/ ? "0" : "1")." <$fileabs";
       } else {
        -f $target or $file=~m{/testsuite/} or die "File $file does not exist at $target";
        spawn "rm -f $target; cp -p $file $target";
       }
     }
 
-    my @check=($distro=~/-x86_64/ ? qw(-m64 -m32) : -m32);
-    @check=map("check//unix/$_",@check);
-    # FSF GDB has no PIE support.
-    # @check=map({($_,"$_/-fPIE/-pie");} @check);
-    # 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;};
+    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);
+      # FSF GDB has no PIE support.
+      # @check=map({($_,"$_/-fPIE/-pie");} @check);
+      # 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;};
+    }
   }
 
   # Call gdbunpack only if no direct $out directory will be created.
@@ -311,12 +324,11 @@ for my $distro (@distrouse) {
   my @testinlog;
   if ($component=~/^(?:fedora|rhel)glibc$/) {
     @testinlog=(qr/={20}TESTING DETAILS={17}/,qr/={20}PLT RELOCS END={18}/);
-  } elsif ($component=~/^(?:fedora|rhel)binutils$/) {
-    @testinlog=(qr/={20}TESTING={25}/,qr/={20}TESTING END={21}/);
   }
   if (@testinlog) {
     subst sub { s{^.*?\n($testinlog[0]\n.*\n$testinlog[1]\n).*$}{$1}s; },$log,$out;
   } elsif ($cvsbasedir || $srcrpm) {
+    # Applies both to gdb and binutils.
     spawn "gdbunpack $log";
   }