Statistics
| Branch: | Tag: | Revision:

root / autotools / check-version @ 36c70d4d

History | View | Annotate | Download (1.3 kB)

1 96602be4 Michael Hanselmann
#!/bin/bash
2 96602be4 Michael Hanselmann
#
3 96602be4 Michael Hanselmann
4 96602be4 Michael Hanselmann
# Copyright (C) 2010 Google Inc.
5 96602be4 Michael Hanselmann
#
6 96602be4 Michael Hanselmann
# This program is free software; you can redistribute it and/or modify
7 96602be4 Michael Hanselmann
# it under the terms of the GNU General Public License as published by
8 96602be4 Michael Hanselmann
# the Free Software Foundation; either version 2 of the License, or
9 96602be4 Michael Hanselmann
# (at your option) any later version.
10 96602be4 Michael Hanselmann
#
11 96602be4 Michael Hanselmann
# This program is distributed in the hope that it will be useful, but
12 96602be4 Michael Hanselmann
# WITHOUT ANY WARRANTY; without even the implied warranty of
13 96602be4 Michael Hanselmann
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 96602be4 Michael Hanselmann
# General Public License for more details.
15 96602be4 Michael Hanselmann
#
16 96602be4 Michael Hanselmann
# You should have received a copy of the GNU General Public License
17 96602be4 Michael Hanselmann
# along with this program; if not, write to the Free Software
18 96602be4 Michael Hanselmann
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 96602be4 Michael Hanselmann
# 02110-1301, USA.
20 96602be4 Michael Hanselmann
21 96602be4 Michael Hanselmann
set -e
22 96602be4 Michael Hanselmann
23 96602be4 Michael Hanselmann
# Enable Bash-specific patterns
24 96602be4 Michael Hanselmann
shopt -s extglob
25 96602be4 Michael Hanselmann
26 96602be4 Michael Hanselmann
readonly version=$1
27 35576615 Michael Hanselmann
readonly newsfile=$2
28 96602be4 Michael Hanselmann
readonly numpat='+([0-9])'
29 96602be4 Michael Hanselmann
30 96602be4 Michael Hanselmann
case "$version" in
31 96602be4 Michael Hanselmann
  # Format "x.y.z"
32 96602be4 Michael Hanselmann
  $numpat.$numpat.$numpat) : ;;
33 96602be4 Michael Hanselmann
34 96602be4 Michael Hanselmann
  # Format "x.y.z~rcN" or "x.y.z~betaN" for N > 0
35 96602be4 Michael Hanselmann
  $numpat.$numpat.$numpat~@(rc|beta)[1-9]*([0-9])) : ;;
36 96602be4 Michael Hanselmann
37 96602be4 Michael Hanselmann
  *)
38 96602be4 Michael Hanselmann
    echo "Invalid version format: $version" >&2
39 96602be4 Michael Hanselmann
    exit 1
40 96602be4 Michael Hanselmann
  ;;
41 96602be4 Michael Hanselmann
esac
42 96602be4 Michael Hanselmann
43 cdb303ab Michael Hanselmann
readonly newsver="Version ${version/\~/ }"
44 96602be4 Michael Hanselmann
45 35576615 Michael Hanselmann
if ! grep -q -x "$newsver" $newsfile
46 96602be4 Michael Hanselmann
then
47 96602be4 Michael Hanselmann
  echo "Unable to find heading '$newsver' in NEWS" >&2
48 96602be4 Michael Hanselmann
  exit 1
49 96602be4 Michael Hanselmann
fi
50 96602be4 Michael Hanselmann
51 96602be4 Michael Hanselmann
exit 0