3 packaging_check_init() {
7 packaging_check_file() {
8 local filename="$1" status=0
12 check_versions || status=1
16 check_versions || status=1
20 check_versions || status=1
24 check_changelog || status=1
28 #echo "No checks found for $filename"
35 packaging_check_fin() {
36 if [ "$version_check" ]
38 version=`get_configure_ac_version`
39 case "$(match_version $version)" in
40 prerelease|candidate|release)
44 cp $MYTMP/build/*.tar.* .
45 echo "Check $(cd $MYTMP/build && ls *.tar.gz) before pushing tags"
61 if [ "$dir" = "$1" ]; then dir="."; fi
62 mkdir -p $MYTMP/files/$dir
64 test -f $MYTMP/files/$1 && return 0
68 if [ $optional -eq 1 ]
70 git show :$1 > $MYTMP/files/$1 2> /dev/null || rm -f $MYTMP/files/$1
72 git show :$1 > $MYTMP/files/$1
75 if [ $optional -eq 0 -o -f $1 ]
83 if [ -f $MYTMP/success ]; then return 0; fi
85 git archive HEAD | tar -xf - -C "$MYTMP/build"
86 git diff --staged | patch -p1 -d "$MYTMP/build"
87 (cd $MYTMP/build; ./packaging/git-build || touch $MYTMP/fail)
88 if [ -f $MYTMP/fail ]; then return 1; fi
89 (cd $MYTMP/build; ./packaging/tar-compare . *.tar.gz || touch $MYTMP/fail)
90 if [ -f $MYTMP/fail ]; then return 1; fi
95 get_changelog_version() {
96 get_staged_file ChangeLog
97 local v=`sed -ne '1s/.*(\(.*\)).*/\1/p' $MYTMP/files/ChangeLog`
98 if [ ! "$v" ]; then v="No version in ChangeLog!"; fi
102 get_configure_ac_version() {
103 get_staged_file configure.ac
105 -e '/define(\[VERSION_MAJOR/s/.*\[\([^[]*\)\].*/\1/p' \
106 -e '/define(\[VERSION_MINOR/s/.*\[\([^[]*\)\].*/.\1/p' \
107 -e '/define(\[VERSION_FIX/s/.*\[\([^[]*\)\].*/.\1/p' \
108 -e '/define(\[VERSION_SUFFIX/s/.*\[\([^[]*\)\].*/\1/p' \
109 $MYTMP/files/configure.ac | tr -d '\n'`
110 if [ ! "$v" ]; then v="No version in configure.ac!"; fi
114 get_configure_ac_package() {
115 get_staged_file configure.ac
116 local v=`sed -n -e 's/AC_INIT(\[\([^]]*\)\].*/\1/p' configure.ac`
117 if [ ! "$v" ]; then v="noname"; fi
121 get_configure_ac_rpmrel() {
122 get_staged_file configure.ac
123 local v=`sed -n -e 's/PACKAGE_RPM_RELEASE="\([^"]*\)".*/\1/p' configure.ac`
124 if [ ! "$v" ]; then v="norpmrel"; fi
129 get_staged_file -o "$1".spec.in
130 test -f $MYTMP/files/"$1".spec.in || return 0 # Spec file is optional
131 sed -n -e '1,/^%changelog/d' -e '/^*/{' -e 's/.*- \([0-9].*\)/\1/p' -e q -e '}' "$1".spec.in
135 local maj min fix sfx IFS=.-_
143 eval $maj=\$1 $min=\$2 $fix=\$3 $sfx=\$4
148 [0-9]*.[0-9]*.[0-9]*_*)
149 # x.y.z_ZZZZ = development branch (can be before or after pre/rc)
152 [0-9]*.[0-9]*.[0-9]-pre[0-9]*)
155 [0-9]*.[0-9]*.[0-9]-rc.[0-9]*)
158 [0-9]*.[0-9]*.[0-9]*)
169 local status=0 exact=0 prerelease=0
171 if [ -f $MYTMP/version-checked ]
173 read status < $MYTMP/version-checked
177 local confver=`get_configure_ac_version`
178 case "$(match_version $confver)" in
182 prerelease|candidate|release)
186 echo "Unrecognised version in configure.ac ($confver)"
191 local clogver=`get_changelog_version`
192 case "$(match_version $clogver)" in
194 echo "Do not include development branch version in ChangeLog ($clogver)"
197 prerelease|candidate)
204 echo "Unrecognised version format in ChangeLog ($clogver)"
209 local package=`get_configure_ac_package`
210 local specver=`get_spec_version $package`
212 local clogmaj clogmin clogfix clogsfx
213 local confmaj confmin conffix confsfx
214 local specmaj specmin specfix specsfx
216 splitver clogmaj clogmin clogfix clogsfx "$clogver"
217 splitver confmaj confmin conffix confsfx "$confver"
218 splitver specmaj specmin specfix specsfx "$specver"
222 if [ $specmaj -ne $clogmaj \
223 -o $specmin -ne $clogmin \
224 -o $specfix -ne $clogfix ]
226 echo "Main version of $package.spec.in ($specver) differs from ChangeLog ($clogver)"
231 if [ $status -eq 0 -a $exact -eq 0 ]
234 if [ $confmaj -gt $clogmaj \
235 -o $confmin -gt $clogmin \
236 -o $conffix -gt $clogfix ]
239 elif [ $confmaj -eq $clogmaj \
240 -a $confmin -eq $clogmin \
241 -a $conffix -eq $clogfix \
242 -a $prerelease -eq 1 ]
246 echo "Version in configure.ac ($confver) lesser than ChangeLog ($clogver)"
253 echo "Running additional release checks"
255 if [ "$confver" != "$clogver" ]
257 echo "Version in configure.ac ($confver) differs from ChangeLog ($clogver)"
263 local confrpmrel=`get_configure_ac_rpmrel`
264 if [ "$specsfx" != "$confrpmrel" ]
266 echo "%changelog suffix in $package.spec.in ($specsfx) differs from configure.ac PACKAGE_RPM_RELEASE ($confrpmrel)"
271 if [ ! "$TRAVIS_TAG" ]
273 if [ "$(git tag -l v$confver)" ]
275 echo "Tag v$confver already exists"
279 if [ "$(git config user.signingkey)" = "" ]
281 echo "You need to set up a PGP signing key e.g.:"
282 echo " gpg --list-keys"
284 echo " git config user.signingkey SHORTID"
286 echo " git config --global user.signingkey SHORTID"
290 git status -s | grep "^?" > $MYTMP/needclean
291 if [ -s $MYTMP/needclean ]
293 echo "The following files must be dealt with before commit:"
295 echo "e.g. add them to .gitignore or remove with 'git clean -fdx'"
301 echo $status > $MYTMP/version-checked
308 if [ -f $MYTMP/changelog-checked ]
310 read status < $MYTMP/changelog-checked
314 local version=`sed -ne '1s/.*(\(.*\)).*/\1/p' $filename`
315 if [ "`echo $version | grep '[[:space:]]'`" != "" ]
317 echo "ChangeLog version contains whitespace! Fix it!"
321 echo $status > $MYTMP/changelog-checked