buildrpm
103 lines
| 2.6 KiB
| text/plain
|
TextLexer
/ contrib / buildrpm
Mads Kiilerich
|
r21638 | #!/bin/sh -e | ||
mpm@selenic.com
|
r564 | # | ||
Mads Kiilerich
|
r21638 | # Build a Mercurial RPM from the current repo | ||
mpm@selenic.com
|
r564 | # | ||
Mads Kiilerich
|
r8867 | # Tested on | ||
Mads Kiilerich
|
r21638 | # - Fedora 20 | ||
# - CentOS 5 | ||||
# - centOS 6 | ||||
mpm@selenic.com
|
r564 | |||
Gilles Moris
|
r9811 | cd "`dirname $0`/.." | ||
Mads Kiilerich
|
r7431 | |||
mpm@selenic.com
|
r564 | specfile=contrib/mercurial.spec | ||
Gilles Moris
|
r9812 | if [ ! -f $specfile ]; then | ||
echo "Cannot find $specfile!" 1>&2 | ||||
exit 1 | ||||
fi | ||||
mpm@selenic.com
|
r564 | |||
Gilles Moris
|
r9812 | if [ ! -d .hg ]; then | ||
mpm@selenic.com
|
r564 | echo 'You are not inside a Mercurial repository!' 1>&2 | ||
exit 1 | ||||
fi | ||||
Mads Kiilerich
|
r21639 | # build local hg and use it | ||
python setup.py build_py -c -d . | ||||
HG="$PWD/hg" | ||||
PYTHONPATH="$PWD/mercurial/pure" | ||||
export PYTHONPATH | ||||
Gilles Moris
|
r9812 | rpmdir="$PWD/rpmbuild" | ||
mpm@selenic.com
|
r564 | |||
rm -rf $rpmdir | ||||
Gilles Moris
|
r9813 | mkdir -p $rpmdir/SOURCES $rpmdir/SPECS $rpmdir/RPMS $rpmdir/SRPMS $rpmdir/BUILD | ||
mpm@selenic.com
|
r564 | |||
Gilles Moris
|
r9809 | 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 | ||||
mpm@selenic.com
|
r564 | |||
Mads Kiilerich
|
r21641 | $HG archive -t tgz $rpmdir/SOURCES/mercurial-$version-$release.tar.gz | ||
rpmspec=$rpmdir/SPECS/mercurial.spec | ||||
Gilles Moris
|
r9813 | |||
Gilles Moris
|
r9812 | sed -e "s,^Version:.*,Version: $version," \ | ||
mpm@selenic.com
|
r564 | -e "s,^Release:.*,Release: $release," \ | ||
Gilles Moris
|
r9813 | $specfile > $rpmspec | ||
mpm@selenic.com
|
r564 | |||
Gilles Moris
|
r9814 | echo >> $rpmspec | ||
echo "%changelog" >> $rpmspec | ||||
if echo $version | grep '+' > /dev/null 2>&1; then | ||||
latesttag="`echo $version | sed -e 's/+.*//'`" | ||||
$HG log -r .:"$latesttag" -fM \ | ||||
--template '{date|hgdate}\t{author}\t{desc|firstline}\n' | python -c ' | ||||
import sys, time | ||||
def datestr(date, format): | ||||
return time.strftime(format, time.gmtime(float(date[0]) - date[1])) | ||||
Adam Spiers
|
r4754 | |||
Gilles Moris
|
r9814 | changelog = [] | ||
for l in sys.stdin.readlines(): | ||||
tok = l.split("\t") | ||||
hgdate = tuple(int(v) for v in tok[0].split()) | ||||
changelog.append((datestr(hgdate, "%F"), tok[1], hgdate, tok[2])) | ||||
prevtitle = "" | ||||
for l in sorted(changelog, reverse=True): | ||||
title = "* %s %s" % (datestr(l[2], "%a %b %d %Y"), l[1]) | ||||
if prevtitle != title: | ||||
prevtitle = title | ||||
print title | ||||
print "- %s" % l[3].strip() | ||||
' >> $rpmspec | ||||
else | ||||
$HG log \ | ||||
--template '{date|hgdate}\t{author}\t{desc|firstline}\n' \ | ||||
.hgtags | python -c ' | ||||
import sys, time | ||||
def datestr(date, format): | ||||
return time.strftime(format, time.gmtime(float(date[0]) - date[1])) | ||||
for l in sys.stdin.readlines(): | ||||
tok = l.split("\t") | ||||
hgdate = tuple(int(v) for v in tok[0].split()) | ||||
print "* %s %s\n- %s" % (datestr(hgdate, "%a %b %d %Y"), tok[1], tok[2]) | ||||
' >> $rpmspec | ||||
fi | ||||
Adam Spiers
|
r4754 | |||
Gilles Moris
|
r9813 | rpmbuild --define "_topdir $rpmdir" -ba $rpmspec --clean | ||
mpm@selenic.com
|
r564 | if [ $? = 0 ]; then | ||
echo | ||||
Mads Kiilerich
|
r7277 | echo "Packages are in $rpmdir:" | ||
Gilles Moris
|
r9813 | ls -l $rpmdir/*RPMS/* | ||
mpm@selenic.com
|
r564 | fi | ||