From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [OSSTEST PATCH 25/33] New utility mg-adjust-flight-makexrefs Date: Fri, 18 Sep 2015 10:47:58 +0100 Message-ID: <1442569678.18856.280.camel@citrix.com> References: <1442511480-32587-1-git-send-email-ian.jackson@eu.citrix.com> <1442511480-32587-26-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZcsGx-0001wg-Gs for xen-devel@lists.xenproject.org; Fri, 18 Sep 2015 09:48:03 +0000 In-Reply-To: <1442511480-32587-26-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson , xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org On Thu, 2015-09-17 at 18:37 +0100, Ian Jackson wrote: > This provides a fairly cooked way of adjusting an existing flight to > reuse previous builds. > > Signed-off-by: Ian Jackson How exciting. Acked-by: Ian Campbell > --- > v2: New patch > --- > mg-adjust-flight-makexrefs | 83 > ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 83 insertions(+) > create mode 100755 mg-adjust-flight-makexrefs > > diff --git a/mg-adjust-flight-makexrefs b/mg-adjust-flight-makexrefs > new file mode 100755 > index 0000000..ebbac15 > --- /dev/null > +++ b/mg-adjust-flight-makexrefs > @@ -0,0 +1,83 @@ > +#!/bin/bash > +# > +# usage: ./mg-adjust-flight-makexrefs [OPTIONS..] FLIGHT \ > +# '[!]JOB-GLOB ...' \ > +# REF-CONDS... > +# > +# JOB-GLOB is as for shell `case'. Sense of first match is used. > +# If no match for a job, uses reverse of sense of last glob. > +# > +# ! means keep such jobs in FLIGHT. Without ! means delete each such > +# job from FLIGHT and replace intra-flight references to it with > +# references to the same job in a suitable other flight. > +# > +# `Suitable' means one in which the required job passed, subject to > +# REF-CONDS (which are passed to sg-check-tested). REF-CONDS really > +# ought to include --blessings=BLESSING,... and should probably also > +# include some --branch=REF-BRANCH. > +# > +# Options: > +# -v Pass -v to cs-adjust-flight > +# -D Print our own debugging output to stderr (consider > +# passing --debug in REF-CONDS too) > +# -n Dry run: do not actually run cs-adjust-flight > + > +set -e > + > +exec 3>/dev/null > +verbose='' > + > +badusage () { echo >&2 "$0: bad usage"; exit 1; } > + > +while true; do > + case "$1" in > + -n) dryrun="echo" ;; > + -v) verbose=-v ;; > + -D) exec 3>&2 ;; > + -*) badusage ;; > + *) break ;; > + esac > + shift > +done > + > +if [ $# -le 2 ]; then badusage; fi > + > +flight=$1; shift > +keepjobs=$1; shift > + > +for j in `./cs-adjust-flight $flight jobs-list '^build-'`; do > + > + tokeep=continue > + todelete=: > + > + for glob in $keepjobs; do > + case "$glob" in > + !*) ifmatch=$tokeep; action=$todelete ; glob="${glob#!}" > ;; > + *) ifmatch=$todelete; action=$tokeep ;; > + esac > + > + case "$j" in > + $glob) > + action=$ifmatch > + echo >&3 "ADJUST XREF $j match=$glob $action" > + break > + ;; > + esac > + done > + > + # `doaction=continue' => job remains > + # `doaction=:' => job gets deleted > + echo >&3 "ADJUST XREF $j ACTION $action" > + $action > + > + # OK, process $j > + > + ref=`./sg-check-tested --pass-job="$j" "$@"` > + echo >&3 "ADJUST XREF $j r=$ref" > + if [ "x$ref" = x ]; then continue; fi > + > + $dryrun \ > + ./cs-adjust-flight $verbose $flight \ > + runvar-change . '/buildjob$' "$j" "$ref.$j" \ > + jobs-del "$j" > +done