]> git.notmuchmail.org Git - notmuch/blob - devel/release-checks.sh
d2bbc6a06d077f7f57c6bab8713fc6f30e55bf02
[notmuch] / devel / release-checks.sh
1 #!/usr/bin/env bash
2
3 set -eu
4 #set -x # or enter bash -x ... on command line
5
6 if [ x"${BASH_VERSION-}" = x ]
7 then    echo
8         echo "Please execute this script using 'bash' interpreter"
9         echo
10         exit 1
11 fi
12
13 set -o posix
14 set -o pipefail # bash feature
15
16 # Avoid locale-specific differences in output of executed commands
17 LANG=C LC_ALL=C; export LANG LC_ALL
18
19 readonly PV_FILE='bindings/python/notmuch/version.py'
20
21 # Using array here turned out to be unnecessarily complicated
22 emsgs=''
23 append_emsg ()
24 {
25         emsgs="${emsgs:+$emsgs\n}  $1"
26 }
27
28 for f in ./version debian/changelog NEWS "$PV_FILE"
29 do
30         if   [ ! -f "$f" ]; then append_emsg "File '$f' is missing"
31         elif [ ! -r "$f" ]; then append_emsg "File '$f' is unreadable"
32         elif [ ! -s "$f" ]; then append_emsg "File '$f' is empty"
33         fi
34 done
35
36 if [ -n "$emsgs" ]
37 then
38         echo 'Release files problems; fix these and try again:'
39         echo -e "$emsgs"
40         exit 1
41 fi
42
43 if read VERSION
44 then
45         if read rest
46         then    echo "'version' file contains more than one line"
47                 exit 1
48         fi
49 else
50         echo "Reading './version' file failed (suprisingly!)"
51         exit 1
52 fi < ./version
53
54 readonly VERSION
55
56 # In the rest of this file, tests collect list of errors to be fixed
57
58 verfail ()
59 {
60         echo No.
61         append_emsg "$@"
62         append_emsg "  Please follow the instructions in RELEASING to choose a version"
63 }
64
65 echo -n "Checking that '$VERSION' is good with digits and periods... "
66 case $VERSION in
67         *[^0-9.]*)
68                 verfail "'$VERSION' contains other characters than digits and periods" ;;
69         .*)     verfail "'$VERSION' begins with a period" ;;
70         *.)     verfail "'$VERSION' ends with a period" ;;
71         *..*)   verfail "'$VERSION' contains two consecutive periods" ;;
72         *.*)    echo Yes. ;;
73         *)      verfail "'$VERSION' is a single number" ;;
74 esac
75
76
77 echo -n "Checking that this is Debian package for notmuch... "
78 read deb_notmuch deb_version rest < debian/changelog
79 if [ "$deb_notmuch" = 'notmuch' ]
80 then
81         echo Yes.
82 else
83         echo No.
84         append_emsg "Package name '$deb_notmuch' is not 'notmuch' in debian/changelog"
85 fi
86
87 echo -n "Checking that Debian package version is $VERSION-1... "
88
89 if [ "$deb_version" = "($VERSION-1)" ]
90 then
91         echo Yes.
92 else
93         echo No.
94         append_emsg "Version '$deb_version' is not '($VERSION-1)' in debian/changelog"
95 fi
96
97 echo -n "Checking that python bindings version is $VERSION... "
98 py_version=`python -c "execfile('$PV_FILE'); print __VERSION__"`
99 if [ "$py_version" = "$VERSION" ]
100 then
101         echo Yes.
102 else
103         echo No.
104         append_emsg "Version '$py_version' is not '$VERSION' in $PV_FILE"
105 fi
106
107 echo -n "Checking that this is Notmuch NEWS... "
108 read news_notmuch news_version news_date < NEWS
109 if [ "$news_notmuch" = "Notmuch" ]
110 then
111         echo Yes.
112 else
113         echo No.
114         append_emsg "First word '$news_notmuch' is not 'Notmuch' in NEWS file"
115 fi
116
117 echo -n "Checking that NEWS version is $VERSION... "
118 if [ "$news_version" = "$VERSION" ]
119 then
120         echo Yes.
121 else
122         echo No.
123         append_emsg "Version '$news_version' in NEWS file is not '$VERSION'"
124 fi
125
126 #eval `date '+year=%Y mon=%m day=%d'`
127 today0utc=`date --date=0Z +%s` # gnu date feature
128
129 echo -n "Checking that NEWS date is right... "
130 case $news_date in
131  '('[2-9][0-9][0-9][0-9]-[01][0-9]-[0123][0-9]')')
132         newsdate0utc=`nd=${news_date#\\(}; date --date="${nd%)} 0Z" +%s`
133         ddiff=$((newsdate0utc - today0utc))
134         if [ $ddiff -lt -86400 ] # since beginning of yesterday...
135         then
136                 echo No.
137                 append_emsg "Date $news_date in NEWS file is too much in the past"
138         elif [ $ddiff -gt 172800 ] # up to end of tomorrow...
139         then
140                 echo No.
141                 append_emsg "Date $news_date in NEWS file is too much in the future"
142         else
143                 echo Yes.
144         fi ;;
145  *)
146         echo No.
147         append_emsg "Date '$news_date' in NEWS file is not in format (yyyy-mm-dd)"
148 esac
149
150 readonly DATE=${news_date//[()]/} # bash feature
151 manthdata ()
152 {
153         set x $*
154         if [ $# != 7 ]
155         then
156                 append_emsg "'$mp' has too many '.TH' lines"
157                 man_mismatch=1
158         fi
159         man_date=${5-} man_version=${7-}
160 }
161
162 echo -n "Checking that manual page dates and versions are $DATE and $VERSION... "
163 manfiles=`find man -type f | sort`
164 man_pages_ok=Yes
165 for mp in $manfiles
166 do
167         case $mp in
168                 *.[0-9]) ;; # fall below this 'case ... esac'
169
170                 */Makefile.local | */Makefile ) continue ;;
171                 */.gitignore)   continue ;;
172                 *.bak)          continue ;;
173
174                 *)      append_emsg "'$mp': extra file"
175                         man_pages_ok=No
176                         continue
177         esac
178         manthdata `sed -n '/^[.]TH NOTMUCH/ { y/"/ /; p; }' "$mp"`
179         if [ "$man_version" != "$VERSION" ]
180         then    append_emsg "Version '$man_version' is not '$VERSION' in $mp"
181                 mman_pages_ok=No
182         fi
183         if [ "$man_date" != "$DATE" ]
184         then    append_emsg "DATE '$man_date' is not '$DATE' in $mp"
185                 man_pages_ok=No
186         fi
187 done
188 echo $man_pages_ok.
189
190 if [ -n "$emsgs" ]
191 then
192         echo
193         echo 'Release check failed; check these issues:'
194         echo -e "$emsgs"
195         exit 1
196 fi
197
198 echo 'All checks this script executed completed successfully.'
199 echo 'Make sure that everything else mentioned in RELEASING'
200 echo 'file is in order, too.'
201
202
203 # Local variables:
204 # mode: shell-script
205 # sh-basic-offset: 8
206 # tab-width: 8
207 # End:
208 # vi: set sw=8 ts=8