[PATCH] devel: add release-checks.sh
authorTomi Ollila <tomi.ollila@iki.fi>
Wed, 8 Aug 2012 20:01:47 +0000 (23:01 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:49:00 +0000 (09:49 -0800)
ac/2bafc07cc674bb372210bb660967c1c0e0fe29 [new file with mode: 0644]

diff --git a/ac/2bafc07cc674bb372210bb660967c1c0e0fe29 b/ac/2bafc07cc674bb372210bb660967c1c0e0fe29
new file mode 100644 (file)
index 0000000..60f3f5f
--- /dev/null
@@ -0,0 +1,292 @@
+Return-Path: <too@guru-group.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 710A0431FBD\r
+       for <notmuch@notmuchmail.org>; Wed,  8 Aug 2012 13:01:41 -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 gLG24vEyNMQM for <notmuch@notmuchmail.org>;\r
+       Wed,  8 Aug 2012 13:01:40 -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 048A9431FAE\r
+       for <notmuch@notmuchmail.org>; Wed,  8 Aug 2012 13:01:39 -0700 (PDT)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+       id DD4B11002A4; Wed,  8 Aug 2012 23:01:49 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] devel: add release-checks.sh\r
+Date: Wed,  8 Aug 2012 23:01:47 +0300\r
+Message-Id: <1344456107-19308-1-git-send-email-tomi.ollila@iki.fi>\r
+X-Mailer: git-send-email 1.7.1\r
+Cc: Tomi Ollila <tomi.ollila@iki.fi>\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: Wed, 08 Aug 2012 20:01:41 -0000\r
+\r
+Currently Makefile.local contains some machine executable release\r
+checking functionality. This is unnecessarily complex way to do it:\r
+\r
+Multiline script functionality is hard to embed -- from Makefile point\r
+of view there is just one line split using backslashes and every line\r
+ends with ';'. It is hard to maintain such "scripts" when it gets longer.\r
+\r
+The script does not fail as robust as separate script; set -eu could\r
+be added to get same level of robustness -- but the provided Bourne\r
+Again Shell (bash) script exceeds this with 'set -o pipefail', making\r
+script to fail when any of the commands in pipeline fails (i.e. not\r
+just the last one).\r
+\r
+Checking for release is done very seldom compared to all other use;\r
+The whole Makefile.local gets simpler and easier to grasp when most\r
+release checking targets are removed.\r
+\r
+When release checking is done, the steps are executed sequentially;\r
+nothing is allowed to be skipped due to some satisfied dependency.\r
+---\r
+\r
+I did not send patch to remove corresponding lines from Makefile.local\r
+just yet. This allows David to run this script in parallel to the code\r
+currently in Makefile.local -- and make sure 0.14 gets best release\r
+engineering treatment so far. Then Makefile.local can be made to execute\r
+this script in place of code it supersedes.\r
+\r
+ devel/release-checks.sh |  210 +++++++++++++++++++++++++++++++++++++++++++++++\r
+ 1 files changed, 210 insertions(+), 0 deletions(-)\r
+ create mode 100755 devel/release-checks.sh\r
+\r
+diff --git a/devel/release-checks.sh b/devel/release-checks.sh\r
+new file mode 100755\r
+index 0000000..29e27df\r
+--- /dev/null\r
++++ b/devel/release-checks.sh\r
+@@ -0,0 +1,210 @@\r
++#!/usr/bin/env bash\r
++\r
++set -eu\r
++#set -x # or enter bash -x ... on command line.\r
++\r
++if [ x"${BASH_VERSION-}" = x ]\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=C LC_ALL=C; export LANG LC_ALL\r
++\r
++readonly DEFAULT_IFS="$IFS"\r
++\r
++readonly PV_FILE='bindings/python/notmuch/version.py'\r
++\r
++# using array here turned out to be unnecessarily complicated\r
++emsgs=''\r
++append_emsg ()\r
++{\r
++      emsgs="${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
++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
++\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" = 'notmuch' ]\r
++then\r
++      echo Yes.\r
++else\r
++      echo No.\r
++      append_emsg "Package name '$deb_notmuch' is not 'notmuch' in debian/changelog"\r
++fi\r
++\r
++echo -n "Checking that Debian package version is $VERSION-1... "\r
++\r
++if [ "$deb_version" = "($VERSION-1)" ]\r
++then\r
++      echo Yes.\r
++else\r
++      echo No.\r
++      append_emsg "Version '$deb_version' is not '($VERSION-1)' in debian/changelog"\r
++fi\r
++\r
++echo -n "Checking that python bindings version is $VERSION... "\r
++py_version=`python -c "execfile('$PV_FILE'); print __VERSION__"`\r
++if [ "$py_version" = "$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" = "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" = "$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=%Y mon=%m day=%d'`\r
++today0utc=`date --date=0Z +%s` # gnu date feature\r
++\r
++echo -n "Checking that NEWS date is right... "\r
++case $news_date in\r
++ '('201[0-9]-[0-1][1-9]-[0-3][1-9]')')\r
++      newsdate0utc=`nd=${news_date#\\(}; date --date="${nd%)} 0Z" +%s`\r
++      ddiff=$((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-dd)"\r
++esac\r
++\r
++readonly DATE=${news_date//[()]/} # bash feature\r
++manthdata ()\r
++{\r
++      set x $*\r
++      if [ $# != 7 ]\r
++      then\r
++              append_emsg "'$mp' has too many '.TH' lines"\r
++              man_mismatch=1\r
++      fi\r
++      man_date=${5-} man_version=${7-}\r
++}\r
++\r
++echo -n "Checking that manual page dates and versions are $DATE and $VERSION... "\r
++manfiles=`find man -type f | sort`\r
++for mp in $manfiles\r
++do\r
++      case $mp in *.[0-9]) ;; # fall below this case ... esac\r
++              */Makefile.local | */Makefile ) continue ;;\r
++              */.gitignore) continue ;;\r
++              *)      append_emsg "'$mp': extra file"\r
++                      man_mismatch=1\r
++                      continue ;;\r
++      esac\r
++      manthdata `sed -n '/^[.]TH NOTMUCH/ { y/"/ /; p; }' "$mp"`\r
++      if [ "$man_version" != "$VERSION" ]\r
++      then    append_emsg "Version '$man_version' is not '$VERSION' in $mp"\r
++              man_mismatch=1\r
++      fi\r
++      if [ "$man_date" != "$DATE" ]\r
++      then    append_emsg "DATE '$man_date' is not '$DATE' in $mp"\r
++              man_mismatch=1\r
++      fi\r
++done\r
++\r
++test "${man_mismatch-}" != 1 && echo Yes. || echo No.\r
++\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
++# Local variables:\r
++# mode: shell-script\r
++# sh-basic-offset: 8\r
++# tab-width: 8\r
++# End:\r
++# vi: set sw=8 ts=8\r
+--\r
+1.7.1\r
+\r