X-Git-Url: https://git.jankratochvil.net/?p=nethome.git;a=blobdiff_plain;f=bin%2Fhammock;h=16053edd5b425ae96368bf6edf3cf1645590c4c0;hp=aeb561b358081a811830cf855357fec2180b72b7;hb=1ca3a51056b03b424d2ab531b43ef75c8d67fc43;hpb=aa2ef342f4f3cf1681cdfe44be8887c3ff66f71d diff --git a/bin/hammock b/bin/hammock index aeb561b..16053ed 100755 --- a/bin/hammock +++ b/bin/hammock @@ -8,13 +8,16 @@ use Getopt::Long qw(:config no_ignore_case); use Carp qw(&carp); my $start=time(); -my $gdbcvsbare=$ENV{"HOME"}."/redhat/gdb-cvs-bare"; -my $binutilscvsbare=$ENV{"HOME"}."/redhat/binutils-cvs-bare"; +my $gdbcvsmaster=$ENV{"HOME"}."/redhat/gdb-cvs-master"; +my $binutilscvsmaster=$ENV{"HOME"}."/redhat/binutils-cvs-master"; my $archermaster=$ENV{"HOME"}."/redhat/archer-master"; my $fedoracvsroot=q{:pserver:anonymous:@cvs.fedoraproject.org:/cvs/pkgs}; +#Unknown host cvs.devel.redhat.com. +#my $rhelcvsroot=q{:pserver:anonymous:@cvs.devel.redhat.com:/cvs/dist}; my $rhelcvsroot=q{:pserver:anonymous:@192.168.67.2:3401/cvs/dist}; my $arch_i386=qr{(?:x86|i\d86|ia32)}io; my $arch_x86_64=qr{(?:x8664|x86_64|em64t)}io; +my $resultdir=$ENV{"HOME"}."/.hammock-result"; my @arches=qw(i386 x86_64); my $error=0; @@ -39,6 +42,7 @@ my $configure; my $branch; # FIXME: Connect make paralellization to the children. my $distrojobs; +my $gdbcvspie; die if !GetOptions( "i|userid=s"=>\$userid, "force"=>\$force, @@ -56,6 +60,7 @@ die if !GetOptions( "D|distrojobs=s"=>\$distrojobs, "configure=s"=>\$configure, "branch=s"=>\$branch, + "gdbcvspie"=>\$gdbcvspie, ); $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"); @@ -68,6 +73,7 @@ if ($component=~/^(gdb|binutils)cvs$/) { } else { die "--branch currently unsupported for non-CVS sources" if $branch; } +!$gdbcvspie or $component eq "gdbcvs" or die "--gdbcvspie requires -c gdbcvs"; @target and ($srcrpm or $component=~/^(?:fedora|rhel)/) and die "--target is available only for baretestsuite modes"; my %target; do { error "Duplicate target: $_\n" if $target{$_}++; } for @target; @@ -95,7 +101,8 @@ sub distro_normalize($;$) s{/+$}{}; s/^.*$/\L$&/s; s/^(?:devel|rawhide)\b/fedora-rawhide/; - s/^(?:epel|rhel|centos)-?(\d)/epel-$1/; + s/^(?:epel|centos)-?(\d)/epel-$1/; + s/^(?:rhel)-?(\d)/rhel-$1/; s/^(?:f|fedora)-?(\d)/fedora-$1/; my @archuse; @archuse="" if -d "/var/lib/mock/$_"; @@ -131,30 +138,39 @@ for my $distroi (0..$#distro) { } } -sub newdir($) +# "-p", "mayexist" +sub newdir($;@) { - my($dir)=@_; + my($dir,@opt)=@_; - warn "+ mkdir $dir\n"; - mkdir $dir or die "mkdir $dir: $!"; + my %opt=map(($_=>1),@opt); + warn "+ mkdir".($opt{"-p"} ? " -p" : "")." $dir\n"; + mkdir $dir or ($opt{"mayexist"} && $!{EEXIST}) or die "mkdir $dir: $!"; } my $log; -sub spawn($) +# "bare" +sub spawn($;%) { - my($cmd)=@_; - - $cmd="set -ex; $cmd"; - my $ok="$log.ok" if $log; - $cmd="($cmd; touch $ok) 2>&1|tee -a $log; test -f $ok" if $log; - unlink $ok if $ok; + my($cmd,@opt)=@_; + + my %opt=map(($_=>1),@opt); + my $ok; + if (!$opt{"bare"}) { + $cmd="set -ex; $cmd"; + $ok="$log.ok" if $log; + $cmd="($cmd; touch $ok) 2>&1|tee -a $log; test -f $ok" if $log; + unlink $ok if $ok; + } else { + warn "+ $cmd\n"; + } # warn "+ $cmd\n"; system $cmd and die "$cmd: $!"; unlink $ok if $ok; } my $basedir=$ENV{"HOME"}."/hammock"; --d $basedir or newdir $basedir; +newdir $basedir,"mayexist"; my $idbase=strftime("%Y%m%d",localtime()); my $id; my $dir; @@ -163,7 +179,7 @@ for my $seq (defined $userid ? $userid : (0..99)) { $dir="$basedir/$id"; last if ! -e $dir; } -spawn "rm -rf $dir" if -d $dir && $force && defined $userid; +spawn "chmod -R u+w $dir; rm -rf $dir" if -d $dir && $force && defined $userid; error "Directory not free: $dir" if !$id || !$dir || -e $dir; print STDERR "ID = $id | dir = $dir\n"; error "No distros specified" if !@distrouse; @@ -182,16 +198,34 @@ sub writefile spawn "renice 20 -p $$"; newdir $dir; $log="$dir/log"; +my $resultid="$resultdir/$id"; +my $resultidxz="$resultid.tar.xz"; +newdir $resultdir,"mayexist"; +spawn "rm -rf $resultid" if -d $resultid && $force; +newdir $resultid; +unlink $resultidxz or $!{ENOENT} or die "unlink $resultidxz: $!"; spawn "uname -r >$dir/kernel"; my %dump=( "path"=>$path, "component"=>$component, + "branch"=>$branch, "srcrpm"=>$srcrpm, "file"=>join("\n",@file), "configure"=>$configure, + "gdbcvspie"=>$gdbcvspie, ); while (my($name,$val)=each(%dump)) { - writefile "$dir/$name","$val\n" if $val; + next if !$val; + writefile "$dir/$name","$val\n"; + link "$dir/$name","$resultid/$name" or warn "link $dir/$name $resultid/$name: $!"; +} +for my $file (@file) { + newdir "$dir/file.d","mayexist"; + (my $base=$file)=~s{^.*/}{}; + my $d="$dir/file.d/$base"; + link $file,$d or die "link $file $d: $!"; + newdir "$resultid/file.d","mayexist"; + link $d,"$resultid/file.d/$base" or warn "link $file $resultid/file.d/$base: $!"; } sub subst @@ -232,7 +266,7 @@ while (@distrouse || keys(%child)) { } if ($component=~/^rhel(.*)$/) { $cvsrepo=$1; - $cvsbasedir="RHEL-$1" if $componentdistro=~/^epel-(\d+)$/; + $cvsbasedir="RHEL-$1" if $componentdistro=~/^(?:epel|rhel)-(\d+)$/; die "$component vs. $componentdistro" if !$cvsbasedir; $cvsroot=$rhelcvsroot; # EPEL still uses Berkeley DB version 8 while F-11+ (F-10?) uses version 9. @@ -319,9 +353,9 @@ while (@distrouse || keys(%child)) { 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 $cvsbranch"; + my $cvsmaster=$which eq "gdb" ? $gdbcvsmaster : $binutilscvsmaster; + if (-d $cvsmaster) { + spawn "cp -a $cvsmaster $builddir/src; cd $builddir/src; cvs update $cvsbranch"; } else { spawn "cd $builddir; cvs -q -z3 -d :pserver:anoncvs:\@sourceware.org:/cvs/src co $cvsbranch $which"; } @@ -367,10 +401,9 @@ while (@distrouse || keys(%child)) { } 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); + @check=map({($_,"$_/-fPIE/-pie");} @check) if $gdbcvspie; # 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;}; + 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".q{$suffix.$t || :; done; done;}; } # gdbunpack does: # perl -i -pe 's{\Q'"$HOME"'\E/.*?/build/[^/]*/}{}g' "$base"/* @@ -396,6 +429,17 @@ while (@distrouse || keys(%child)) { spawn "gdbunpack $log"; } + my $resultout="$resultdir/$id/$distrodirbase"; + newdir $resultout; + $resultout.="/out"; + newdir $resultout; + for my $fname (glob "$out/*") { + (my $base=$fname)=~s{^.*/}{}; + my $d="$resultout/$base"; + warn "+ link $fname $d\n"; + link $fname,$d or warn $!; + } + exit 0 if $parallel>1; } @@ -411,6 +455,8 @@ while (@distrouse || keys(%child)) { die if keys(%child); die if @distrouse; +spawn "(set -e -o pipefail;cd $resultdir;tar cf - $id|xz -9e >$resultidxz;rm -rf $id)&","bare"; + sub timestr($) { my($sec)=@_;