buildrpm
149 lines
| 3.8 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 | |||
Augie Fackler
|
r24972 | . $(dirname $0)/packagelib.sh | ||
Mads Kiilerich
|
r22435 | BUILD=1 | ||
Mads Kiilerich
|
r22437 | RPMBUILDDIR="$PWD/rpmbuild" | ||
Mads Kiilerich
|
r22435 | while [ "$1" ]; do | ||
case "$1" in | ||||
--prepare ) | ||||
shift | ||||
BUILD= | ||||
;; | ||||
Mads Kiilerich
|
r22436 | --withpython | --with-python) | ||
shift | ||||
Mads Kiilerich
|
r23881 | PYTHONVER=2.7.9 | ||
PYTHONMD5=5eebcaa0030dc4061156d3429657fb83 | ||||
Mads Kiilerich
|
r22436 | ;; | ||
Mads Kiilerich
|
r22437 | --rpmbuilddir ) | ||
shift | ||||
RPMBUILDDIR="$1" | ||||
shift | ||||
;; | ||||
Mads Kiilerich
|
r22435 | * ) | ||
echo "Invalid parameter $1!" 1>&2 | ||||
exit 1 | ||||
;; | ||||
esac | ||||
done | ||||
Gilles Moris
|
r9811 | cd "`dirname $0`/.." | ||
Mads Kiilerich
|
r7431 | |||
Mads Kiilerich
|
r22436 | specfile=$PWD/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 | ||||
Augie Fackler
|
r24972 | gethgversion | ||
Gilles Moris
|
r9809 | |||
Mads Kiilerich
|
r22436 | if [ "$PYTHONVER" ]; then | ||
release=$release+$PYTHONVER | ||||
RPMPYTHONVER=$PYTHONVER | ||||
else | ||||
RPMPYTHONVER=%{nil} | ||||
fi | ||||
mpm@selenic.com
|
r564 | |||
Augie Fackler
|
r26139 | mkdir -p $RPMBUILDDIR/SOURCES | ||
Mads Kiilerich
|
r22437 | $HG archive -t tgz $RPMBUILDDIR/SOURCES/mercurial-$version-$release.tar.gz | ||
Mads Kiilerich
|
r22436 | if [ "$PYTHONVER" ]; then | ||
( | ||||
Mads Kiilerich
|
r24730 | mkdir -p build | ||
Mads Kiilerich
|
r22436 | cd build | ||
PYTHON_SRCFILE=Python-$PYTHONVER.tgz | ||||
[ -f $PYTHON_SRCFILE ] || curl -Lo $PYTHON_SRCFILE http://www.python.org/ftp/python/$PYTHONVER/$PYTHON_SRCFILE | ||||
Mads Kiilerich
|
r23141 | if [ "$PYTHONMD5" ]; then | ||
echo "$PYTHONMD5 $PYTHON_SRCFILE" | md5sum -w -c | ||||
fi | ||||
Mads Kiilerich
|
r22437 | ln -f $PYTHON_SRCFILE $RPMBUILDDIR/SOURCES/$PYTHON_SRCFILE | ||
Mads Kiilerich
|
r22436 | |||
DOCUTILSVER=`sed -ne "s/^%global docutilsname docutils-//p" $specfile` | ||||
DOCUTILS_SRCFILE=docutils-$DOCUTILSVER.tar.gz | ||||
[ -f $DOCUTILS_SRCFILE ] || curl -Lo $DOCUTILS_SRCFILE http://downloads.sourceforge.net/project/docutils/docutils/$DOCUTILSVER/$DOCUTILS_SRCFILE | ||||
Mads Kiilerich
|
r23141 | DOCUTILSMD5=`sed -ne "s/^%global docutilsmd5 //p" $specfile` | ||
if [ "$DOCUTILSMD5" ]; then | ||||
echo "$DOCUTILSMD5 $DOCUTILS_SRCFILE" | md5sum -w -c | ||||
fi | ||||
Mads Kiilerich
|
r22437 | ln -f $DOCUTILS_SRCFILE $RPMBUILDDIR/SOURCES/$DOCUTILS_SRCFILE | ||
Mads Kiilerich
|
r22436 | ) | ||
fi | ||||
Augie Fackler
|
r26139 | mkdir -p $RPMBUILDDIR/SPECS | ||
Mads Kiilerich
|
r22437 | rpmspec=$RPMBUILDDIR/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 | |||
Mads Kiilerich
|
r22436 | sed -i \ | ||
-e "s/^%define withpython.*$/%define withpython $RPMPYTHONVER/" \ | ||||
$rpmspec | ||||
Mads Kiilerich
|
r22435 | if [ "$BUILD" ]; then | ||
Mads Kiilerich
|
r22437 | rpmbuild --define "_topdir $RPMBUILDDIR" -ba $rpmspec --clean | ||
Mads Kiilerich
|
r22435 | if [ $? = 0 ]; then | ||
echo | ||||
echo "Built packages for $version-$release:" | ||||
Mads Kiilerich
|
r22437 | find $RPMBUILDDIR/*RPMS/ -type f -newer $rpmspec | ||
Mads Kiilerich
|
r22435 | fi | ||
else | ||||
Mads Kiilerich
|
r22437 | echo "Prepared sources for $version-$release $rpmspec are in $RPMBUILDDIR/SOURCES/ - use like:" | ||
echo "rpmbuild --define '_topdir $RPMBUILDDIR' -ba $rpmspec --clean" | ||||
mpm@selenic.com
|
r564 | fi | ||