##// END OF EJS Templates
buildrpm: enable to start the script from anywhere...
buildrpm: enable to start the script from anywhere Previously the script worked only from the hg root.

File last commit:

r9811:c92ac5a5 default
r9811:c92ac5a5 default
Show More
buildrpm
89 lines | 2.3 KiB | text/plain | TextLexer
mpm@selenic.com
[PATCH] Add contrib/buildrpm script...
r564 #!/bin/sh
#
# Build a Mercurial RPM in place.
#
# Bryan O'Sullivan <bos@serpentine.com>
Mads Kiilerich
contrib/buildrpm: Support python 2.4 and 2.6
r8867 #
# Tested on
# - Fedora 10
# - Fedora 11
# - Centos 5.3 (with Fedora EPEL repo for asciidoc)
mpm@selenic.com
[PATCH] Add contrib/buildrpm script...
r564
Gilles Moris
buildrpm: enable to start the script from anywhere...
r9811 cd "`dirname $0`/.."
HG="$PWD/hg"
PYTHONPATH="$PWD/mercurial/pure"
Mads Kiilerich
contrib/buildrpm: Don't require installed hg, use local hg with pure extensions
r8869 export PYTHONPATH
Mads Kiilerich
buildrpm: complain when hg command isn't available...
r7431
Mads Kiilerich
contrib/buildrpm: Don't require installed hg, use local hg with pure extensions
r8869 root="`$HG root 2>/dev/null`"
mpm@selenic.com
[PATCH] Add contrib/buildrpm script...
r564 specfile=contrib/mercurial.spec
if [ -z "$root" ]; then
echo 'You are not inside a Mercurial repository!' 1>&2
exit 1
fi
Gilles Moris
buildrpm: warn if there is outstanding uncommitted changes
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
Mads Kiilerich
Make contrib/buildrpm work on Fedora 9....
r7277 rpmdir=/tmp/"`basename $root | sed 's/ /_/'`"-rpm # FIXME: Insecure /tmp handling
mpm@selenic.com
[PATCH] Add contrib/buildrpm script...
r564
cd "$root"
rm -rf $rpmdir
mkdir -p $rpmdir/RPMS
Gilles Moris
buildrpm: build from working dir parent and use hg version for RPM versioning...
r9809 $HG clone -u . "$root" $rpmdir/BUILD
mpm@selenic.com
[PATCH] Add contrib/buildrpm script...
r564
if [ ! -f $specfile ]; then
echo "Cannot find $specfile!" 1>&2
exit 1
fi
Mads Kiilerich
Make contrib/buildrpm work on Fedora 9....
r7277 tmpspec=/tmp/`basename "$specfile"`.$$ # FIXME: Insecure /tmp handling
Gilles Moris
buildrpm: build from working dir parent and use hg version for RPM versioning...
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
Mads Kiilerich
contrib/buildrpm: Don't require installed hg, use local hg with pure extensions
r8869 tip=`$HG -q tip`
mpm@selenic.com
[PATCH] Add contrib/buildrpm script...
r564
# Beat up the spec file
sed -e 's,^Source:.*,Source: /dev/null,' \
-e "s,^Version:.*,Version: $version," \
-e "s,^Release:.*,Release: $release," \
-e "s,^%prep.*,Changeset: $tip\n\0," \
-e 's,^%setup.*,,' \
$specfile > $tmpspec
Adam Spiers
buildrpm: auto-generate %changelog in .spec file...
r4754 cat <<EOF >> $tmpspec
%changelog
Stefano Tortarolo
contrib/buildrpm: force en_US locale during changelog's creation...
r8906 * `LANG=en_US date +'%a %b %d %Y'` `$HG showconfig ui.username` $version-$release
Adam Spiers
buildrpm: auto-generate %changelog in .spec file...
r4754 - Automatically built via $0
EOF
Mads Kiilerich
contrib/buildrpm: Don't require installed hg, use local hg with pure extensions
r8869 $HG log \
Adam Spiers
buildrpm: auto-generate %changelog in .spec file...
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\}//}' \
>> $tmpspec
mpm@selenic.com
[PATCH] Add contrib/buildrpm script...
r564 rpmbuild --define "_topdir $rpmdir" -bb $tmpspec
if [ $? = 0 ]; then
rm -rf $tmpspec $rpmdir/BUILD
mv $rpmdir/RPMS/*/* $rpmdir && rm -r $rpmdir/RPMS
echo
Mads Kiilerich
Make contrib/buildrpm work on Fedora 9....
r7277 echo "Packages are in $rpmdir:"
ls -l $rpmdir/*.rpm
mpm@selenic.com
[PATCH] Add contrib/buildrpm script...
r564 fi