X-Git-Url: https://erislabs.net/gitweb/?a=blobdiff_plain;f=build-aux%2Fdo-release-commit-and-tag;h=0bd8ce8604bfbef8fbeb2fcf8b5949f4a84e49e9;hb=0012ebc176b72505d01b547c91aff5a4e5feef5e;hp=353c4601bdab2176f6c82a1302f972d7d601e10d;hpb=b2e2010c7c902235b5efb5bd3c6529f61b093aa4;p=gnulib.git diff --git a/build-aux/do-release-commit-and-tag b/build-aux/do-release-commit-and-tag index 353c4601b..0bd8ce860 100755 --- a/build-aux/do-release-commit-and-tag +++ b/build-aux/do-release-commit-and-tag @@ -3,11 +3,11 @@ # controlled .prev-version file, automate the procedure by which we record # the date, release-type and version string in the NEWS file. That commit # will serve to identify the release, so apply a signed tag to it as well. -VERSION=2009-11-06.10 # UTC +VERSION=2012-08-01.09 # UTC # Note: this is a bash script (could be zsh or dash) -# Copyright (C) 2009, 2010 Free Software Foundation, Inc. +# Copyright (C) 2009-2013 Free Software Foundation, Inc. # 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 @@ -24,30 +24,32 @@ VERSION=2009-11-06.10 # UTC # Written by Jim Meyering -ME=`basename "$0"` +ME=$(basename "$0") warn() { printf '%s: %s\n' "$ME" "$*" >&2; } die() { warn "$*"; exit 1; } -help_version() +help() { - case $1 in - --help) cat <. EOF - exit ;; + exit +} - --version) - year=`echo "$VERSION" | sed 's/[^0-9].*//'` - cat < This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. EOF - exit ;; + exit +} - *) die "unrecognized option: $1";; +## ------ ## +## Main. ## +## ------ ## + +# Constants. +noteworthy='* Noteworthy changes in release' +noteworthy_stub="$noteworthy ?.? (????-??-??) [?]" + +# Variables. +branch=$(git branch | sed -ne '/^\* /{s///;p;q;}') +builddir=. + +while test $# != 0 +do + # Handle --option=value by splitting apart and putting back on argv. + case $1 in + --*=*) + opt=$(echo "$1" | sed -e 's/=.*//') + val=$(echo "$1" | sed -e 's/[^=]*=//') + shift + set dummy "$opt" "$val" ${1+"$@"}; shift + ;; esac -} -case $# in - 1) help_version $1; exit 0;; - 2) ;; - *) warn "Usage: $ME VERSION TYPE"; exit 1;; -esac + case $1 in + --help|--version) ${1#--};; + --branch) shift; branch=$1; shift ;; + -C|--builddir) shift; builddir=$1; shift ;; + --*) die "unrecognized option: $1";; + *) break;; + esac +done + +test $# = 2 \ + || die "Usage: $ME [OPTION...] VERSION TYPE" ver=$1 type=$2 + +## ---------------------- ## +## First, sanity checks. ## +## ---------------------- ## + # Verify that $ver looks like a version number, and... echo "$ver"|grep -E '^[0-9][0-9.]*[0-9]$' > /dev/null \ || die "invalid version: $ver" @@ -91,7 +127,7 @@ prev_ver=$(cat .prev-version) \ # Verify that $ver is sensible (> .prev-version). case $(printf "$prev_ver\n$ver\n"|sort -V -u|tr '\n' ':') in "$prev_ver:$ver:") ;; - *) die "invalid version: $ver";; + *) die "invalid version: $ver (<= $prev_ver)";; esac case $type in @@ -99,32 +135,36 @@ case $type in *) die "invalid release type: $type";; esac -# Extract package name from Makefile. -pkg=$(sed -n 's/^PACKAGE = \(.*\)/\1/p' Makefile) \ - || die 'failed to determine package name from Makefile' - -# simple check: no question marks on line 3 of NEWS -noteworthy='* Noteworthy changes in release' -test "$(sed -n 3p NEWS)" = "$noteworthy ?.? (????-??-??) [?]" \ - || die 'line 3 of NEWS looks fishy!' - -# No dirt allowed. +# No local modifications allowed. case $(git diff-index --name-only HEAD) in '') ;; *) die 'this tree is dirty; commit your changes first';; esac -# update NEWS to have today's date, plus desired version number and $type +# Ensure the current branch name is correct: +curr_br=$(git rev-parse --symbolic-full-name HEAD) +test "$curr_br" = refs/heads/$branch || die not on branch $branch + +# Extract package name from Makefile. +Makefile=$builddir/Makefile +pkg=$(sed -n 's/^PACKAGE = \(.*\)/\1/p' "$Makefile") \ + || die "failed to determine package name from $Makefile" + +# Check that line 3 of NEWS is the stub line about to be replaced. +test "$(sed -n 3p NEWS)" = "$noteworthy_stub" \ + || die "line 3 of NEWS must be exactly '$noteworthy_stub'" + +## --------------- ## +## Then, changes. ## +## --------------- ## + +# Update NEWS to have today's date, plus desired version number and $type. perl -MPOSIX -ni -e 'my $today = strftime "%F", localtime time;' \ -e 'my ($type, $ver) = qw('"$type $ver"');' \ -e 'my $pfx = "'"$noteworthy"'";' \ -e 'print $.==3 ? "$pfx $ver ($today) [$type]\n" : $_' \ NEWS || die 'failed to update NEWS' -# Ensure the current branch name is "master": -curr_br=$(git rev-parse --symbolic-full-name HEAD) -test "$curr_br" = refs/heads/master || die not on master - printf "version $ver\n\n* NEWS: Record release date.\n" \ | git commit -F - -a || die 'git commit failed' git tag -s -m "$pkg $ver" v$ver HEAD || die 'git tag failed'