From 28466652234d484985dfabdfe48383f81cda5bdf Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Fri, 16 Mar 2012 17:57:26 +0000 Subject: [PATCH] Merge in sprint branch management commands from old trunk - Legacy-Id: 4138 --- test/mergedevbranch | 143 ++++++++++++++++++++++++++++ test/mkdevbranch | 93 ++++++++++++++++++ test/sprint76.txt | 11 +++ test/sprint77.txt | 16 ++++ test/sprint78.txt | 14 +++ test/sprint79.txt | 11 +++ test/sprint80.txt | 14 +++ test/sprint81.txt | 15 +++ test/sprint82.txt | 8 ++ test/update | 225 ++++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 550 insertions(+) create mode 100755 test/mergedevbranch create mode 100755 test/mkdevbranch create mode 100644 test/sprint76.txt create mode 100644 test/sprint77.txt create mode 100644 test/sprint78.txt create mode 100644 test/sprint79.txt create mode 100644 test/sprint80.txt create mode 100644 test/sprint81.txt create mode 100644 test/sprint82.txt create mode 100755 test/update diff --git a/test/mergedevbranch b/test/mergedevbranch new file mode 100755 index 000000000..ad307b151 --- /dev/null +++ b/test/mergedevbranch @@ -0,0 +1,143 @@ +#!/bin/bash + +version=0.20 +program=${0##*/} +progdir=${0%/*} +if [ "$progdir" = "$program" ]; then progdir="."; fi + +# ---------------------------------------------------------------------- +function usage() { + cat < + +COPYRIGHT + Copyright 2010 Henrik Levkowetz. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or (at + your option) any later version. There is NO WARRANTY; not even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more details. + +EOF + +} + +# ---------------------------------------------------------------------- +function die() { + echo -e "\n$program: error: $*" > /dev/stderr + exit 1 +} + +function note() { + if [ -n "$VERBOSE" ]; then echo -e "$*"; fi +} + +# ---------------------------------------------------------------------- +function version() { + echo -e "$program $version" +} + +# ---------------------------------------------------------------------- +trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)"; exit 1' ERR + + +# ---------------------------------------------------------------------- +# Option parsing + +# Options +shortopts=chvV +longopts=commit,help,verbose,version + +# Default values + +if [ "$(uname)" = "Linux" ]; then + args=$(getopt -o "$shortopts" --long "$longopts" -n '$program' -- $SV "$@") + if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi + eval set -- "$args" + sed="sed -r" +else + # Darwin, BSDs + args=$(getopt -o$shortopts $SV $*) + if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi + set -- $args + sed="sed -E" +fi + +while true ; do + case "$1" in + -c| --commit) ARG_COMMIT=1;; # Run commit in addition to merge + -h| --help) usage; exit;; # Show this help, then exit + -v| --verbose) VERBOSE=1;; # Be more talkative + -V| --version) version; exit;; # Show program version, then exit + --) shift; break;; + *) die "Internal error, inconsistent option specification: '$1'";; + esac + shift +done + +# ---------------------------------------------------------------------- +# The program itself + +[[ $1 =~ @ ]] && set ${1/@/ } +[ $# -ge 2 ] || die "Expected branch and repository revision on the command line" +[ ${PWD##*/} = trunk ] || die "Expected this script to be run in trunk" +branch=$1 +rev=$2 +fix=$3 + +note "Extract who and what:" +info=$(svn log http://svn.tools.ietf.org/svn/tools/ietfdb/ -r $rev --incremental) +set $(echo "$info" | tail -n +2 | head -n 1 | tr "|" "\t") +who=$2; echo -e "\n$who" +comment=$(echo "$info" | tail -n +3); echo -e "$comment\n" + +note "Do the merge:" +svn merge -c $rev http://svn.tools.ietf.org/svn/tools/ietfdb/personal/$branch . + +mail -s "Merged datatracker branch personal/$branch@$rev to trunk" $who -c henrik@levkowetz.com <<-EOF +Hi, + +This is an automatic merge info message. Your code in personal/$branch@$rev +has been merged to trunk, and will be part of the next release if nothing +goes wrong during final testing. + +Regards, + + Henrik + (via the mergesprintbranch script) +EOF + +if [ "$ARG_COMMIT" ]; then + echo "Committing the merge:" + echo "" + svn commit -m "Merged [$rev] from $who: $comment $fix" +else + echo "This merge has not been committed yet." + echo "To commit it, run this commit command:" + echo "" + echo "svn commit -m \"Merged [$rev] from $who: $comment $fix\"" +fi + diff --git a/test/mkdevbranch b/test/mkdevbranch new file mode 100755 index 000000000..67ef4ad29 --- /dev/null +++ b/test/mkdevbranch @@ -0,0 +1,93 @@ +#!/bin/bash + +version=0.21 +program=${0##*/} +progdir=${0%/*} +if [ "$progdir" = "$program" ]; then progdir="."; fi + +function die() { + echo -e "\n$program: Error: ${1:0:160} ..." >&2 + exit 1 +} + +function warn() { + logger -i -p user.warn -t $program "$*" + echo "$program: Warning: $*" 1>&2; +} + +function note() { + logger -i -p user.notice -t $program "$*" + if [ -n "$OPT_VERBOSE" ]; then echo -e "$*"; fi +} + +function version() { + echo -e "$program: v$version\n\nRunning as $(id -urn) on $(date +'%Y-%m-%d %H:%M')" +} + +#[ "$#" -gt 0 ] || die "Expected the ietf number as argument on the command line, but found nothing" +#[ $1 -gt 70 ] || die "Expected the ietf number as argument on the command line, but found '$1'" + +#if [ "$1" ]; then arg=$1; else arg=$(svn info http://svn.tools.ietf.org/svn/tools/ietfdb/trunk/ | egrep "^Last Changed Rev" | awk '{print $4}'); fi +if [ "$1" ]; then arg=$1; else arg=$(svn ls http://svn.tools.ietf.org/svn/tools/ietfdb/tags/ | tail -n 1 | sed -r 's/^(.*)\/$/v\1/' ); fi + +if [ "${arg:0:1}" = "v" ]; then + source="tags/${arg:1}" + target="$arg" + rev="release $arg" +else + source="trunk@$arg" + target="r$arg" + rev="repository rev r$arg" +fi + +function mksvndir() { + who=$1 + if [ "$2" ]; then dir=$2; else dir=$who; fi + if ! svn info http://svn.tools.ietf.org/svn/tools/ietfdb/personal/$dir >/dev/null 2>&1 ; then + echo "Creating personal directory area for IETF datatracker coding: /personal/$dir" + svn mkdir http://svn.tools.ietf.org/svn/tools/ietfdb/personal/$dir -m "Personal SVN dir for $who, for IETF datatracker code" + else + echo "Repository area personal/$dir is already in place." + fi +} + +num=$( < /www/tools.ietf.org/meta/current-ietf-number.txt) +trac-admin /www/tools.ietf.org/tools/ietfdb wiki export IETF${num}SprintSignUp \ + | egrep "^\|\|" | tail -n +2 | python -c ' +import sys, re +for line in sys.stdin: + blank, name, email, rest = line.strip().split("||", 3) + login, dummy = re.split("[@.]", email, 1) + print "\t".join((login.strip().lower(), email.strip().lower(), name.strip())) ' \ + | $progdir/update $progdir/sprint$num.txt + +cat $(ls $progdir/sprint*.txt | tail -n 4) | sed 's/[ \t]*$//' | sort | uniq | while read login email name; do + echo "" + echo "$login ($name <$email>):" + mksvndir $login + if ! svn info http://svn.tools.ietf.org/svn/tools/ietfdb/personal/$login/$target >/dev/null 2>&1 ; then + echo " creating $target branch for $login ($name)." + svn cp http://svn.tools.ietf.org/svn/tools/ietfdb/$source http://svn.tools.ietf.org/svn/tools/ietfdb/personal/$login/$target/ -m "New IETF datatracker coding branch for $name" \ + && mail "$name <$email>" -s "A new SVN branch for you for IETF datatracker coding${rev:+, based on $rev}." -b henrik@levkowetz.com <<-EOF + Hi, + + This mail has been automatically generated by the $program script. + + A new SVN branch has been set up for you for IETF datatracker coding, at + http://svn.tools.ietf.org/svn/tools/ietfdb/personal/$login/$target + ${rev:+This branch is based on $rev. }You can check it out by doing + svn co http://svn.tools.ietf.org/svn/tools/ietfdb/personal/$login/$target + + (More instructions about setup is available at + http://trac.tools.ietf.org/tools/ietfdb/wiki/SprintCoderSetup) + + + Best, + + Henrik (via the $program script) + + EOF + else + echo " branch personal/$login/$target already exists." + fi +done diff --git a/test/sprint76.txt b/test/sprint76.txt new file mode 100644 index 000000000..6f375df1c --- /dev/null +++ b/test/sprint76.txt @@ -0,0 +1,11 @@ +henrik henrik@levkowetz.com Henrik Levkowetz +chris chris.newman@sun.com Chris Newman +pasi pasi.eronen@nokia.com Pasi Eronen +rjs rjs@nostrum.com Robert Sparks +tony tony@att.com Tony Hansen +ben ben@nostrum.com Ben Campbell +kivinen kivinen@iki.fi Tero Kivinen +adam adam@nostrum.com Adam Roach +arifumi arifumi@nttv6.net Arifumi Matsumoto +edj edj.etc@gmail.com Ed Juskevicius +lars lars.eggert@gmail.com Lars Eggert diff --git a/test/sprint77.txt b/test/sprint77.txt new file mode 100644 index 000000000..8ee11df3f --- /dev/null +++ b/test/sprint77.txt @@ -0,0 +1,16 @@ +henrik henrik@levkowetz.com Henrik Levkowetz +rjs rjs@nostrum.com Robert Sparks +adam adam@nostrum.com Adam Roach +pasi pasi.eronen@nokia.com Pasi Eronen +kivinen kivinen@iki.fi Tero Kivinen +housley housley@vigilsec.com Russ Housley +tony tony@att.com Tony Hansen +lars lars.eggert@gmail.com Lars Eggert +richard richard.barnes@gmail.com Richard Barnes +cabo cabo@tzi.org Carsten Bormann +ben ben@nostrum.com Ben Campbell +fenner fenner@fenron.net Bill Fenner +suresh suresh.krishnan@ericsson.com Suresh Krishnan +matthijs matthijs@nlnetlabs.nl Matthijs Mekking +edj edj.etc@gmail.com Ed Juskevicius +george george.bullis@jdsu.com George Bullis diff --git a/test/sprint78.txt b/test/sprint78.txt new file mode 100644 index 000000000..7245b505c --- /dev/null +++ b/test/sprint78.txt @@ -0,0 +1,14 @@ +henrik henrik@levkowetz.com Henrik Levkowetz +rjs rjs@nostrum.com Robert Sparks +housley housley@vigilsec.com Russ Housley +tony tony@att.com Tony Hansen +lars lars.eggert@gmail.com Lars Eggert +kivinen kivinen@iki.fi Tero Kivinen +peter peter.musgrave@magorcorp.com Peter Musgrave +matthijs matthijs@nlnetlabs.nl Matthijs Mekking +jelte jelte@isc.org Jelte Jansen +yuri yuri@nlnetlabs.nl Yuri Schaeffer +adam adam@nostrum.com Adam Roach +paul paul.hoffman@vpnc.org Paul Hoffman +rcross rcross@amsl.com Ryan Cross +warren warren@kumari.net Warren Kumari diff --git a/test/sprint79.txt b/test/sprint79.txt new file mode 100644 index 000000000..dce4a1cfa --- /dev/null +++ b/test/sprint79.txt @@ -0,0 +1,11 @@ +henrik henrik@levkowetz.com Henrik Levkowetz +rjs rjs@nostrum.com Robert Sparks +housley housley@vigilsec.com Russ Housley +tony tony@att.com Tony Hansen +peter peter.musgrave@magorcorp.com Peter Musgrave +warren warren@kumari.net Warren Kumari +suresh suresh.krishnan@ericsson.com Suresh Krishnan +kivinen kivinen@iki.fi Tero Kivinen +lars lars.eggert@gmail.com Lars Eggert +fenner fenner@fenron.net Bill Fenner +adam adam@nostrum.com Adam Roach diff --git a/test/sprint80.txt b/test/sprint80.txt new file mode 100644 index 000000000..40db0af89 --- /dev/null +++ b/test/sprint80.txt @@ -0,0 +1,14 @@ +henrik henrik@levkowetz.com Henrik Levkowetz +rjs rjs@nostrum.com Robert Sparks +housley housley@vigilsec.com Russ Housley +tony tony@att.com Tony Hansen +rcross rcross@amsl.com Ryan Cross +shane shane@time-travellers.org Shane Kerr +kivinen kivinen@iki.fi Tero Kivinen +adam adam@nostrum.com Adam Roach +peter peter.musgrave@magorcorp.com Peter Musgrave +julian julian.reschke@greenbytes.de Julian Reschke +warren warren@kumari.net Warren Kumari +jelte jelte@isc.org Jelte Jansen +bmheight bmheight@gmail.com Brandon Height +lars lars.eggert@gmail.com Lars Eggert diff --git a/test/sprint81.txt b/test/sprint81.txt new file mode 100644 index 000000000..c420d229d --- /dev/null +++ b/test/sprint81.txt @@ -0,0 +1,15 @@ +henrik henrik@levkowetz.com Henrik Levkowetz +rjs rjs@nostrum.com Robert Sparks +housley housley@vigilsec.com Russ Housley +lars lars.eggert@gmail.com Lars Eggert +adam adam@nostrum.com Adam Roach +kivinen kivinen@iki.fi Tero Kivinen +suresh suresh.krishnan@ericsson.com Suresh Krishnan +wes wes@mti-systems.com Wes Eddy +dow dow.street@linquest.com Dow Street +ondrej ondrej@sury.org Ondřej Surý +tony tony@att.com Tony Hansen +rcross rcross@amsl.com Ryan Cross +julian julian.reschke@greenbytes.de Julian Reschke +elwynd elwynd@folly.org.uk Elwyn Davies +presnick presnick@qualcomm.com Pete Resnick diff --git a/test/sprint82.txt b/test/sprint82.txt new file mode 100644 index 000000000..20c42c3e7 --- /dev/null +++ b/test/sprint82.txt @@ -0,0 +1,8 @@ +henrik henrik@levkowetz.com Henrik Levkowetz +rjs rjs@nostrum.com Robert Sparks +housley housley@vigilsec.com Russ Housley +adam adam@nostrum.com Adam Roach +lars lars.eggert@gmail.com Lars Eggert +kivinen kivinen@iki.fi Tero Kivinen +tony tony@att.com Tony Hansen +mahoney mahoney@nostrum.com Jean Mahoney diff --git a/test/update b/test/update new file mode 100755 index 000000000..42142c403 --- /dev/null +++ b/test/update @@ -0,0 +1,225 @@ +#!/bin/bash + +version="0.34" +program=$(basename $0) + +NEW="" # If there are more than $NEW % new lines, skip update +OLD="" # If there are more than $OLD % deleted lines, skip update +FILE="" +verbose="" +silent="" + +# ---------------------------------------------------------------------- +function usage() { +cat < +EOF +exit +} + + +# ---------------------------------------------------------------------- +function note() { + if [ -n "$verbose" ]; then + echo -e "$program: $*" + fi +} + +# ---------------------------------------------------------------------- +function warn() { + [ "$QUIET" ] || echo -e "$program: $*" +} + +# ---------------------------------------------------------------------- +function err() { + echo -e "$program: $*" > /dev/stderr +} + +# ----------------------------------------------------------------------------- +function leave() { + errcode=$1; shift + if [ "$errcode" -ge "2" ]; then warn "$*"; else note "$*"; fi + if [ -f "$tempfile" ]; then rm $tempfile; fi + if [ -f "$difffile" ]; then rm $difffile; fi + if [ "$errcode" = "1" -a "$RESULT" = "0" ]; then exit 0; else exit $errcode; fi +} + +# ---------------------------------------------------------------------- +# Set up error trap +trap 'leave 127 "$program($LINENO): Command failed with error code $? while processing '$origfile'."' ERR + +# exit with a message if a command fails +set -e + +# ---------------------------------------------------------------------- +# Get any options +# + +# Default values +PAT="\$path\$base.%Y-%m-%d_%H%M" +RESULT="0" +QUIET="" + +# Based on the sample code in /usr/share/doc/util-linux/examples/parse.bash.gz +GETOPT_RESULT=$(getopt -o bc:ef:hn:o:p:qrvV --long backup,maxchg:,empty,file:,help,maxnew:,maxold:,prefix:,report,quiet,verbose,version -n "$program" -- "$@") + +if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi + +note "GETOPT_RESULT: $GETOPT_RESULT" +eval set -- "$GETOPT_RESULT" + +while true ; do + case "$1" in + -b|--backup) backup=1; shift ;; # Back up earlier versions by creating a backup file + -c|--maxchg) CHG="$2"; shift 2 ;; # Limit on percentage of changed lines + -e|--empty) empty=1; shift ;; # Permit the update to be empty (default: discard) + -f|--file) FILE="$2"; shift 2 ;; # Read input from FILE instead of standard input + -h|--help) usage; shift ;; # Show this text and exit + -n|--maxnew) NEW="$2"; shift 2 ;; # Limit on percentage of new (added) lines + -o|--maxold) OLD="$2"; shift 2 ;; # Limit on percentage of old (deleted) lines + -p|--pat*) PAT="$2"; shift 2 ;; # Backup name base ('$path$base.%Y%m%d_%H%M') + -q|--quiet) QUIET=1; shift;; # Be less verbose + -r|--result) RESULT=1; shift ;; # Return 1 if update not done + -v|--verbose) verbose=1; shift ;; # Be more verbose about what's happening + -V|--version) echo -e "$program\t$version"; exit;; # Show version and exit + --) shift ; break ;; + *) echo "$program: Internal error, inconsistent option specification." ; exit 1 ;; + esac +done + +if [ $CHG ]; then OLD=$CHG; NEW=$CHG; fi + +if [ $# -lt 1 ]; then echo -e "$program: Missing output filename\n"; usage; fi + +origfile=$1 +tempfile=$(tempfile) +difffile=$(tempfile) + +if [ -e "$origfile" ]; then + cp -p $origfile $tempfile # For ownership and permissions + cat $FILE > $tempfile + [ "$FILE" ] && touch -r $FILE $tempfile + # This won't work if we don't have sufficient privileges: + #chown --reference=$origfile $tempfile + #chmod --reference=$origfile $tempfile +else + cat $FILE > $origfile + [ "$FILE" ] && touch -r $FILE $tempfile + leave 0 "Created file '$origfile'" +fi + +origlen=$(wc -c < $origfile) +newlen=$(wc -c < $tempfile) + +if [ $origlen = 0 -a $newlen = 0 ]; then + rm $tempfile + leave 1 "New content is identical (and void) - not updating '$origfile'." +fi +if [ $newlen = 0 -a -z "$empty" ]; then + leave 1 "New content is void - not updating '$origfile'." +fi + +diff $origfile $tempfile > $difffile || [ $? -le 1 ] && true # suppress the '1' error code on differences +difflen=$(wc -l < $difffile) +if [ $difflen = 0 ]; then + leave 1 "New content is identical - not updating '$origfile'." +fi + +if [ "$OLD" -o "$NEW" ]; then + + if [ "$NEW" ]; then maxnew=$(( $origlen * $NEW / 100 )); fi + if [ "$OLD" ]; then maxdel=$(( $origlen * $OLD / 100 )); fi + + newcount=$(grep "^> " $difffile | wc -c) + outcount=$(grep "^< " $difffile | wc -c) + delcount=$(grep "^! " $difffile | wc -c) + delcount=$(( $outcount + $delcount )) + rm $difffile + + if [ "$OLD" ]; then + if [ "$delcount" -ge "$maxdel" ]; then + cp $tempfile $origfile.update + leave 2 "New content has too many removed lines ($delcount/$origlen)\n - not updating '$origfile'.\nNew content placed in '$origfile.update' instead" + fi + fi + if [ "$NEW" ]; then + if [ "$newcount" -ge "$maxnew" ]; then + cp $tempfile $origfile.update + leave 2 "New content has too many added lines ($newcount/$origlen)\n - not updating '$origfile'.\nNew content placed in '$origfile.update' instead" + fi + fi +fi + +if [ "$backup" ]; then + + path=${origfile%/*} + name=${origfile##*/} + base=${name%.*} + ext=${origfile##*.} + + if [ "$ext" = "$origfile" ]; then + ext="" + elif [ ! "${ext%/*}" = "$ext" ]; then + ext="" + else + ext=".$ext" + fi + + if [ "$path" = "$origfile" ]; then + path="" + else + path="$path/" + fi + + ver=1 + backfile=$(eval date +"$PAT") + backpath="${backfile%/*}" + if [ "$backpath" = "$backfile" ]; then + backpath="." + fi + if [ ! -d $backpath ]; then + if [ -e $backpath ]; then + leave 3 "The backup path '$backpath' exists but isn't a directory" + else + mkdir -p $backpath + fi + fi + while [ -e "$backfile,$ver$ext" ]; do + ver=$(( $ver+1 )) + done + note "Saving backup: $backfile,$ver$ext" + cp -p "$origfile" "$backfile,$ver$ext" + chmod -w "$backfile,$ver$ext" || true +fi + +if ! mv $tempfile $origfile; then cp -p $tempfile $origfile; fi +leave 0 "Updated file '$origfile'"