comparison contrib/buildrpm @ 9813:2059795bb5d0

buildrpm: build full RPM package including sources
author Gilles Moris <gilles.moris@free.fr>
date Fri, 06 Nov 2009 09:59:55 +0100
parents dd2c95fc4fe5
children 5070e4d57276
comparison
equal deleted inserted replaced
9812:dd2c95fc4fe5 9813:2059795bb5d0
32 fi 32 fi
33 33
34 rpmdir="$PWD/rpmbuild" 34 rpmdir="$PWD/rpmbuild"
35 35
36 rm -rf $rpmdir 36 rm -rf $rpmdir
37 mkdir -p $rpmdir/RPMS 37 mkdir -p $rpmdir/SOURCES $rpmdir/SPECS $rpmdir/RPMS $rpmdir/SRPMS $rpmdir/BUILD
38 $HG clone -u . . $rpmdir/BUILD
39 38
40 tmpspec=/tmp/`basename "$specfile"`.$$ # FIXME: Insecure /tmp handling
41 # make setup.py build the version string 39 # make setup.py build the version string
42 python setup.py build_py -c -d . 40 python setup.py build_py -c -d .
43 hgversion=`$HG version | sed -ne 's/.*(version \(.*\))$/\1/p'` 41 hgversion=`$HG version | sed -ne 's/.*(version \(.*\))$/\1/p'`
44 42
45 if echo $hgversion | grep -- '-' > /dev/null 2>&1; then 43 if echo $hgversion | grep -- '-' > /dev/null 2>&1; then
50 # official tag, version is like 1.3.1 48 # official tag, version is like 1.3.1
51 version=`echo $hgversion | sed -e 's/+.*//'` 49 version=`echo $hgversion | sed -e 's/+.*//'`
52 release='0' 50 release='0'
53 fi 51 fi
54 52
53 $HG archive -t tgz $rpmdir/SOURCES/mercurial-$version.tar.gz
54 rpmspec=$rpmdir/SPECS/mercurial-$version.spec
55
55 sed -e "s,^Version:.*,Version: $version," \ 56 sed -e "s,^Version:.*,Version: $version," \
56 -e "s,^Release:.*,Release: $release," \ 57 -e "s,^Release:.*,Release: $release," \
57 -e "s,^%prep.*,\n\0," \ 58 $specfile > $rpmspec
58 -e 's,^%setup.*,,' \
59 $specfile > $tmpspec
60 59
61 cat <<EOF >> $tmpspec 60 cat <<EOF >> $rpmspec
62 %changelog 61 %changelog
63 * `LANG=en_US date +'%a %b %d %Y'` `$HG showconfig ui.username` $version-$release 62 * `LANG=en_US date +'%a %b %d %Y'` `$HG showconfig ui.username` $version-$release
64 - Automatically built via $0 63 - Automatically built via $0
65 64
66 EOF 65 EOF
67 $HG log \ 66 $HG log \
68 --template '* {date|rfc822date} {author}\n- {desc|firstline}\n\n' \ 67 --template '* {date|rfc822date} {author}\n- {desc|firstline}\n\n' \
69 .hgtags \ 68 .hgtags \
70 | sed -e 's/^\(\* [MTWFS][a-z][a-z]\), \([0-3][0-9]\) \([A-Z][a-z][a-z]\) /\1 \3 \2 /' \ 69 | sed -e 's/^\(\* [MTWFS][a-z][a-z]\), \([0-3][0-9]\) \([A-Z][a-z][a-z]\) /\1 \3 \2 /' \
71 -e '/^\* [MTWFS][a-z][a-z] /{s/ [012][0-9]:[0-9][0-9]:[0-9][0-9] [+-][0-9]\{4\}//}' \ 70 -e '/^\* [MTWFS][a-z][a-z] /{s/ [012][0-9]:[0-9][0-9]:[0-9][0-9] [+-][0-9]\{4\}//}' \
72 >> $tmpspec 71 >> $rpmspec
73 72
74 rpmbuild --define "_topdir $rpmdir" -bb $tmpspec --clean 73 rpmbuild --define "_topdir $rpmdir" -ba $rpmspec --clean
75 if [ $? = 0 ]; then 74 if [ $? = 0 ]; then
76 mv $rpmdir/RPMS/*/* $rpmdir && rm -r $rpmdir/RPMS
77 echo 75 echo
78 echo "Packages are in $rpmdir:" 76 echo "Packages are in $rpmdir:"
79 ls -l $rpmdir/*.rpm 77 ls -l $rpmdir/*RPMS/*
80 fi 78 fi