From owner-svn-src-user@FreeBSD.ORG Thu May 15 16:17:22 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2CA96F45; Thu, 15 May 2014 16:17:22 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 19E7627F7; Thu, 15 May 2014 16:17:22 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s4FGHLBn073658; Thu, 15 May 2014 16:17:21 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s4FGHL8x073655; Thu, 15 May 2014 16:17:21 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201405151617.s4FGHL8x073655@svn.freebsd.org> From: Dag-Erling Smørgrav Date: Thu, 15 May 2014 16:17:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r266153 - user/des/tinderbox X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 May 2014 16:17:22 -0000 Author: des Date: Thu May 15 16:17:21 2014 New Revision: 266153 URL: http://svnweb.freebsd.org/changeset/base/266153 Log: Add a revert command which runs svn revert and removes any leftovers. Clean up and simplify the svn checkout / update code. Modified: user/des/tinderbox/tbmaster.pl user/des/tinderbox/tinderbox.1 user/des/tinderbox/tinderbox.pl Modified: user/des/tinderbox/tbmaster.pl ============================================================================== --- user/des/tinderbox/tbmaster.pl Thu May 15 16:11:06 2014 (r266152) +++ user/des/tinderbox/tbmaster.pl Thu May 15 16:17:21 2014 (r266153) @@ -34,7 +34,7 @@ use POSIX; use Getopt::Long; use Storable qw(dclone); -my $VERSION = "2.21"; +my $VERSION = "2.22"; my $COPYRIGHT = "Copyright (c) 2003-2014 Dag-Erling Smørgrav. " . "All rights reserved."; Modified: user/des/tinderbox/tinderbox.1 ============================================================================== --- user/des/tinderbox/tinderbox.1 Thu May 15 16:11:06 2014 (r266152) +++ user/des/tinderbox/tinderbox.1 Thu May 15 16:17:21 2014 (r266153) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 24, 2014 +.Dd May 15, 2014 .Dt TINDERBOX 1 .Os .Sh NAME @@ -194,12 +194,11 @@ Delete the object tree at the start of e Delete the installation tree at the start of each job. .It Cm precleanroot Delete the release chroot tree at the start of each job. +.It Cm revert +Revert the source tree to a clean state. .It Cm update -Update the sources using +Update the source tree using .Xr svn 1 . -This is highly recommended, for obvious reasons, if the -.Cm clean -command is specified. .It Cm patch Apply the patch specified with the .Fl -patch @@ -207,6 +206,9 @@ option to the source tree. If the specified patch file does not exist, the .Cm patch command will fail gracefully. +.It Cm version +After updating and patching the source tree but before doing anything +else, log information about the current state of the source tree. .It Cm world Build the world. .It Cm lint @@ -270,9 +272,6 @@ but at the end of each job. As .Cm precleanroot , but at the end of each job. -.It Cm version -After updating and patching the source tree but before doing anything -else, log information about the current state of the source tree. .El .Pp The commands are executed in the order in which they are listed above, Modified: user/des/tinderbox/tinderbox.pl ============================================================================== --- user/des/tinderbox/tinderbox.pl Thu May 15 16:11:06 2014 (r266152) +++ user/des/tinderbox/tinderbox.pl Thu May 15 16:17:21 2014 (r266153) @@ -34,7 +34,7 @@ use POSIX; use Getopt::Long; use Scalar::Util qw(tainted); -my $VERSION = "2.21"; +my $VERSION = "2.22"; my $COPYRIGHT = "Copyright (c) 2003-2014 Dag-Erling Smørgrav. " . "All rights reserved."; @@ -65,6 +65,7 @@ my %cmds = ( 'cleanobj' => 0, 'precleanobj' => 0, 'postcleanobj' => 0, 'cleaninst' => 0, 'precleaninst' => 0, 'postcleaninst' => 0, 'cleanobj' => 0, 'precleanobj' => 0, 'postcleanobj' => 0, + 'revert' => 0, 'update' => 0, 'patch' => 0, 'world' => 0, @@ -615,45 +616,75 @@ MAIN:{ do_clean(); # no prefix for backward compatibility do_clean('pre'); - # Check out new source tree - if ($cmds{'update'}) { - if (defined($svnbase)) { - my @svnargs; - push(@svnargs, "--quiet") - unless ($verbose); - # ugly-bugly magic required because CVS to SVN conversion - # smashed branch names - $svnbase =~ s/\/$//; - if ($branch eq 'HEAD') { - $svnbase .= '/head'; - } elsif ($branch =~ m/^RELENG_(\d+)_(\d+)$/) { - $svnbase .= "/releng/$1.$2"; - } elsif ($branch =~ m/^RELENG_(\d+)$/) { - $svnbase .= "/stable/$1"; + # Locate svn + my $svncmd = '/usr/bin/false'; + if ($cmds{'revert'} || $cmds{'version'} || $cmds{'update'}) { + $svncmd = [grep({ -x } @svncmds)]->[0] + or error("unable to locate svn binary"); + } + + # Revert sources + if ($cmds{'revert'} && -d "$srcdir/.svn") { + my @svnargs; + push(@svnargs, "--quiet") + unless ($verbose); + logstage("reverting $srcdir"); + spawn($svncmd, @svnargs, "upgrade", $srcdir); + spawn($svncmd, @svnargs, "cleanup", $srcdir); + spawn($svncmd, @svnargs, "revert", "-R", $srcdir) + or error("unable to revert the source tree"); + # remove leftovers... ugly! + open(my $pipe, '-|', $svncmd, "stat", "--no-ignore", $srcdir) + or error("unable to stat source tree"); + while (<$pipe>) { + m/^[I?]\s+(\S.*)$/ or next; + if (-d $1) { + remove_dir($1) + or error("unable to remove $1"); + } elsif (-f $1 || -l $1) { + unlink($1) + or error("unable to remove $1"); } else { - error("unrecognized branch: $branch"); + warning("ignoring $1"); } - logstage("checking out $srcdir from $svnbase"); - my $svncmd = [grep({ -x } @svncmds)]->[0] - or error("unable to locate svn binary"); - cd("$sandbox"); + } + close($pipe); + } + + # Check out new source tree + if ($cmds{'update'}) { + error("no svn base URL defined") + unless defined($svnbase); + my @svnargs; + push(@svnargs, "--quiet") + unless ($verbose); + # ugly-bugly magic required because CVS to SVN conversion + # smashed branch names + $svnbase =~ s/\/$//; + if ($branch eq 'HEAD') { + $svnbase .= '/head'; + } elsif ($branch =~ m/^RELENG_(\d+)_(\d+)$/) { + $svnbase .= "/releng/$1.$2"; + } elsif ($branch =~ m/^RELENG_(\d+)$/) { + $svnbase .= "/stable/$1"; + } else { + error("unrecognized branch: $branch"); + } + logstage("checking out $srcdir from $svnbase"); + cd("$sandbox"); + for (0..$svnattempts) { if (-d "$srcdir/.svn") { spawn($svncmd, "upgrade", $srcdir); spawn($svncmd, "cleanup", $srcdir); - push(@svnargs, "update", $srcdir); + last if spawn($svncmd, @svnargs, "update", $srcdir); } else { - push(@svnargs, "checkout", $svnbase, $srcdir); - } - for (0..$svnattempts) { - last if spawn($svncmd, @svnargs); - error("unable to check out the source tree") - if ($_ == $svnattempts); - my $delay = 30 * ($_ + 1); - warning("sleeping $delay s and retrying..."); - sleep($delay); + last if spawn($svncmd, @svnargs, "checkout", $svnbase, $srcdir); } - } else { - error("no svn base URL defined"); + error("unable to check out the source tree") + if ($_ == $svnattempts); + my $delay = 30 * ($_ + 1); + warning("sleeping $delay s and retrying..."); + sleep($delay); } } @@ -682,8 +713,6 @@ MAIN:{ # Print source tree version information if ($cmds{'version'}) { if (defined($svnbase)) { - my $svncmd = [grep({ -x } @svncmds)]->[0] - or error("unable to locate svn binary"); my $svnversioncmd = [grep({ -x } @svnversioncmds)]->[0] or error("unable to locate svnversion binary"); if ($verbose) {