From: Tomi Ollila Date: Tue, 4 Sep 2012 14:49:12 +0000 (+0300) Subject: [PATCH v3 1/2] devel: add release-checks.sh X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=5a33ca14b8a5e872bc8830bf6a55912cf8c91f93;p=notmuch-archives.git [PATCH v3 1/2] devel: add release-checks.sh --- diff --git a/52/ecbffa42f5c83be3b47c562b3f3af9852e13ff b/52/ecbffa42f5c83be3b47c562b3f3af9852e13ff new file mode 100644 index 000000000..1ead7b894 --- /dev/null +++ b/52/ecbffa42f5c83be3b47c562b3f3af9852e13ff @@ -0,0 +1,286 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id BE710431FC2 + for ; Tue, 4 Sep 2012 07:49:16 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id Myded6FCJtEK for ; + Tue, 4 Sep 2012 07:49:15 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id 7B777431FAF + for ; Tue, 4 Sep 2012 07:49:14 -0700 (PDT) +Received: by guru.guru-group.fi (Postfix, from userid 501) + id 9536E100150; Tue, 4 Sep 2012 17:49:21 +0300 (EEST) +From: Tomi Ollila +To: notmuch@notmuchmail.org +Subject: [PATCH v3 1/2] devel: add release-checks.sh +Date: Tue, 4 Sep 2012 17:49:12 +0300 +Message-Id: <1346770153-14947-2-git-send-email-tomi.ollila@iki.fi> +X-Mailer: git-send-email 1.7.1 +In-Reply-To: <1346770153-14947-1-git-send-email-tomi.ollila@iki.fi> +References: <1346770153-14947-1-git-send-email-tomi.ollila@iki.fi> +Cc: tomi.ollila@iki.fi +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Tue, 04 Sep 2012 14:49:17 -0000 + +Currently Makefile.local contains some machine executable release +checking functionality. This is unnecessarily complex way to do it: + +Multiline script functionality is hard to embed -- from Makefile point +of view there is just one line split using backslashes and every line +ends with ';'. It is hard to maintain such "script" when it gets longer. + +The embedded script does not fail as robust as separate script; set -eu +could be added to get same level of robustness -- but the provided +Bourne Again Shell (bash) script exceeds this with 'set -o pipefail', +making the script to fail when any of the commands in pipeline fails +(and not just the last one). + +Checking for release is done very seldom compared to all other use; +The whole Makefile.local gets simpler and easier to grasp when most +release checking targets are removed. + +When release checking is done, the steps are executed sequentially; +nothing is allowed to be skipped due to some satisfied dependency. +--- + devel/release-checks.sh | 209 +++++++++++++++++++++++++++++++++++++++++++++++ + 1 files changed, 209 insertions(+), 0 deletions(-) + create mode 100755 devel/release-checks.sh + +diff --git a/devel/release-checks.sh b/devel/release-checks.sh +new file mode 100755 +index 0000000..e1d19f2 +--- /dev/null ++++ b/devel/release-checks.sh +@@ -0,0 +1,209 @@ ++#!/usr/bin/env bash ++ ++set -eu ++#set -x # or enter bash -x ... on command line ++ ++if [ x"${BASH_VERSION-}" = x ] ++then echo ++ echo "Please execute this script using 'bash' interpreter" ++ echo ++ exit 1 ++fi ++ ++set -o posix ++set -o pipefail # bash feature ++ ++# Avoid locale-specific differences in output of executed commands ++LANG=C LC_ALL=C; export LANG LC_ALL ++ ++readonly PV_FILE='bindings/python/notmuch/version.py' ++ ++# Using array here turned out to be unnecessarily complicated ++emsgs='' ++append_emsg () ++{ ++ emsgs="${emsgs:+$emsgs\n} $1" ++} ++ ++for f in ./version debian/changelog NEWS "$PV_FILE" ++do ++ if [ ! -f "$f" ]; then append_emsg "File '$f' is missing" ++ elif [ ! -r "$f" ]; then append_emsg "File '$f' is unreadable" ++ elif [ ! -s "$f" ]; then append_emsg "File '$f' is empty" ++ fi ++done ++ ++if [ -n "$emsgs" ] ++then ++ echo 'Release files problems; fix these and try again:' ++ echo -e "$emsgs" ++ exit 1 ++fi ++ ++if read VERSION ++then ++ if read rest ++ then echo "'version' file contains more than one line" ++ exit 1 ++ fi ++else ++ echo "Reading './version' file failed (suprisingly!)" ++ exit 1 ++fi < ./version ++ ++readonly VERSION ++ ++verfail () ++{ ++ echo No. ++ echo "$@" ++ echo "Please follow the instructions in RELEASING to choose a version" ++ exit 1 ++} ++ ++echo -n "Checking that '$VERSION' is good with digits and periods... " ++case $VERSION in ++ *[^0-9.]*) ++ verfail "'$VERSION' contains other characters than digits and periods" ;; ++ .*) verfail "'$VERSION' begins with a period" ;; ++ *.) verfail "'$VERSION' ends with a period" ;; ++ *..*) verfail "'$VERSION' contains two consecutive periods" ;; ++ *.*) echo Yes. ;; ++ *) verfail "'$VERSION' is a single number" ;; ++esac ++ ++ ++# In the rest of this file, tests collect list of errors to be fixed ++ ++echo -n "Checking that this is Debian package for notmuch... " ++read deb_notmuch deb_version rest < debian/changelog ++if [ "$deb_notmuch" = 'notmuch' ] ++then ++ echo Yes. ++else ++ echo No. ++ append_emsg "Package name '$deb_notmuch' is not 'notmuch' in debian/changelog" ++fi ++ ++echo -n "Checking that Debian package version is $VERSION-1... " ++ ++if [ "$deb_version" = "($VERSION-1)" ] ++then ++ echo Yes. ++else ++ echo No. ++ append_emsg "Version '$deb_version' is not '($VERSION-1)' in debian/changelog" ++fi ++ ++echo -n "Checking that python bindings version is $VERSION... " ++py_version=`python -c "execfile('$PV_FILE'); print __VERSION__"` ++if [ "$py_version" = "$VERSION" ] ++then ++ echo Yes. ++else ++ echo No. ++ append_emsg "Version '$py_version' is not '$VERSION' in $PV_FILE" ++fi ++ ++echo -n "Checking that this is Notmuch NEWS... " ++read news_notmuch news_version news_date < NEWS ++if [ "$news_notmuch" = "Notmuch" ] ++then ++ echo Yes. ++else ++ echo No. ++ append_emsg "First word '$news_notmuch' is not 'Notmuch' in NEWS file" ++fi ++ ++echo -n "Checking that NEWS version is $VERSION... " ++if [ "$news_version" = "$VERSION" ] ++then ++ echo Yes. ++else ++ echo No. ++ append_emsg "Version '$news_version' in NEWS file is not '$VERSION'" ++fi ++ ++#eval `date '+year=%Y mon=%m day=%d'` ++today0utc=`date --date=0Z +%s` # gnu date feature ++ ++echo -n "Checking that NEWS date is right... " ++case $news_date in ++ '('[2-9][0-9][0-9][0-9]-[01][0-9]-[0123][0-9]')') ++ newsdate0utc=`nd=${news_date#\\(}; date --date="${nd%)} 0Z" +%s` ++ ddiff=$((newsdate0utc - today0utc)) ++ if [ $ddiff -lt -86400 ] # since beginning of yesterday... ++ then ++ echo No. ++ append_emsg "Date $news_date in NEWS file is too much in the past" ++ elif [ $ddiff -gt 172800 ] # up to end of tomorrow... ++ then ++ echo No. ++ append_emsg "Date $news_date in NEWS file is too much in the future" ++ else ++ echo Yes. ++ fi ;; ++ *) ++ echo No. ++ append_emsg "Date '$news_date' in NEWS file is not in format (yyyy-mm-dd)" ++esac ++ ++readonly DATE=${news_date//[()]/} # bash feature ++manthdata () ++{ ++ set x $* ++ if [ $# != 7 ] ++ then ++ append_emsg "'$mp' has too many '.TH' lines" ++ man_mismatch=1 ++ fi ++ man_date=${5-} man_version=${7-} ++} ++ ++echo -n "Checking that manual page dates and versions are $DATE and $VERSION... " ++manfiles=`find man -type f | sort` ++man_pages_ok=Yes ++for mp in $manfiles ++do ++ case $mp in ++ *.[0-9]) ;; # fall below this 'case ... esac' ++ ++ */Makefile.local | */Makefile ) continue ;; ++ */.gitignore) continue ;; ++ *.bak) continue ;; ++ ++ *) append_emsg "'$mp': extra file" ++ man_pages_ok=No ++ continue ++ esac ++ manthdata `sed -n '/^[.]TH NOTMUCH/ { y/"/ /; p; }' "$mp"` ++ if [ "$man_version" != "$VERSION" ] ++ then append_emsg "Version '$man_version' is not '$VERSION' in $mp" ++ mman_pages_ok=No ++ fi ++ if [ "$man_date" != "$DATE" ] ++ then append_emsg "DATE '$man_date' is not '$DATE' in $mp" ++ man_pages_ok=No ++ fi ++done ++echo $man_pages_ok. ++ ++if [ -n "$emsgs" ] ++then ++ echo ++ echo 'Release check failed; check these issues:' ++ echo -e "$emsgs" ++ exit 1 ++fi ++ ++echo 'All checks this script executed completed successfully.' ++echo 'Make sure that everything else mentioned in RELEASING' ++echo 'file is in order, too.' ++ ++ ++# Local variables: ++# mode: shell-script ++# sh-basic-offset: 8 ++# tab-width: 8 ++# End: ++# vi: set sw=8 ts=8 +-- +1.7.1 +