]> git.notmuchmail.org Git - notmuch/blob - devel/release-checks.sh
Import notmuch_0.28.2.orig.tar.gz
[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 readonly DEFAULT_IFS="$IFS" # Note: In this particular case quotes are needed.
17
18 # Avoid locale-specific differences in output of executed commands
19 LANG=C LC_ALL=C; export LANG LC_ALL
20
21 readonly PV_FILE='bindings/python/notmuch/version.py'
22
23 # Using array here turned out to be unnecessarily complicated
24 emsgs=''
25 emsg_count=0
26 append_emsg ()
27 {
28         emsg_count=$((emsg_count + 1))
29         emsgs="${emsgs:+$emsgs\n}  $1"
30 }
31
32 for f in ./version debian/changelog NEWS "$PV_FILE"
33 do
34         if   [ ! -f "$f" ]; then append_emsg "File '$f' is missing"
35         elif [ ! -r "$f" ]; then append_emsg "File '$f' is unreadable"
36         elif [ ! -s "$f" ]; then append_emsg "File '$f' is empty"
37         fi
38 done
39
40 if [ -n "$emsgs" ]
41 then
42         echo 'Release files problems; fix these and try again:'
43         echo -e "$emsgs"
44         exit 1
45 fi
46
47 if read VERSION
48 then
49         if read rest
50         then    echo "'version' file contains more than one line"
51                 exit 1
52         fi
53 else
54         echo "Reading './version' file failed (surprisingly!)"
55         exit 1
56 fi < ./version
57
58 readonly VERSION
59
60 # In the rest of this file, tests collect list of errors to be fixed
61
62 echo -n "Checking that git working directory is clean... "
63 git_status=`git status --porcelain`
64 if [ "$git_status" = '' ]
65 then
66         echo Yes.
67 else
68         echo No.
69         append_emsg "Git working directory is not clean (git status --porcelain)."
70 fi
71 unset git_status
72
73 verfail ()
74 {
75         echo No.
76         append_emsg "$@"
77         append_emsg "  Please follow the instructions in RELEASING to choose a version"
78 }
79
80 echo -n "Checking that '$VERSION' is good with digits and periods... "
81 case $VERSION in
82         *[!0-9.]*)
83                 verfail "'$VERSION' contains other characters than digits and periods" ;;
84         .*)     verfail "'$VERSION' begins with a period" ;;
85         *.)     verfail "'$VERSION' ends with a period" ;;
86         *..*)   verfail "'$VERSION' contains two consecutive periods" ;;
87         *.*)    echo Yes. ;;
88         *)      verfail "'$VERSION' is a single number" ;;
89 esac
90
91 echo -n "Checking that this is Debian package for notmuch... "
92 read deb_notmuch deb_version rest < debian/changelog
93 if [ "$deb_notmuch" = 'notmuch' ]
94 then
95         echo Yes.
96 else
97         echo No.
98         append_emsg "Package name '$deb_notmuch' is not 'notmuch' in debian/changelog"
99 fi
100
101 echo -n "Checking that Debian package version is $VERSION-1... "
102
103 if [ "$deb_version" = "($VERSION-1)" ]
104 then
105         echo Yes.
106 else
107         echo No.
108         append_emsg "Version '$deb_version' is not '($VERSION-1)' in debian/changelog"
109 fi
110
111 echo -n "Checking that python bindings version is $VERSION... "
112 py_version=`python -c "with open('$PV_FILE') as vf: exec(vf.read()); print(__VERSION__)"`
113 if [ "$py_version" = "$VERSION" ]
114 then
115         echo Yes.
116 else
117         echo No.
118         append_emsg "Version '$py_version' is not '$VERSION' in $PV_FILE"
119 fi
120
121 echo -n "Checking that NEWS header is tidy... "
122 if [ "`exec sed 's/./=/g; 1q' NEWS`" = "`exec sed '1d; 2q' NEWS`" ]
123 then
124         echo Yes.
125 else
126         echo No.
127         if [ "`exec sed '1d; s/=//g; 2q' NEWS`" != '' ]
128         then
129                 append_emsg "Line 2 in NEWS file is not all '=':s"
130         else
131                 append_emsg "Line 2 in NEWS file does not have the same length as line 1"
132         fi
133 fi
134
135 echo -n "Checking that this is Notmuch NEWS... "
136 read news_notmuch news_version news_date < NEWS
137 if [ "$news_notmuch" = "Notmuch" ]
138 then
139         echo Yes.
140 else
141         echo No.
142         append_emsg "First word '$news_notmuch' is not 'Notmuch' in NEWS file"
143 fi
144
145 echo -n "Checking that NEWS version is $VERSION... "
146 if [ "$news_version" = "$VERSION" ]
147 then
148         echo Yes.
149 else
150         echo No.
151         append_emsg "Version '$news_version' in NEWS file is not '$VERSION'"
152 fi
153
154 #eval `date '+year=%Y mon=%m day=%d'`
155 today0utc=`date --date=0Z +%s` # gnu date feature
156
157 echo -n "Checking that NEWS date is right... "
158 case $news_date in
159  '('[2-9][0-9][0-9][0-9]-[01][0-9]-[0123][0-9]')')
160         newsdate0utc=`nd=${news_date#\\(}; date --date="${nd%)} 0Z" +%s`
161         ddiff=$((newsdate0utc - today0utc))
162         if [ $ddiff -lt -86400 ] # since beginning of yesterday...
163         then
164                 echo No.
165                 append_emsg "Date $news_date in NEWS file is too much in the past"
166         elif [ $ddiff -gt 172800 ] # up to end of tomorrow...
167         then
168                 echo No.
169                 append_emsg "Date $news_date in NEWS file is too much in the future"
170         else
171                 echo Yes.
172         fi ;;
173  *)
174         echo No.
175         append_emsg "Date '$news_date' in NEWS file is not in format (yyyy-mm-dd)"
176 esac
177
178 year=`exec date +%Y`
179 echo -n "Checking that copyright in documentation contains 2009-$year... "
180 # Read the value of variable `copyright' defined in 'doc/conf.py'.
181 # As __file__ is not defined when python command is given from command line,
182 # it is defined before contents of 'doc/conf.py' (which dereferences __file__)
183 # is executed.
184 copyrightline=`exec python -c "with open('doc/conf.py') as cf: __file__ = ''; exec(cf.read()); print(copyright)"`
185 case $copyrightline in
186         *2009-$year*)
187                 echo Yes. ;;
188         *)
189                 echo No.
190                 append_emsg "The copyright in doc/conf.py line '$copyrightline' does not contain '2009-$year'"
191 esac
192
193 if [ -n "$emsgs" ]
194 then
195         echo
196         echo 'Release check failed; check these issues:'
197         echo -e "$emsgs"
198         exit 1
199 fi
200
201 echo 'All checks this script executed completed successfully.'
202 echo 'Make sure that everything else mentioned in RELEASING'
203 echo 'file is in order, too.'
204
205
206 # Local variables:
207 # mode: shell-script
208 # sh-basic-offset: 8
209 # tab-width: 8
210 # End:
211 # vi: set sw=8 ts=8