~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to build-aux/do-release-commit-and-tag

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
# controlled .prev-version file, automate the procedure by which we record
4
4
# the date, release-type and version string in the NEWS file.  That commit
5
5
# will serve to identify the release, so apply a signed tag to it as well.
6
 
VERSION=2011-05-04.11 # UTC
 
6
VERSION=2012-08-01.09 # UTC
7
7
 
8
8
# Note: this is a bash script (could be zsh or dash)
9
9
 
10
 
# Copyright (C) 2009-2011 Free Software Foundation, Inc.
 
10
# Copyright (C) 2009-2012 Free Software Foundation, Inc.
11
11
 
12
12
# This program is free software: you can redistribute it and/or modify
13
13
# it under the terms of the GNU General Public License as published by
24
24
 
25
25
# Written by Jim Meyering
26
26
 
27
 
ME=`basename "$0"`
 
27
ME=$(basename "$0")
28
28
warn() { printf '%s: %s\n' "$ME" "$*" >&2; }
29
29
die() { warn "$*"; exit 1; }
30
30
 
31
 
help_version()
 
31
help()
32
32
{
33
 
  case $1 in
34
 
    --help) cat <<EOF
 
33
  cat <<EOF
35
34
Usage: $ME [OPTION...] VERSION RELEASE_TYPE
36
35
 
37
 
Run this script to perform the final pre-release NEWS update
38
 
in which the date, release-type and version string are recorded.
39
 
Commit that result with a log entry marking the release, and apply
40
 
a signed tag.  Run it from your project's top-level directory.
 
36
Run this script from top_srcdir to perform the final pre-release NEWS
 
37
update in which the date, release-type and version string are
 
38
recorded.  Commit that result with a log entry marking the release,
 
39
and apply a signed tag.  Run it from your project's top-level
 
40
directory.
41
41
 
42
42
Requirements:
43
43
- you use git for version-control
 
44
- a version-controlled .prev-version file
44
45
- a NEWS file, with line 3 identical to this:
45
 
* Noteworthy changes in release ?.? (????-??-??) [?]
46
 
- a version-controlled .prev-version file
 
46
$noteworthy_stub
47
47
 
48
48
Options:
49
 
  --branch BRANCH            set release branch (default: master)
50
 
  --help                     print this help, then exit
51
 
  --version                  print version number, then exit
 
49
  --branch=BRANCH     set release branch (default: $branch)
 
50
  -C, --builddir=DIR  location of (configured) Makefile (default: $builddir)
 
51
  --help              print this help, then exit
 
52
  --version           print version number, then exit
52
53
 
53
54
EXAMPLE:
54
55
To update NEWS and tag the beta 8.1 release of coreutils, I would run this:
57
58
 
58
59
Report bugs and patches to <bug-gnulib@gnu.org>.
59
60
EOF
60
 
      exit ;;
 
61
  exit
 
62
}
61
63
 
62
 
    --version)
63
 
      year=`echo "$VERSION" | sed 's/[^0-9].*//'`
64
 
      cat <<EOF
 
64
version()
 
65
{
 
66
  year=$(echo "$VERSION" | sed 's/[^0-9].*//')
 
67
  cat <<EOF
65
68
$ME $VERSION
66
69
Copyright (C) $year Free Software Foundation, Inc,
67
70
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
68
71
This is free software: you are free to change and redistribute it.
69
72
There is NO WARRANTY, to the extent permitted by law.
70
73
EOF
71
 
      exit ;;
72
 
 
73
 
  *) die "unrecognized option: $1";;
74
 
  esac
 
74
  exit
75
75
}
76
76
 
77
 
branch=master
78
 
case $1 in
79
 
  --branch) shift; branch=$1; shift ;;
80
 
esac
81
 
 
82
 
case $# in
83
 
  1) help_version $1; exit 0;;
84
 
  2) ;;
85
 
  *) warn "Usage: $ME [OPTION...] VERSION TYPE"; exit 1;;
86
 
esac
 
77
## ------ ##
 
78
## Main.  ##
 
79
## ------ ##
 
80
 
 
81
# Constants.
 
82
noteworthy='* Noteworthy changes in release'
 
83
noteworthy_stub="$noteworthy ?.? (????-??-??) [?]"
 
84
 
 
85
# Variables.
 
86
branch=$(git branch | sed -ne '/^\* /{s///;p;q;}')
 
87
builddir=.
 
88
 
 
89
while test $# != 0
 
90
do
 
91
  # Handle --option=value by splitting apart and putting back on argv.
 
