OpenPKG CVS Repository http://cvs.openpkg.org/ ____________________________________________________________________________
Server: cvs.openpkg.org Name: Thomas Lotterer Root: /e/openpkg/cvs Email: [EMAIL PROTECTED] Module: openpkg-tools Date: 31-Jan-2005 15:19:20 Branch: HEAD Handle: 2005013114192000 Modified files: openpkg-tools/cmd bf-db.pl bf-mk.pl Log: add amendment feature Summary: Revision Changes Path 1.5 +25 -5 openpkg-tools/cmd/bf-db.pl 1.7 +24 -1 openpkg-tools/cmd/bf-mk.pl ____________________________________________________________________________ patch -p0 <<'@@ .' Index: openpkg-tools/cmd/bf-db.pl ============================================================================ $ cvs diff -u -r1.4 -r1.5 bf-db.pl --- openpkg-tools/cmd/bf-db.pl 26 Jan 2005 14:42:24 -0000 1.4 +++ openpkg-tools/cmd/bf-db.pl 31 Jan 2005 14:19:20 -0000 1.5 @@ -74,7 +74,8 @@ " -C|config=s specifiy config file ($opt_config)\n" . "Available commands:\n" . " begin log beginning of build for instance and package\n" . - " end log end and color of build for instance and package\n"; + " end log end and color of build for instance and package\n" . + " amend log end and color only if entry currently missing\n"; exit(1) if (defined $level); exit(0); } @@ -103,7 +104,8 @@ my $dbh = &dbinit($dbfile); if ( $ARGV[0] =~ m|^init$| ) { } elsif ( $ARGV[0] =~ m|^begin$| ) { &status_begin($opt_inst, $opt_package); } -elsif ( $ARGV[0] =~ m|^end$| ) { &status_end ($opt_inst, $opt_package, $opt_color); } +elsif ( $ARGV[0] =~ m|^end$| ) { &status_end ($opt_inst, $opt_package, $opt_color, 0); } +elsif ( $ARGV[0] =~ m|^amend$| ) { &status_end ($opt_inst, $opt_package, $opt_color, 1); } else { &usage(); } $dbh->disconnect(); undef $dbh; @@ -206,13 +208,13 @@ } } -sub status_end ($$$) +sub status_end ($$$$) { - my ($inst, $package, $color) = @_; + my ($inst, $package, $color, $amend) = @_; my ($host, $arch, $os, $tag) = &splitinst($inst); my ($name, $version, $release) = &splitpackage($package); my ($sth, $rv, $retries); - printf STDERR "DEBUG:$0: status_end(%s, %s, %s) host=%s, arch=%s, os=%s, tag=%s, name=%s, version=%s, release=%s;\n", $inst, $package, $color, $host, $arch, $os, $tag, $name, $version, $release if ($opt_verbose); + printf STDERR "DEBUG:$0: status_end(%s, %s, %s, %d) host=%s, arch=%s, os=%s, tag=%s, name=%s, version=%s, release=%s;\n", $inst, $package, $color, $amend, $host, $arch, $os, $tag, $name, $version, $release if ($opt_verbose); # special case to handle UPDATE from nonexisting row # this can happen if the database was erased between build begin and build end @@ -249,6 +251,12 @@ exit(2); } } + else { + if ($amend) { + printf STDERR "amendment for inst=%s, package=%s skipped\n", $inst, $package; + return; + } + } } if (defined $color) { @@ -269,6 +277,10 @@ print STDERR "ERROR:$0: SQLite error: ".$dbh->errstr."\n"; exit(2); } + if ($amend) { + printf STDERR "amendment for inst=%s, package=%s completed, set color=%s\n", $inst, $package, $color; + return; + } } else { $sth = $dbh->prepare( @@ -444,6 +456,14 @@ -p|package=s package (<name>-<version>-<release>) -c|color=s color (red|green) + amend + + works like end but existing records will not be modified. Missing + records will be created. This allows amendment of information that + has never hit the database or recovery past a database deletion by + scanning for existing binary packages in DST. This is automated + using the "slave -A" worker command. + common options [-C|config=s] specifiy config file @@ . patch -p0 <<'@@ .' Index: openpkg-tools/cmd/bf-mk.pl ============================================================================ $ cvs diff -u -r1.6 -r1.7 bf-mk.pl --- openpkg-tools/cmd/bf-mk.pl 31 Jan 2005 14:11:35 -0000 1.6 +++ openpkg-tools/cmd/bf-mk.pl 31 Jan 2005 14:19:20 -0000 1.7 @@ -453,7 +453,7 @@ exit 1 } -oneshot () +createslavestructure () { # creating SHARED directory structure for SLAVE %{driver.shtool} echo -e "%B++ [EMAIL PROTECTED]:%{shared.prefix}: creating SHARED directory structure for SLAVE%b" @@ -461,6 +461,11 @@ target="%{shared.prefix}/$dir/$HOST-$ARCH-$OS" %{driver.shtool} mkdir -f -p -m 775 $target || die "cannot create directory \"$target\"" done +} + +oneshot () +{ + createslavestructure # prepare SRPMs for SLAVE %{driver.shtool} echo -e "%B++ [EMAIL PROTECTED]:%{shared.prefix}: prepare SRPMs for SLAVE%b" @@ -523,6 +528,20 @@ ) } +amend () +{ + createslavestructure + + # amend DST packages for SLAVE + %{driver.shtool} echo -e "%B++ [EMAIL PROTECTED]:%{shared.prefix}: amend DST packages for SLAVE%b" + amendthis="%{shared.prefix}/dst/$HOST-$ARCH-$OS" + for item in `cd $amendthis && ls 2>/dev/null -1 *-*-*.*-*-*.rpm \ + | sed -e 's;^\(.*-[^-][^-]*-[^-][^-]*\)\.[^-][^-]*-[^-][^-]*-[^-][^-]*\.rpm$;\1;' \ + | sort`; do #aide-0.10-20040920.ix86-freebsd4.10-openpkg.rpm => aide-0.10-20040920 + %{slaves.bfdb} -i $HOST-$ARCH-$OS-$TAG -p $item -c green amend + done +} + wipe () { # wipe out SHARED areas belonging to SLAVE @@ -543,6 +562,7 @@ echo " -1|oneshot run slave once" echo " -l|loop run slave in a loop" echo " -H|help print out this usage page" + echo " -A|amend amend slave packages" echo "Notes on slave mode" echo " with -[1l] the application executes the SLAVE role" echo "To reconfigure settings, change bf.conf on the MASTER" @@ -566,17 +586,20 @@ HOST=`%{driver.hostname} | %{driver.sed} -e 's;\..*$;;'` ARCH=`%{slaves.rpm} --eval '%{l_host_arch}'` OS=`%{slaves.rpm} --eval '%{l_host_os}'` +TAG=`%{slaves.rpm} --eval '%{l_tag}'` if [ ".$TERM" = .screen ]; then %{driver.shtool} echo -n "k$HOST-$ARCH-$OS\\"; fi cmd="" if [ ".$1" = ".-1" -o ".$1" = ".--oneshot" ]; then cmd="oneshot"; fi if [ ".$1" = ".-l" -o ".$1" = ".--loop" ]; then cmd="loop"; fi +if [ ".$1" = ".-A" -o ".$1" = ".--amend" ]; then cmd="amend"; fi if [ ".$1" = ".-H" -o ".$1" = ".--help" ]; then cmd="help"; fi if [ ".$cmd" = . ]; then usage "ERROR"; fi if [ ".$cmd" = .help ]; then usage; fi if [ ".$cmd" = .oneshot ]; then oneshot; fi if [ ".$cmd" = .loop ]; then loop; fi +if [ ".$cmd" = .amend ]; then amend; fi exit 1 EOT @@ . ______________________________________________________________________ The OpenPKG Project www.openpkg.org CVS Repository Commit List openpkg-cvs@openpkg.org