##// END OF EJS Templates
py3kcompat: added a "compatibility layer" for py3k...
py3kcompat: added a "compatibility layer" for py3k This patch adds some ugly constructs. The first of them is bytesformatter, a function that formats strings like when '%' is called. The main motivation for this function is py3k's strange behavior: >>> 'foo %s' % b'bar' "foo b'bar'" >>> b'foo %s' % b'bar' Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for %: 'bytes' and 'bytes' >>> b'foo %s' % 'bar' Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for %: 'bytes' and 'str' In other words, if we can't format bytes with bytes, and recall that all mercurial strings will be converted by a fixer, then things will break badly if we don't take a similar approach. The other addition with this patch is that the os.environ dictionary is monkeypatched to have bytes items. Hopefully this won't be needed in the future, as python 3.2 might get a os.environb dictionary that holds bytes items.

File last commit:

r9814:5070e4d5 default
r11748:37a70a78 default
Show More
buildrpm
110 lines | 2.8 KiB | text/plain | TextLexer
mpm@selenic.com
[PATCH] Add contrib/buildrpm script...
r564 #!/bin/sh
#
# Build a Mercurial RPM in place.
#
Mads Kiilerich
contrib/buildrpm: Support python 2.4 and 2.6
r8867 # Tested on
Gilles Moris
buildrpm: cleanup script
r9812 # - Fedora 8 (with docutils 0.5)
Mads Kiilerich
contrib/buildrpm: Support python 2.4 and 2.6
r8867 # - Fedora 11
Gilles Moris
buildrpm: cleanup script
r9812 # - OpenSuse 11.2
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
mpm@selenic.com
[PATCH] Add contrib/buildrpm script...
r564 specfile=contrib/mercurial.spec
Gilles Moris
buildrpm: cleanup script
r9812 if [ ! -f $specfile ]; then
echo "Cannot find $specfile!" 1>&2
exit 1
fi
mpm@selenic.com
[PATCH] Add contrib/buildrpm script...
r564
Gilles Moris
buildrpm: cleanup script
r9812 if [ ! -d .hg ]; then
mpm@selenic.com
[PATCH] Add contrib/buildrpm script...
r564 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
Gilles Moris
buildrpm: cleanup script
r9812 rpmdir="$PWD/rpmbuild"
mpm@selenic.com
[PATCH] Add contrib/buildrpm script...
r564
rm -rf $rpmdir
Gilles Moris
buildrpm: build full RPM package including sources
r9813 mkdir -p $rpmdir/SOURCES $rpmdir/SPECS $rpmdir/RPMS $rpmdir/SRPMS $rpmdir/BUILD
mpm@selenic.com
[PATCH] Add contrib/buildrpm script...
r564
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
mpm@selenic.com
[PATCH] Add contrib/buildrpm script...
r564
Gilles Moris
buildrpm: build full RPM package including sources
r9813 $HG archive -t tgz $rpmdir/SOURCES/mercurial-$version.tar.gz
rpmspec=$rpmdir/SPECS/mercurial-$version.spec
Gilles Moris
buildrpm: cleanup script
r9812 sed -e "s,^Version:.*,Version: $version," \
mpm@selenic.com
[PATCH] Add contrib/buildrpm script...
r564 -e "s,^Release:.*,Release: $release," \
Gilles Moris
buildrpm: build full RPM package including sources
r9813 $specfile > $rpmspec
mpm@selenic.com
[PATCH] Add contrib/buildrpm script...
r564
Gilles Moris
buildrpm: enhance changelog of the RPM file...
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
buildrpm: auto-generate %changelog in .spec file...
r4754
Gilles Moris
buildrpm: enhance changelog of the RPM file...
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
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
buildrpm: auto-generate %changelog in .spec file...
r4754
Gilles Moris
buildrpm: build full RPM package including sources
r9813 rpmbuild --define "_topdir $rpmdir" -ba $rpmspec --clean
mpm@selenic.com
[PATCH] Add contrib/buildrpm script...
r564 if [ $? = 0 ]; then
echo
Mads Kiilerich
Make contrib/buildrpm work on Fedora 9....
r7277 echo "Packages are in $rpmdir:"
Gilles Moris
buildrpm: build full RPM package including sources
r9813 ls -l $rpmdir/*RPMS/*
mpm@selenic.com
[PATCH] Add contrib/buildrpm script...
r564 fi