binutils support etc.
authorjkratoch <>
Sat, 11 Jul 2009 08:53:22 +0000 (08:53 +0000)
committerjkratoch <>
Sat, 11 Jul 2009 08:53:22 +0000 (08:53 +0000)
bin/hammock

index d477300..c0c9137 100755 (executable)
@@ -46,7 +46,7 @@ die if !GetOptions(
   "s|srcrpm=s"=>\$srcrpm,
     "file=s{,}"=>\@file,
 );
-$component and ($component=~m{^(?:(?:fedora|rhel)(?:gdb|glibc)|gdbcvs|archer-.*|/home/.*)$} or die "-c|--component required to be: fedoragdb|rhelgdb|fedoraglibc|rhelglibc|gdbcvs|archer-*|/home/*");
+$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{^/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";
@@ -139,24 +139,47 @@ while (my($name,$val)=each(%dump)) {
   close F or die $fname;
 }
 
+sub subst
+{
+  my($sub,$in,$out)=@_;
+
+  $out||=$in;
+
+  local *F;
+  open F,$in or die $in;
+  local $_=do { local $/; <F>; } or die $in;
+  close F or die $in;
+
+  &{$sub}() or die $_."\nError substituting $in";
+
+  open F,">$out" or die $out;
+  print F $_ or die $out;
+  close F or die $out;
+}
+
 # PID->distro
 my %child;
 for my $distro (@distrouse) {
+  my $rpmbuild="rpmbuild";
+
   my $cvsbasedir;
   my $cvsroot;
   my $cvsrepo;
-  if ($component=~/^fedora(gdb|glibc)$/) {
+  if ($component=~/^fedora(gdb|binutils|glibc)$/) {
     $cvsrepo=$1;
     $cvsbasedir="F-$1" if $distro=~/^fedora-(\d+)-$arches_re$/;
     $cvsbasedir="devel" if $distro=~/^fedora-rawhide-$arches_re$/;
     die "$component vs. $distro" if !$cvsbasedir;
     $cvsroot=$fedoracvsroot;
   }
-  if ($component=~/^rhel(gdb|glibc)$/) {
+  if ($component=~/^rhel(gdb|binutils|glibc)$/) {
     $cvsrepo=$1;
     $cvsbasedir="RHEL-$1" if $distro=~/^epel-(\d+)-$arches_re$/;
     die "$component vs. $distro" if !$cvsbasedir;
     $cvsroot=$rhelcvsroot;
+    # EPEL still uses Berkeley DB version 8 while F-11+ (F-10?) uses version 9.
+    # Using db_dump and db_load would no longer make it mock compatible.
+    $rpmbuild.=q{ --dbpath $PWD --nodeps};
   }
 
   my $distrodir="$dir/$distro";
@@ -176,20 +199,24 @@ for my $distro (@distrouse) {
   my $builddir="$distrodir/build";
   newdir $builddir;
 
+  # Do not use mockrun as the rpm database may be in a different version.
+  spawn "rpm -r /var/lib/mock/$distro/root -qa|sort >$distrodir/rpm-qa";
+
   $::distro=$distro;
   sub mockrun($)
   {
     my($c)=@_;
 
     $c="export PATH=\"$path:\$PATH\"; $c" if $path;
-    $c="export MAKEFLAGS=\"-j\$[`getconf _NPROCESSORS_ONLN`*3/2]\"; $c";
+    $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 http_proxy=http://127.0.0.1:3128/; $c";
     $c="set -ex; cd $builddir; $c";
     die "found ': $c" if $c=~/'/;
     spawn "mockrun $::distro '$c'";
   }
 
-  mockrun "rpm -qa|sort >$distrodir/rpm-qa";
-
   if ($cvsbasedir) {
     die if !$cvsroot;
     die if !$cvsrepo;
@@ -198,6 +225,8 @@ for my $distro (@distrouse) {
     -d $componentdir or die "Failed checkout to: $componentdir";
     # Required for RHEL; Fedora does so automatically.
     spawn "cd $componentdir/..; cvs -q -z3 -d $cvsroot co common";
+    # Workaround (RHEL-5?) curl which uses `Pragma: nocache' on $http_proxy.
+    subst sub { s{echo "curl }{$&-H 'Pragma: cache' }; },"$componentdir/../common/Makefile.common";
 
     for my $file (@file) {
       my $filebase=$file;
@@ -210,7 +239,9 @@ for my $distro (@distrouse) {
 
     my $glob="$componentdir/*.src.rpm";
     @{[glob $glob]}==0 or die "Found some before test-srpm: $glob";
-    spawn "cd $componentdir; make test-srpm";
+    # No `spawn' as we could get:
+    # error: unpacking of archive failed on file X;4a56efef: cpio: MD5 sum mismatch
+    mockrun "cd $componentdir; make test-srpm";
     my @srcrpm=(glob $glob);
     @srcrpm==1 or die "Did not find 1 srcrpm: @srcrpm";
     $srcrpm=$srcrpm[0];
@@ -221,7 +252,7 @@ for my $distro (@distrouse) {
     $srcrpmbasename=~s{^.*/}{};
     spawn "cp -p $srcrpm $builddir/$srcrpmbasename";
 
-    my $rpmbuildlocal=q{rpmbuild --define "_topdir $PWD" --define "_builddir $PWD" --define "_rpmdir $PWD" --define "_sourcedir $PWD" --define "_specdir $PWD" --define "_srcrpmdir $PWD" --define "_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm"};
+    my $rpmbuildlocal=$rpmbuild.q{ --define "_topdir $PWD" --define "_builddir $PWD" --define "_rpmdir $PWD" --define "_sourcedir $PWD" --define "_specdir $PWD" --define "_srcrpmdir $PWD" --define "_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm"};
     $rpmbuildlocal="orphanripper $rpmbuildlocal" if $cvsrepo && $cvsrepo eq "glibc";
     mockrun $rpmbuildlocal." --rebuild --with testsuite".($parallel<2 ? "" : " --with parallel")." $srcrpmbasename";
   }
@@ -277,16 +308,14 @@ for my $distro (@distrouse) {
   # Call gdbunpack only if no direct $out directory will be created.
   # It is needed only for .src.rpm-built testsuites, no matter how .src.rpm
   # got created.
+  my @testinlog;
   if ($component=~/^(?:fedora|rhel)glibc$/) {
-    local *F;
-    open F,$log or die $log;
-    my $F=do { local $/; <F>; } or die $log;
-    close F or die $log;
-    $F=~s{^.*?\n(={20}TESTING DETAILS={17}\n.*\n={20}PLT RELOCS END={18}\n).*$}{$1}s or die "No TESTING part found: $log";
-
-    open F,">$out" or die $out;
-    print F $F or die $out;
-    close F or die $out;
+    @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) {
     spawn "gdbunpack $log";
   }