buildrpm
78 lines
| 2.0 KiB
| text/plain
|
TextLexer
/ contrib / buildrpm
|
r564 | #!/bin/sh | ||
# | ||||
# Build a Mercurial RPM in place. | ||||
# | ||||
|
r8867 | # Tested on | ||
|
r9812 | # - Fedora 8 (with docutils 0.5) | ||
|
r8867 | # - Fedora 11 | ||
|
r9812 | # - OpenSuse 11.2 | ||
|
r564 | |||
|
r9811 | cd "`dirname $0`/.." | ||
HG="$PWD/hg" | ||||
PYTHONPATH="$PWD/mercurial/pure" | ||||
|
r8869 | export PYTHONPATH | ||
|
r7431 | |||
|
r564 | specfile=contrib/mercurial.spec | ||
|
r9812 | if [ ! -f $specfile ]; then | ||
echo "Cannot find $specfile!" 1>&2 | ||||
exit 1 | ||||
fi | ||||
|
r564 | |||
|
r9812 | if [ ! -d .hg ]; then | ||
|
r564 | echo 'You are not inside a Mercurial repository!' 1>&2 | ||
exit 1 | ||||
fi | ||||
|
r9810 | if $HG id -i | grep '+$' > /dev/null 2>&1; then | ||
echo -n "Your local changes will NOT be in the RPM. Continue [y/n] ? " | ||||
read answer | ||||
if echo $answer | grep -iv '^y'; then | ||||
exit | ||||
fi | ||||
fi | ||||
|
r9812 | rpmdir="$PWD/rpmbuild" | ||
|
r564 | |||
rm -rf $rpmdir | ||||
|
r9813 | mkdir -p $rpmdir/SOURCES $rpmdir/SPECS $rpmdir/RPMS $rpmdir/SRPMS $rpmdir/BUILD | ||
|
r564 | |||
|
r9809 | # make setup.py build the version string | ||
python setup.py build_py -c -d . | ||||
hgversion=`$HG version | sed -ne 's/.*(version \(.*\))$/\1/p'` | ||||
if echo $hgversion | grep -- '-' > /dev/null 2>&1; then | ||||
# nightly build case, version is like 1.3.1+250-20b91f91f9ca | ||||
version=`echo $hgversion | cut -d- -f1` | ||||
release=`echo $hgversion | cut -d- -f2 | sed -e 's/+.*//'` | ||||
else | ||||
# official tag, version is like 1.3.1 | ||||
version=`echo $hgversion | sed -e 's/+.*//'` | ||||
release='0' | ||||
fi | ||||
|
r564 | |||
|
r9813 | $HG archive -t tgz $rpmdir/SOURCES/mercurial-$version.tar.gz | ||
rpmspec=$rpmdir/SPECS/mercurial-$version.spec | ||||
|
r9812 | sed -e "s,^Version:.*,Version: $version," \ | ||
|
r564 | -e "s,^Release:.*,Release: $release," \ | ||
|
r9813 | $specfile > $rpmspec | ||
|
r564 | |||
|
r9813 | cat <<EOF >> $rpmspec | ||
|
r4754 | %changelog | ||
|
r8906 | * `LANG=en_US date +'%a %b %d %Y'` `$HG showconfig ui.username` $version-$release | ||
|
r4754 | - Automatically built via $0 | ||
EOF | ||||
|
r8869 | $HG log \ | ||
|
r4754 | --template '* {date|rfc822date} {author}\n- {desc|firstline}\n\n' \ | ||
.hgtags \ | ||||
| sed -e 's/^\(\* [MTWFS][a-z][a-z]\), \([0-3][0-9]\) \([A-Z][a-z][a-z]\) /\1 \3 \2 /' \ | ||||
-e '/^\* [MTWFS][a-z][a-z] /{s/ [012][0-9]:[0-9][0-9]:[0-9][0-9] [+-][0-9]\{4\}//}' \ | ||||
|
r9813 | >> $rpmspec | ||
|
r4754 | |||
|
r9813 | rpmbuild --define "_topdir $rpmdir" -ba $rpmspec --clean | ||
|
r564 | if [ $? = 0 ]; then | ||
echo | ||||
|
r7277 | echo "Packages are in $rpmdir:" | ||
|
r9813 | ls -l $rpmdir/*RPMS/* | ||
|
r564 | fi | ||