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_\(MINOR\|FIX\)/s/.*\[\([^[]*\)\].*/.\1/p' \
106 -e '/define(\[VERSION_\(MAJOR\|SUFFIX\)/s/.*\[\([^[]*\)\].*/\1/p' \
107 $MYTMP/files/configure.ac | tr -d '\n'`
108 if [ ! "$v" ]; then v="No version in configure.ac!"; fi
112 get_configure_ac_package() {
113 get_staged_file configure.ac
114 local v=`sed -n -e 's/AC_INIT(\[\([^]]*\)\].*/\1/p' configure.ac`
115 if [ ! "$v" ]; then v="noname"; fi
119 get_configure_ac_rpmrel() {
120 get_staged_file configure.ac
121 local v=`sed -n -e 's/PACKAGE_RPM_RELEASE="\([^"]*\)".*/\1/p' configure.ac`
122 if [ ! "$v" ]; then v="norpmrel"; fi
127 get_staged_file "$1".spec.in
128 test -f $MYTMP/files/"$1".spec.in || return 0 # Spec file is optional
129 sed -n -e '1,/^%changelog/d' -e '/^*/{s/.*- \([0-9].*\)/\1/p;q}' "$1".spec.in
133 local maj min fix sfx IFS=.-_
141 eval $maj=\$1 $min=\$2 $fix=\$3 $sfx=\$4
146 [0-9]*.[0-9]*.[0-9]*_*)
147 # x.y.z_ZZZZ = development branch (can be before or after pre/rc)
150 [0-9]*.[0-9]*.[0-9]-pre[0-9]*)
153 [0-9]*.[0-9]*.[0-9]-rc.[0-9]*)
156 [0-9]*.[0-9]*.[0-9]*)
167 local status=0 exact=0 prerelease=0
169 if [ -f $MYTMP/version-checked ]
171 read status < $MYTMP/version-checked
175 local confver=`get_configure_ac_version`
176 case "$(match_version $confver)" in
180 prerelease|candidate|release)
184 echo "Unrecognised version in configure.ac ($confver)"
189 local clogver=`get_changelog_version`
190 case "$(match_version $clogver)" in
192 echo "Do not include development branch version in ChangeLog ($clogver)"
195 prerelease|candidate)
202 echo "Unrecognised version format in ChangeLog ($clogver)"
207 local package=`get_configure_ac_package`
208 local specver=`get_spec_version $package`
210 local clogmaj clogmin clogfix clogsfx
211 local confmaj confmin conffix confsfx
212 local specmaj specmin specfix specsfx
214 splitver clogmaj clogmin clogfix clogsfx "$clogver"
215 splitver confmaj confmin conffix confsfx "$confver"
216 splitver specmaj specmin specfix specsfx "$specver"
220 if [ $specmaj -ne $clogmaj \
221 -o $specmin -ne $clogmin \
222 -o $specfix -ne $clogfix ]
224 echo "Main version of $package.spec.in ($specver) differs from ChangeLog ($clogver)"
229 if [ $status -eq 0 -a $exact -eq 0 ]
232 if [ $confmaj -gt $clogmaj \
233 -o $confmin -gt $clogmin \
234 -o $conffix -gt $clogfix ]
237 elif [ $confmaj -eq $clogmaj \
238 -a $confmin -eq $clogmin \
239 -a $conffix -eq $clogfix \
240 -a $prerelease -eq 1 ]
244 echo "Version in configure.ac ($confver) lesser than ChangeLog ($clogver)"
251 echo "Running additional release checks"
253 if [ "$confver" != "$clogver" ]
255 echo "Version in configure.ac ($confver) differs from ChangeLog ($clogver)"
257 elif [ "$(git tag -l v$confver)" ]
259 echo "Tag v$confver already exists"
265 local confrpmrel=`get_configure_ac_rpmrel`
266 if [ "$specsfx" != "$confrpmrel" ]
268 echo "%changelog suffix in $package.spec.in ($specsfx) differs from configure.ac PACKAGE_RPM_RELEASE ($confrpmrel)"
273 if [ "$(git config user.signingkey)" = "" ]
275 echo "You need to set up a PGP signing key e.g.:"
276 echo " gpg --list-keys"
278 echo " git config user.signingkey SHORTID"
280 echo " git config --global user.signingkey SHORTID"
284 git status -s | grep "^?" > $MYTMP/needclean
285 if [ -s $MYTMP/needclean ]
287 echo "The following files must be dealt with before commit:"
289 echo "e.g. add them to .gitignore or remove with 'git clean -fdx'"
294 echo $status > $MYTMP/version-checked
301 if [ -f $MYTMP/changelog-checked ]
303 read status < $MYTMP/changelog-checked
307 local version=`sed -ne '1s/.*(\(.*\)).*/\1/p' $filename`
308 if [ "`echo $version | grep '[[:space:]]'`" != "" ]
310 echo "ChangeLog version contains whitespace! Fix it!"
314 echo $status > $MYTMP/changelog-checked