--- /dev/null
+Return-Path: <tomi.ollila@iki.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 1EDAE431FB6\r
+ for <notmuch@notmuchmail.org>; Mon, 3 Sep 2012 07:58:34 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id syRZT04Vq1dH for <notmuch@notmuchmail.org>;\r
+ Mon, 3 Sep 2012 07:58:32 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by olra.theworths.org (Postfix) with ESMTP id 9E486431FAF\r
+ for <notmuch@notmuchmail.org>; Mon, 3 Sep 2012 07:58:32 -0700 (PDT)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+ by guru.guru-group.fi (Postfix) with ESMTP id 0DCB31000E5;\r
+ Mon, 3 Sep 2012 17:58:39 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Michal Nazarewicz <mina86@mina86.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH V2 1/2] devel: add release-checks.sh\r
+In-Reply-To: <xa1t7gsbwbxe.fsf@mina86.com>\r
+References: <1346491928-2356-1-git-send-email-tomi.ollila@iki.fi>\r
+ <xa1t7gsbwbxe.fsf@mina86.com>\r
+User-Agent: Notmuch/0.14+11~gd9bf007 (http://notmuchmail.org) Emacs/24.2.1\r
+ (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+ $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+ !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Mon, 03 Sep 2012 17:58:38 +0300\r
+Message-ID: <m2sjazdug1.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: quoted-printable\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 03 Sep 2012 14:58:34 -0000\r
+\r
+On Mon, Sep 03 2012, Michal Nazarewicz <mina86@mina86.com> wrote:\r
+\r
+> Tomi Ollila <tomi.ollila@iki.fi> writes:\r
+>> diff --git a/devel/release-checks.sh b/devel/release-checks.sh\r
+>> new file mode 100755\r
+>> index 0000000..7dadefa\r
+>> --- /dev/null\r
+>> +++ b/devel/release-checks.sh\r
+>> @@ -0,0 +1,211 @@\r
+>> +#!/usr/bin/env bash\r
+>\r
+> On a side note, the whole script could be relatively easily rewritten\r
+> not to use bash at all and work with plain POSIX shell.\r
+\r
+The 'set -o pipefail' is hard to do using POSIX shell. I've been hit\r
+by this when 'find' part in find | sort' failed (due to a typo).\r
+\r
+When building release we can choose shell in more relaxed manner and\r
+expect release builder have a recent bash shell -- actually tests\r
+require bash 4...\r
+\r
+>> +\r
+>> +set -eu\r
+>> +#set -x # or enter bash -x ... on command line\r
+>> +\r
+>> +if [ x"${BASH_VERSION-}" =3D x ]\r
+>\r
+> -n perhaps?\r
+\r
+Before this test we cannot know what shell is run; the x"$var" =3D x=20\r
+is the most robust way to do this test. Well, if $BASH_VERSION had=20\r
+some value then we'd miss this error message and failed in\r
+set -o pipefail\r
+\r
+If we'd require bash 4 then the test [ x"${BASHPID-}" !=3D x$$ ]\r
+would be very hard to get wrong...\r
+\r
+>> +then echo\r
+>> + echo "Please execute this script using 'bash' interpreter"\r
+>> + echo\r
+>> + exit 1\r
+>> +fi\r
+>> +\r
+>> +set -o pipefail # bash feature\r
+>> +\r
+>> +# Avoid locale-specific differences in output of executed commands\r
+>> +LANG=3DC LC_ALL=3DC; export LANG LC_ALL\r
+>> +\r
+>> +readonly DEFAULT_IFS=3D"$IFS"\r
+>\r
+> Never used.\r
+\r
+True, it used to be. Can be removed in followup patch.\r
+\r
+>> +\r
+>> +readonly PV_FILE=3D'bindings/python/notmuch/version.py'\r
+>> +\r
+>> +# Using array here turned out to be unnecessarily complicated\r
+>> +emsgs=3D''\r
+>> +append_emsg ()\r
+>> +{\r
+>> + emsgs=3D"${emsgs:+$emsgs\n} $1"\r
+>> +}\r
+>> +\r
+>> +for f in ./version debian/changelog NEWS "$PV_FILE"\r
+>> +do\r
+>> + test -f $f || { append_emsg "File '$f' is missing"; continue; }\r
+>> + test -r $f || { append_emsg "File '$f' is unreadable"; continue; }\r
+>> + test -s $f || append_emsg "File '$f' is empty"\r
+>\r
+> if ! [ -f "$f" ]; then\r
+> append_emsg "File '$f' is missing"\r
+> elif ! [ -r "$f" ]; then\r
+> append_emsg "File '$f' is unreadable"\r
+> elif ! [ -s "$f" ]; then\r
+> append_emsg "File '$f' is empty"\r
+> fi\r
+\r
+IMHO this short-circuited or (||) version works well due to this\r
+negation handling. The $f's should have been quoted ("$f"), though\r
+(in case some of the items contain whitespace the construct=20\r
+would't fail). I am open to other opinions, though.\r
+\r
+>> +done\r
+>> +\r
+>> +if [ -n "$emsgs" ]\r
+>> +then\r
+>> + echo 'Release files problems; fix these and try again:'\r
+>> + echo -e "$emsgs"\r
+>> + exit 1\r
+>> +fi\r
+>> +\r
+>> +if read VERSION\r
+>> +then\r
+>> + if read rest\r
+>> + then echo "'version' file contains more than one line"\r
+>> + exit 1\r
+>> + fi\r
+>> +else\r
+>> + echo "Reading './version' file failed (suprisingly!)"\r
+>> + exit 1\r
+>> +fi < ./version\r
+>> +\r
+>> +readonly VERSION\r
+>> +\r
+>> +verfail ()\r
+>> +{\r
+>> + echo No.\r
+>> + echo "$@"\r
+>> + echo "Please follow the instructions in RELEASING to choose a version"\r
+>> + exit 1\r
+>> +}\r
+>> +\r
+>> +echo -n "Checking that '$VERSION' is good with digits and periods... "\r
+>> +if [ -z "${VERSION//[0123456789.]/}" ] # bash feature\r
+>> +then\r
+>> + case $VERSION in\r
+>> + .*) verfail "'$VERSION' begins with a period" ;;\r
+>> + *.) verfail "'$VERSION' ends with a period" ;;\r
+>> + *..*) verfail "'$VERSION' contains two consecutive periods" ;;\r
+>> + *.*) echo Yes. ;;\r
+>> + *) verfail "'$VERSION' is a single number" ;;\r
+>> + esac\r
+>> +else\r
+>> + verfail "'$VERSION' contains other characters than digits and periods"\r
+>> +fi\r
+>\r
+> The outer condition can be put inside of case as so:\r
+>\r
+> *[^0-9.]*) verfail "'$VERSION' contains other characters than digits and=\r
+ periods"\r
+>\r
+> This makes it more readable by putting all checks in case rather than\r
+> splitting one to an outer if.\r
+\r
+That's true! Also, one less bashish cannot be bad thing to have.\r
+\r
+>> +\r
+>> +\r
+>> +# In the rest of this file, tests collect list of errors to be fixed\r
+>> +\r
+>> +echo -n "Checking that this is Debian package for notmuch... "\r
+>> +read deb_notmuch deb_version rest < debian/changelog\r
+>> +if [ "$deb_notmuch" =3D 'notmuch' ]\r
+>\r
+> if [ x"$deb_notmuch" =3D xnotmuch ]\r
+>\r
+> And so in the rest of the conditions below.\r
+\r
+builtin bash '[' seems to be robust in these cases(*) ... but I'm now break=\r
+ing\r
+my own rule about not using most portable expressions; maybe it is just\r
+ugliness of the format in so many places. I'm not changing unless there is\r
+more desire for it :)\r
+\r
+(*) at least both of these work:\r
+ bash -c 'set -eu; foo=3D"-a"; [ "$foo" =3D -a ]'\r
+ bash -c 'set -eu; foo=3D"-z"; [ "$foo" =3D -z ]'\r
+\r
+>\r
+>> +then\r
+>> + echo Yes.\r
+>> +else\r
+>> + echo No.\r
+>> + append_emsg "Package name '$deb_notmuch' is not 'notmuch' in debian/ch=\r
+angelog"\r
+>> +fi\r
+>> +\r
+>> +echo -n "Checking that Debian package version is $VERSION-1... "\r
+>> +\r
+>> +if [ "$deb_version" =3D "($VERSION-1)" ]\r
+>> +then\r
+>> + echo Yes.\r
+>> +else\r
+>> + echo No.\r
+>> + append_emsg "Version '$deb_version' is not '($VERSION-1)' in debian/ch=\r
+angelog"\r
+>> +fi\r
+>> +\r
+>> +echo -n "Checking that python bindings version is $VERSION... "\r
+>> +py_version=3D`python -c "execfile('$PV_FILE'); print __VERSION__"`\r
+>> +if [ "$py_version" =3D "$VERSION" ]\r
+>> +then\r
+>> + echo Yes.\r
+>> +else\r
+>> + echo No.\r
+>> + append_emsg "Version '$py_version' is not '$VERSION' in $PV_FILE"\r
+>> +fi\r
+>> +\r
+>> +echo -n "Checking that this is Notmuch NEWS... "\r
+>> +read news_notmuch news_version news_date < NEWS\r
+>> +if [ "$news_notmuch" =3D "Notmuch" ]\r
+>> +then\r
+>> + echo Yes.\r
+>> +else\r
+>> + echo No.\r
+>> + append_emsg "First word '$news_notmuch' is not 'Notmuch' in NEWS file"\r
+>> +fi\r
+>> +\r
+>> +echo -n "Checking that NEWS version is $VERSION... "\r
+>> +if [ "$news_version" =3D "$VERSION" ]\r
+>> +then\r
+>> + echo Yes.\r
+>> +else\r
+>> + echo No.\r
+>> + append_emsg "Version '$news_version' in NEWS file is not '$VERSION'"\r
+>> +fi\r
+>> +\r
+>> +#eval `date '+year=3D%Y mon=3D%m day=3D%d'`\r
+>> +today0utc=3D`date --date=3D0Z +%s` # gnu date feature\r
+>> +\r
+>> +echo -n "Checking that NEWS date is right... "\r
+>> +case $news_date in\r
+>> + '('[2-9][0-9][0-9][0-9]-[01][0-9]-[0123][0-9]')')\r
+>> + newsdate0utc=3D`nd=3D${news_date#\\(}; date --date=3D"${nd%)} 0Z" +%s`\r
+>> + ddiff=3D$((newsdate0utc - today0utc))\r
+>> + if [ $ddiff -lt -86400 ] # since beginning of yesterday...\r
+>> + then\r
+>> + echo No.\r
+>> + append_emsg "Date $news_date in NEWS file is too much in the past"\r
+>> + elif [ $ddiff -gt 172800 ] # up to end of tomorrow...\r
+>> + then\r
+>> + echo No.\r
+>> + append_emsg "Date $news_date in NEWS file is too much in the future"\r
+>> + else\r
+>> + echo Yes.\r
+>> + fi ;;\r
+>> + *)\r
+>> + echo No.\r
+>> + append_emsg "Date '$news_date' in NEWS file is not in format (yyyy-mm-=\r
+dd)"\r
+>> +esac\r
+>> +\r
+>> +readonly DATE=3D${news_date//[()]/} # bash feature\r
+>> +manthdata ()\r
+>> +{\r
+>> + set x $*\r
+>\r
+> Uh? Did you mean =E2=80=9Cset -- $*=E2=80=9D?\r
+\r
+Nope, set in some shells don't know '--' (now I'm following the most\r
+portable code snippet principle) so with 'x' and just referencing\r
+positional parameters with number one larger than with '--' does the trick.\r
+\r
+>\r
+>> + if [ $# !=3D 7 ]\r
+>> + then\r
+>> + append_emsg "'$mp' has too many '.TH' lines"\r
+>> + man_mismatch=3D1\r
+>> + fi\r
+>> + man_date=3D${5-} man_version=3D${7-}\r
+>> +}\r
+>> +\r
+>> +echo -n "Checking that manual page dates and versions are $DATE and $VE=\r
+RSION... "\r
+>> +manfiles=3D`find man -type f | sort`\r
+>> +man_pages_ok=3DYes\r
+>> +for mp in $manfiles\r
+>> +do\r
+>> + case $mp in *.[0-9]) ;; # fall below this 'case ... esac'\r
+>\r
+> Perhaps new line after =E2=80=9Cin=E2=80=9D?\r
+\r
+Can be added...\r
+\r
+>\r
+>> + */Makefile.local | */Makefile ) continue ;;\r
+>> + */.gitignore) continue ;;\r
+>> + *.bak) continue ;;\r
+>> +\r
+>> + *) append_emsg "'$mp': extra file"\r
+>> + man_pages_ok=3DNo\r
+>> + continue\r
+>> + esac\r
+>> + manthdata `sed -n '/^[.]TH NOTMUCH/ { y/"/ /; p; }' "$mp"`\r
+>\r
+> Alternatively =E2=80=9C\.=E2=80=9D instead of =E2=80=9C[.]=E2=80=9D.\r
+\r
+I prefer [.] as a more robust alternative -- backslashes may get=20\r
+"expanded away" in some cases; using [.] just frees me from checking\r
+whether that may happen.\r
+\r
+>> + if [ "$man_version" !=3D "$VERSION" ]\r
+>> + then append_emsg "Version '$man_version' is not '$VERSION' in $mp"\r
+>> + mman_pages_ok=3DNo\r
+>> + fi\r
+>> + if [ "$man_date" !=3D "$DATE" ]\r
+>> + then append_emsg "DATE '$man_date' is not '$DATE' in $mp"\r
+>> + man_pages_ok=3DNo\r
+>> + fi\r
+>> +done\r
+>> +echo $man_pages_ok.\r
+>> +\r
+>> +if [ -n "$emsgs" ]\r
+>> +then\r
+>> + echo\r
+>> + echo 'Release check failed; check these issues:'\r
+>> + echo -e "$emsgs"\r
+>> + exit 1\r
+>> +fi\r
+>> +\r
+>> +echo 'All checks this script executed completed successfully.'\r
+>> +echo 'Make sure that everything else mentioned in RELEASING'\r
+>> +echo 'file is in order, too.'\r
+>> +\r
+>> +exit 0\r
+>\r
+> Unnecessary.\r
+\r
+True.=20\r
+\r
+Thanks for the review, I'll probably send new version tomorrow...\r
+\r
+>> +\r
+>> +# Local variables:\r
+>> +# mode: shell-script\r
+>> +# sh-basic-offset: 8\r
+>> +# tab-width: 8\r
+>> +# End:\r
+>> +# vi: set sw=3D8 ts=3D8\r
+>\r
+> --=20\r
+> Best regards, _ _\r
+> .o. | Liege of Serenely Enlightened Majesty of o' \,=3D./ `o\r
+> ..o | Computer Science, Micha=C5=82 =E2=80=9Cmina86=E2=80=9D Nazarewicz =\r
+ (o o)\r
+\r
+Tomi\r