92
  case $1 in
 
93
    --*=*)
 
94
      opt=$(echo "$1" | sed -e 's/=.*//')
 
95
      val=$(echo "$1" | sed -e 's/[^=]*=//')
 
96
      shift
 
97
      set dummy "$opt" "$val" ${1+"$@"}; shift
 
98
      ;;
 
99
  esac
 
100
 
 
101
  case $1 in
 
102
    --help|--version) ${1#--};;
 
103
    --branch) shift; branch=$1; shift ;;
 
104
    -C|--builddir) shift; builddir=$1; shift ;;
 
105
    --*) die "unrecognized option: $1";;
 
106
    *) break;;
 
107
  esac
 
108
done
 
109
 
 
110
test $# = 2 \
 
111
  || die "Usage: $ME [OPTION...] VERSION TYPE"
87
112
 
88
113
ver=$1
89
114
type=$2
90
115
 
 
116
 
 
117
## ---------------------- ##
 
118
## First, sanity checks.  ##
 
119
## ---------------------- ##
 
120
 
91
121
# Verify that $ver looks like a version number, and...
92
122
echo "$ver"|grep -E '^[0-9][0-9.]*[0-9]$' > /dev/null \
93
123
  || die "invalid version: $ver"
97
127
# Verify that $ver is sensible (> .prev-version).
98
128
case $(printf "$prev_ver\n$ver\n"|sort -V -u|tr '\n' ':') in
99
129
  "$prev_ver:$ver:") ;;
100
 
  *) die "invalid version: $ver";;
 
130
  *) die "invalid version: $ver (<= $prev_ver)";;
101
131
esac
102
132
 
103
133
case $type in
105
135
  *) die "invalid release type: $type";;
106
136
esac
107
137
 
108
 
# Extract package name from Makefile.
109
 
pkg=$(sed -n 's/^PACKAGE = \(.*\)/\1/p' Makefile) \
110
 
  || die 'failed to determine package name from Makefile'
111
 
 
112
 
# simple check: no question marks on line 3 of NEWS
113
 
noteworthy='* Noteworthy changes in release'
114
 
test "$(sed -n 3p NEWS)" = "$noteworthy ?.? (????-??-??) [?]" \
115
 
  || die 'line 3 of NEWS looks fishy!'
116
 
 
117
 
# No dirt allowed.
 
138
# No local modifications allowed.
118
139
case $(git diff-index --name-only HEAD) in
119
140
  '') ;;
120
141
  *) die 'this tree is dirty; commit your changes first';;
121
142
esac
122
143
 
123
 
# update NEWS to have today's date, plus desired version number and $type
 
144
# Ensure the current branch name is correct:
 
145
curr_br=$(git rev-parse --symbolic-full-name HEAD)
 
146
test "$curr_br" = refs/heads/$branch || die not on branch $branch
 
147
 
 
148
# Extract package name from Makefile.
 
149
Makefile=$builddir/Makefile
 
150
pkg=$(sed -n 's/^PACKAGE = \(.*\)/\1/p' "$Makefile") \
 
151
  || die "failed to determine package name from $Makefile"
 
152
 
 
153
# Check that line 3 of NEWS is the stub line about to be replaced.
 
154
test "$(sed -n 3p NEWS)" = "$noteworthy_stub" \
 
155
  || die "line 3 of NEWS must be exactly '$noteworthy_stub'"
 
156
 
 
157
## --------------- ##
 
158
## Then, changes.  ##
 
159
## --------------- ##
 
160
 
 
161
# Update NEWS to have today's date, plus desired version number and $type.
124
162
perl -MPOSIX -ni -e 'my $today = strftime "%F", localtime time;' \
125
163
 -e 'my ($type, $ver) = qw('"$type $ver"');' \
126
164
 -e 'my $pfx = "'"$noteworthy"'";' \
127
165
 -e 'print $.==3 ? "$pfx $ver ($today) [$type]\n" : $_' \
128
166
     NEWS || die 'failed to update NEWS'
129
167
 
130
 
# Ensure the current branch name is correct:
131
 
curr_br=$(git rev-parse --symbolic-full-name HEAD)
132
 
test "$curr_br" = refs/heads/$branch || die not on branch $branch
133
 
 
134
168
printf "version $ver\n\n* NEWS: Record release date.\n" \
135
169
    | git commit -F -  -a || die 'git commit failed'
136
170
git tag -s -m "$pkg $ver" v$ver HEAD || die 'git tag failed'