4 #set -x # or enter bash -x ... on command line
6 if [ x"${BASH_VERSION-}" = x ]
8 echo "Please execute this script using 'bash' interpreter"
14 set -o pipefail # bash feature
16 readonly DEFAULT_IFS="$IFS" # Note: In this particular case quotes are needed.
18 # Avoid locale-specific differences in output of executed commands
19 LANG=C LC_ALL=C; export LANG LC_ALL
21 readonly PV_FILE='bindings/python/notmuch/version.py'
23 # Using array here turned out to be unnecessarily complicated
28 emsg_count=$((emsg_count + 1))
29 emsgs="${emsgs:+$emsgs\n} $1"
32 for f in ./version debian/changelog NEWS "$PV_FILE"
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"
42 echo 'Release files problems; fix these and try again:'
50 then echo "'version' file contains more than one line"
54 echo "Reading './version' file failed (suprisingly!)"
60 # In the rest of this file, tests collect list of errors to be fixed
66 append_emsg " Please follow the instructions in RELEASING to choose a version"
69 echo -n "Checking that '$VERSION' is good with digits and periods... "
72 verfail "'$VERSION' contains other characters than digits and periods" ;;
73 .*) verfail "'$VERSION' begins with a period" ;;
74 *.) verfail "'$VERSION' ends with a period" ;;
75 *..*) verfail "'$VERSION' contains two consecutive periods" ;;
77 *) verfail "'$VERSION' is a single number" ;;
80 echo -n "Checking that LIBNOTMUCH version macros & variables match ... "
82 LIBNOTMUCH_MAJOR_VERSION=broken
83 LIBNOTMUCH_MINOR_VERSION=broken
84 LIBNOTMUCH_MICRO_VERSION=broken
86 LIBNOTMUCH_VERSION_MAJOR=borken
87 LIBNOTMUCH_VERSION_MINOR=borken
88 LIBNOTMUCH_VERSION_RELEASE=borken
90 eval `awk 'NF == 3 && $1 == "#define" && $2 ~ /^LIBNOTMUCH_[A-Z]+_VERSION$/ \
91 && $3 ~ /^[0-9]+$/ { print $2 "=" $3 }' lib/notmuch.h`
93 eval `awk 'NF == 3 && $1 ~ /^LIBNOTMUCH_VERSION_[A-Z]+$/ && $2 == "=" \
94 && $3 ~ /^[0-9]+$/ { print $1 "=" $3 }' lib/Makefile.local`
97 check_version_component ()
99 eval local v1=\$LIBNOTMUCH_$1_VERSION
100 eval local v2=\$LIBNOTMUCH_VERSION_$2
102 then append_emsg "LIBNOTMUCH_$1_VERSION ($v1) does not equal LIBNOTMUCH_VERSION_$2 ($v2)"
106 old_emsg_count=$emsg_count
107 check_version_component MAJOR MAJOR
108 check_version_component MINOR MINOR
109 check_version_component MICRO RELEASE
110 [ $old_emsg_count = $emsg_count ] && echo Yes. || echo No.
112 echo -n "Checking that this is Debian package for notmuch... "
113 read deb_notmuch deb_version rest < debian/changelog
114 if [ "$deb_notmuch" = 'notmuch' ]
119 append_emsg "Package name '$deb_notmuch' is not 'notmuch' in debian/changelog"
122 echo -n "Checking that Debian package version is $VERSION-1... "
124 if [ "$deb_version" = "($VERSION-1)" ]
129 append_emsg "Version '$deb_version' is not '($VERSION-1)' in debian/changelog"
132 echo -n "Checking that python bindings version is $VERSION... "
133 py_version=`python -c "with open('$PV_FILE') as vf: exec(vf.read()); print __VERSION__"`
134 if [ "$py_version" = "$VERSION" ]
139 append_emsg "Version '$py_version' is not '$VERSION' in $PV_FILE"
142 echo -n "Checking that NEWS header is tidy... "
143 if [ "`exec sed 's/./=/g; 1q' NEWS`" = "`exec sed '1d; 2q' NEWS`" ]
148 if [ "`exec sed '1d; s/=//g; 2q' NEWS`" != '' ]
150 append_emsg "Line 2 in NEWS file is not all '=':s"
152 append_emsg "Line 2 in NEWS file does not have the same length as line 1"
156 echo -n "Checking that this is Notmuch NEWS... "
157 read news_notmuch news_version news_date < NEWS
158 if [ "$news_notmuch" = "Notmuch" ]
163 append_emsg "First word '$news_notmuch' is not 'Notmuch' in NEWS file"
166 echo -n "Checking that NEWS version is $VERSION... "
167 if [ "$news_version" = "$VERSION" ]
172 append_emsg "Version '$news_version' in NEWS file is not '$VERSION'"
175 #eval `date '+year=%Y mon=%m day=%d'`
176 today0utc=`date --date=0Z +%s` # gnu date feature
178 echo -n "Checking that NEWS date is right... "
180 '('[2-9][0-9][0-9][0-9]-[01][0-9]-[0123][0-9]')')
181 newsdate0utc=`nd=${news_date#\\(}; date --date="${nd%)} 0Z" +%s`
182 ddiff=$((newsdate0utc - today0utc))
183 if [ $ddiff -lt -86400 ] # since beginning of yesterday...
186 append_emsg "Date $news_date in NEWS file is too much in the past"
187 elif [ $ddiff -gt 172800 ] # up to end of tomorrow...
190 append_emsg "Date $news_date in NEWS file is too much in the future"
196 append_emsg "Date '$news_date' in NEWS file is not in format (yyyy-mm-dd)"
202 echo 'Release check failed; check these issues:'
207 echo 'All checks this script executed completed successfully.'
208 echo 'Make sure that everything else mentioned in RELEASING'
209 echo 'file is in order, too.'