Re: [PATCH] lib: provide _notmuch_database_log_append
[notmuch-archives.git] / ac / 2bafc07cc674bb372210bb660967c1c0e0fe29
1 Return-Path: <too@guru-group.fi>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 710A0431FBD\r
6         for <notmuch@notmuchmail.org>; Wed,  8 Aug 2012 13:01:41 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id gLG24vEyNMQM for <notmuch@notmuchmail.org>;\r
16         Wed,  8 Aug 2012 13:01:40 -0700 (PDT)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id 048A9431FAE\r
19         for <notmuch@notmuchmail.org>; Wed,  8 Aug 2012 13:01:39 -0700 (PDT)\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)\r
21         id DD4B11002A4; Wed,  8 Aug 2012 23:01:49 +0300 (EEST)\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>\r
23 To: notmuch@notmuchmail.org\r
24 Subject: [PATCH] devel: add release-checks.sh\r
25 Date: Wed,  8 Aug 2012 23:01:47 +0300\r
26 Message-Id: <1344456107-19308-1-git-send-email-tomi.ollila@iki.fi>\r
27 X-Mailer: git-send-email 1.7.1\r
28 Cc: Tomi Ollila <tomi.ollila@iki.fi>\r
29 X-BeenThere: notmuch@notmuchmail.org\r
30 X-Mailman-Version: 2.1.13\r
31 Precedence: list\r
32 List-Id: "Use and development of the notmuch mail system."\r
33         <notmuch.notmuchmail.org>\r
34 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
35         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
36 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
37 List-Post: <mailto:notmuch@notmuchmail.org>\r
38 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
39 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
40         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
41 X-List-Received-Date: Wed, 08 Aug 2012 20:01:41 -0000\r
42 \r
43 Currently Makefile.local contains some machine executable release\r
44 checking functionality. This is unnecessarily complex way to do it:\r
45 \r
46 Multiline script functionality is hard to embed -- from Makefile point\r
47 of view there is just one line split using backslashes and every line\r
48 ends with ';'. It is hard to maintain such "scripts" when it gets longer.\r
49 \r
50 The script does not fail as robust as separate script; set -eu could\r
51 be added to get same level of robustness -- but the provided Bourne\r
52 Again Shell (bash) script exceeds this with 'set -o pipefail', making\r
53 script to fail when any of the commands in pipeline fails (i.e. not\r
54 just the last one).\r
55 \r
56 Checking for release is done very seldom compared to all other use;\r
57 The whole Makefile.local gets simpler and easier to grasp when most\r
58 release checking targets are removed.\r
59 \r
60 When release checking is done, the steps are executed sequentially;\r
61 nothing is allowed to be skipped due to some satisfied dependency.\r
62 ---\r
63 \r
64 I did not send patch to remove corresponding lines from Makefile.local\r
65 just yet. This allows David to run this script in parallel to the code\r
66 currently in Makefile.local -- and make sure 0.14 gets best release\r
67 engineering treatment so far. Then Makefile.local can be made to execute\r
68 this script in place of code it supersedes.\r
69 \r
70  devel/release-checks.sh |  210 +++++++++++++++++++++++++++++++++++++++++++++++\r
71  1 files changed, 210 insertions(+), 0 deletions(-)\r
72  create mode 100755 devel/release-checks.sh\r
73 \r
74 diff --git a/devel/release-checks.sh b/devel/release-checks.sh\r
75 new file mode 100755\r
76 index 0000000..29e27df\r
77 --- /dev/null\r
78 +++ b/devel/release-checks.sh\r
79 @@ -0,0 +1,210 @@\r
80 +#!/usr/bin/env bash\r
81 +\r
82 +set -eu\r
83 +#set -x # or enter bash -x ... on command line.\r
84 +\r
85 +if [ x"${BASH_VERSION-}" = x ]\r
86 +then   echo\r
87 +       echo "Please execute this script using 'bash' interpreter."\r
88 +       echo\r
89 +       exit 1\r
90 +fi\r
91 +\r
92 +set -o pipefail # bash feature\r
93 +\r
94 +# Avoid locale-specific differences in output of executed commands.\r
95 +LANG=C LC_ALL=C; export LANG LC_ALL\r
96 +\r
97 +readonly DEFAULT_IFS="$IFS"\r
98 +\r
99 +readonly PV_FILE='bindings/python/notmuch/version.py'\r
100 +\r
101 +# using array here turned out to be unnecessarily complicated\r
102 +emsgs=''\r
103 +append_emsg ()\r
104 +{\r
105 +       emsgs="${emsgs:+$emsgs\n}  $1"\r
106 +}\r
107 +\r
108 +for f in ./version debian/changelog NEWS "$PV_FILE"\r
109 +do\r
110 +       test -f $f || { append_emsg "File '$f' is missing"; continue; }\r
111 +       test -r $f || { append_emsg "File '$f' is unreadable"; continue; }\r
112 +       test -s $f ||   append_emsg "File '$f' is empty"\r
113 +done\r
114 +\r
115 +if [ -n "$emsgs" ]\r
116 +then\r
117 +       echo 'Release files problems; fix these and try again:'\r
118 +       echo -e "$emsgs"\r
119 +       exit 1\r
120 +fi\r
121 +\r
122 +if read VERSION\r
123 +then\r
124 +       if read rest\r
125 +       then    echo "'version' file contains more than one line"\r
126 +               exit 1\r
127 +       fi\r
128 +else\r
129 +       echo "Reading './version' file failed (suprisingly!)"\r
130 +       exit 1\r
131 +fi < ./version\r
132 +\r
133 +readonly VERSION\r
134 +\r
135 +verfail ()\r
136 +{\r
137 +       echo No.\r
138 +       echo "$@"\r
139 +       echo "Please follow the instructions in RELEASING to choose a version"\r
140 +       exit 1\r
141 +}\r
142 +\r
143 +echo -n "Checking that '$VERSION' is good with digits and periods... "\r
144 +if [ -z "${VERSION//[0123456789.]/}" ] # bash feature\r
145 +then\r
146 +       case $VERSION in\r
147 +               .*)     verfail "'$VERSION' begins with a period" ;;\r
148 +               *.)     verfail "'$VERSION' ends with a period" ;;\r
149 +               *..*)   verfail "'$VERSION' contains two consecutive periods";;\r
150 +               *.*)    echo Yes. ;;\r
151 +               *)      verfail "'$VERSION' is a single number" ;;\r
152 +       esac\r
153 +else\r
154 +       verfail "'$VERSION' contains other characters than digits and periods"\r
155 +fi\r
156 +\r
157 +\r
158 +# In the rest of this file, tests collect list of errors to be fixed\r
159 +\r
160 +echo -n "Checking that this is Debian package for notmuch... "\r
161 +read deb_notmuch deb_version rest < debian/changelog\r
162 +if [ "$deb_notmuch" = 'notmuch' ]\r
163 +then\r
164 +       echo Yes.\r
165 +else\r
166 +       echo No.\r
167 +       append_emsg "Package name '$deb_notmuch' is not 'notmuch' in debian/changelog"\r
168 +fi\r
169 +\r
170 +echo -n "Checking that Debian package version is $VERSION-1... "\r
171 +\r
172 +if [ "$deb_version" = "($VERSION-1)" ]\r
173 +then\r
174 +       echo Yes.\r
175 +else\r
176 +       echo No.\r
177 +       append_emsg "Version '$deb_version' is not '($VERSION-1)' in debian/changelog"\r
178 +fi\r
179 +\r
180 +echo -n "Checking that python bindings version is $VERSION... "\r
181 +py_version=`python -c "execfile('$PV_FILE'); print __VERSION__"`\r
182 +if [ "$py_version" = "$VERSION" ]\r
183 +then\r
184 +       echo Yes.\r
185 +else\r
186 +       echo No.\r
187 +       append_emsg "Version '$py_version' is not '$VERSION' in $PV_FILE"\r
188 +fi\r
189 +\r
190 +echo -n "Checking that this is Notmuch NEWS... "\r
191 +read news_notmuch news_version news_date < NEWS\r
192 +if [ "$news_notmuch" = "Notmuch" ]\r
193 +then\r
194 +       echo Yes.\r
195 +else\r
196 +       echo No.\r
197 +       append_emsg "First word '$news_notmuch' is not 'Notmuch' in NEWS file"\r
198 +fi\r
199 +\r
200 +echo -n "Checking that NEWS version is $VERSION... "\r
201 +if [ "$news_version" = "$VERSION" ]\r
202 +then\r
203 +       echo Yes.\r
204 +else\r
205 +       echo No.\r
206 +       append_emsg "Version '$news_version' in NEWS file is not '$VERSION'"\r
207 +fi\r
208 +\r
209 +#eval `date '+year=%Y mon=%m day=%d'`\r
210 +today0utc=`date --date=0Z +%s` # gnu date feature\r
211 +\r
212 +echo -n "Checking that NEWS date is right... "\r
213 +case $news_date in\r
214 + '('201[0-9]-[0-1][1-9]-[0-3][1-9]')')\r
215 +       newsdate0utc=`nd=${news_date#\\(}; date --date="${nd%)} 0Z" +%s`\r
216 +       ddiff=$((newsdate0utc - today0utc))\r
217 +       if [ $ddiff -lt -86400 ] # since beginning of yesterday...\r
218 +       then\r
219 +               echo No.\r
220 +               append_emsg "Date $news_date in NEWS file is too much in the past"\r
221 +       elif [ $ddiff -gt 172800 ] # up to end of tomorrow...\r
222 +       then\r
223 +               echo No.\r
224 +               append_emsg "Date $news_date in NEWS file is too much in the future"\r
225 +       else\r
226 +               echo Yes.\r
227 +       fi ;;\r
228 + *)\r
229 +       echo No.\r
230 +       append_emsg "Date '$news_date' in NEWS file is not in format (yyyy-mm-dd)"\r
231 +esac\r
232 +\r
233 +readonly DATE=${news_date//[()]/} # bash feature\r
234 +manthdata ()\r
235 +{\r
236 +       set x $*\r
237 +       if [ $# != 7 ]\r
238 +       then\r
239 +               append_emsg "'$mp' has too many '.TH' lines"\r
240 +               man_mismatch=1\r
241 +       fi\r
242 +       man_date=${5-} man_version=${7-}\r
243 +}\r
244 +\r
245 +echo -n "Checking that manual page dates and versions are $DATE and $VERSION... "\r
246 +manfiles=`find man -type f | sort`\r
247 +for mp in $manfiles\r
248 +do\r
249 +       case $mp in *.[0-9]) ;; # fall below this case ... esac\r
250 +               */Makefile.local | */Makefile ) continue ;;\r
251 +               */.gitignore) continue ;;\r
252 +               *)      append_emsg "'$mp': extra file"\r
253 +                       man_mismatch=1\r
254 +                       continue ;;\r
255 +       esac\r
256 +       manthdata `sed -n '/^[.]TH NOTMUCH/ { y/"/ /; p; }' "$mp"`\r
257 +       if [ "$man_version" != "$VERSION" ]\r
258 +       then    append_emsg "Version '$man_version' is not '$VERSION' in $mp"\r
259 +               man_mismatch=1\r
260 +       fi\r
261 +       if [ "$man_date" != "$DATE" ]\r
262 +       then    append_emsg "DATE '$man_date' is not '$DATE' in $mp"\r
263 +               man_mismatch=1\r
264 +       fi\r
265 +done\r
266 +\r
267 +test "${man_mismatch-}" != 1 && echo Yes. || echo No.\r
268 +\r
269 +\r
270 +if [ -n "$emsgs" ]\r
271 +then\r
272 +       echo\r
273 +       echo 'Release check failed; check these issues:'\r
274 +       echo -e "$emsgs"\r
275 +       exit 1\r
276 +fi\r
277 +\r
278 +echo All checks this script executed completed successfully.\r
279 +echo Make sure that everything else mentioned in RELEASING\r
280 +echo file is in order, too.\r
281 +\r
282 +exit 0\r
283 +\r
284 +# Local variables:\r
285 +# mode: shell-script\r
286 +# sh-basic-offset: 8\r
287 +# tab-width: 8\r
288 +# End:\r
289 +# vi: set sw=8 ts=8\r
290 --\r
291 1.7.1\r
292 \r