root / autotools / check-version @ 58458012
History | View | Annotate | Download (1.5 kB)
1 | 96602be4 | Michael Hanselmann | #!/bin/bash |
---|---|---|---|
2 | 96602be4 | Michael Hanselmann | # |
3 | 96602be4 | Michael Hanselmann | |
4 | a71afd47 | Michele Tartara | # Copyright (C) 2010,2013 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 | a71afd47 | Michele Tartara | # Format "x.y.z~rcN" or "x.y.z~betaN" or "x.y.z~alphaN" for N > 0 |
35 | a71afd47 | Michele Tartara | $numpat.$numpat.$numpat~@(rc|beta|alpha)[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 | a71afd47 | Michele Tartara | # Only alpha versions are allowed not to have their own NEWS section yet |
46 | a71afd47 | Michele Tartara | set +e |
47 | a71afd47 | Michele Tartara | FOUND=x`echo $version | grep "alpha[1-9]*[0-9]$"` |
48 | a71afd47 | Michele Tartara | set -e |
49 | a71afd47 | Michele Tartara | if [ $FOUND == "x" ] |
50 | 96602be4 | Michael Hanselmann | then |
51 | a71afd47 | Michele Tartara | if ! grep -q -x "$newsver" $newsfile |
52 | a71afd47 | Michele Tartara | then |
53 | a71afd47 | Michele Tartara | echo "Unable to find heading '$newsver' in NEWS" >&2 |
54 | a71afd47 | Michele Tartara | exit 1 |
55 | a71afd47 | Michele Tartara | fi |
56 | 96602be4 | Michael Hanselmann | fi |
57 | 96602be4 | Michael Hanselmann | |
58 | 96602be4 | Michael Hanselmann | exit 0 |