X-Git-Url: https://git.jankratochvil.net/?a=blobdiff_plain;f=bin%2Fhammock;h=8102e159dadd29ee7c3557f38ba48a2c1a2cbbe9;hb=ee2604be2545bf1c77d421a8e6570ab69cd34b5d;hp=306d653cc2c138cf0669e89df3be64fbadb8b906;hpb=0130c629d7bd39819e8e086f7f3c27c388ceb16e;p=nethome.git diff --git a/bin/hammock b/bin/hammock index 306d653..8102e15 100755 --- a/bin/hammock +++ b/bin/hammock @@ -10,11 +10,12 @@ 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; 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; @@ -36,6 +37,7 @@ my $srcrpm; my @file; my @target; my $configure; +my $branch; # FIXME: Connect make paralellization to the children. my $distrojobs; die if !GetOptions( @@ -54,12 +56,19 @@ die if !GetOptions( "target=s{,}"=>\@target, "D|distrojobs=s"=>\$distrojobs, "configure=s"=>\$configure, + "branch=s"=>\$branch, ); $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"; $component||=""; # Make `eq' not complaining. +my $cvsbranch; +if ($component=~/^(gdb|binutils)cvs$/) { + $cvsbranch=(!$branch?"-A":"-r $branch"); +} else { + die "--branch currently unsupported for non-CVS sources" if $branch; +} @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; @@ -90,11 +99,12 @@ 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"; + my $dir="/var/lib/mock/$_".(!$arch?"":"-$arch"); $force or -d $dir or error "No distro: $dir"; } @@ -117,35 +127,44 @@ 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}; } } } -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; @@ -173,6 +192,12 @@ 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, @@ -182,7 +207,17 @@ my %dump=( "configure"=>$configure, ); 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 @@ -312,11 +347,11 @@ while (@distrouse || keys(%child)) { 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"; + spawn "cp -a $cvsbare $builddir/src; cd $builddir/src; cvs update $cvsbranch"; } else { - spawn "cd $builddir; cvs -q -z3 -d :pserver:anoncvs:\@sourceware.org:/cvs/src co $which"; + spawn "cd $builddir; cvs -q -z3 -d :pserver:anoncvs:\@sourceware.org:/cvs/src co $cvsbranch $which"; } - spawn "cd $builddir/src".q{; test -z "$(cvs update -A)"}; + spawn "cd $builddir/src; test -z \"\$(cvs update $cvsbranch)\""; $baretestsuite="$builddir/src"; } @@ -387,6 +422,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; } @@ -402,6 +448,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)=@_;