author | Mads Kiilerich <madski@unity3d.com> |
Tue, 14 Apr 2015 23:51:02 -0400 | |
changeset 24730 | aa8e5c6d953b |
parent 23881 | 33471119267b |
child 24972 | 56c64c91b429 |
permissions | -rwxr-xr-x |
21638
5337cb17fa1f
buildrpm: various minor cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
9814
diff
changeset
|
1 |
#!/bin/sh -e |
564 | 2 |
# |
21638
5337cb17fa1f
buildrpm: various minor cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
9814
diff
changeset
|
3 |
# Build a Mercurial RPM from the current repo |
564 | 4 |
# |
8867
ff817723280a
contrib/buildrpm: Support python 2.4 and 2.6
Mads Kiilerich <mads@kiilerich.com>
parents:
7431
diff
changeset
|
5 |
# Tested on |
21638
5337cb17fa1f
buildrpm: various minor cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
9814
diff
changeset
|
6 |
# - Fedora 20 |
5337cb17fa1f
buildrpm: various minor cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
9814
diff
changeset
|
7 |
# - CentOS 5 |
5337cb17fa1f
buildrpm: various minor cleanup
Mads Kiilerich <madski@unity3d.com>
parents:
9814
diff
changeset
|
8 |
# - centOS 6 |
564 | 9 |
|
22435
4c4385eb26bc
buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents:
21641
diff
changeset
|
10 |
BUILD=1 |
22437
9e2e4fc524fd
buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents:
22436
diff
changeset
|
11 |
RPMBUILDDIR="$PWD/rpmbuild" |
22435
4c4385eb26bc
buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents:
21641
diff
changeset
|
12 |
while [ "$1" ]; do |
4c4385eb26bc
buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents:
21641
diff
changeset
|
13 |
case "$1" in |
4c4385eb26bc
buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents:
21641
diff
changeset
|
14 |
--prepare ) |
4c4385eb26bc
buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents:
21641
diff
changeset
|
15 |
shift |
4c4385eb26bc
buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents:
21641
diff
changeset
|
16 |
BUILD= |
4c4385eb26bc
buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents:
21641
diff
changeset
|
17 |
;; |
22436
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
18 |
--withpython | --with-python) |
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
19 |
shift |
23881
33471119267b
rpm: make Python 2.7.9 the default Python to include in rpms for EL 5
Mads Kiilerich <madski@unity3d.com>
parents:
23141
diff
changeset
|
20 |
PYTHONVER=2.7.9 |
33471119267b
rpm: make Python 2.7.9 the default Python to include in rpms for EL 5
Mads Kiilerich <madski@unity3d.com>
parents:
23141
diff
changeset
|
21 |
PYTHONMD5=5eebcaa0030dc4061156d3429657fb83 |
22436
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
22 |
;; |
22437
9e2e4fc524fd
buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents:
22436
diff
changeset
|
23 |
--rpmbuilddir ) |
9e2e4fc524fd
buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents:
22436
diff
changeset
|
24 |
shift |
9e2e4fc524fd
buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents:
22436
diff
changeset
|
25 |
RPMBUILDDIR="$1" |
9e2e4fc524fd
buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents:
22436
diff
changeset
|
26 |
shift |
9e2e4fc524fd
buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents:
22436
diff
changeset
|
27 |
;; |
22435
4c4385eb26bc
buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents:
21641
diff
changeset
|
28 |
* ) |
4c4385eb26bc
buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents:
21641
diff
changeset
|
29 |
echo "Invalid parameter $1!" 1>&2 |
4c4385eb26bc
buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents:
21641
diff
changeset
|
30 |
exit 1 |
4c4385eb26bc
buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents:
21641
diff
changeset
|
31 |
;; |
4c4385eb26bc
buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents:
21641
diff
changeset
|
32 |
esac |
4c4385eb26bc
buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents:
21641
diff
changeset
|
33 |
done |
4c4385eb26bc
buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents:
21641
diff
changeset
|
34 |
|
9811
c92ac5a56f69
buildrpm: enable to start the script from anywhere
Gilles Moris <gilles.moris@free.fr>
parents:
9810
diff
changeset
|
35 |
cd "`dirname $0`/.." |
7431
3d827cc616b6
buildrpm: complain when hg command isn't available
Mads Kiilerich <mads@kiilerich.com>
parents:
7277
diff
changeset
|
36 |
|
22436
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
37 |
specfile=$PWD/contrib/mercurial.spec |
9812
dd2c95fc4fe5
buildrpm: cleanup script
Gilles Moris <gilles.moris@free.fr>
parents:
9811
diff
changeset
|
38 |
if [ ! -f $specfile ]; then |
dd2c95fc4fe5
buildrpm: cleanup script
Gilles Moris <gilles.moris@free.fr>
parents:
9811
diff
changeset
|
39 |
echo "Cannot find $specfile!" 1>&2 |
dd2c95fc4fe5
buildrpm: cleanup script
Gilles Moris <gilles.moris@free.fr>
parents:
9811
diff
changeset
|
40 |
exit 1 |
dd2c95fc4fe5
buildrpm: cleanup script
Gilles Moris <gilles.moris@free.fr>
parents:
9811
diff
changeset
|
41 |
fi |
564 | 42 |
|
9812
dd2c95fc4fe5
buildrpm: cleanup script
Gilles Moris <gilles.moris@free.fr>
parents:
9811
diff
changeset
|
43 |
if [ ! -d .hg ]; then |
564 | 44 |
echo 'You are not inside a Mercurial repository!' 1>&2 |
45 |
exit 1 |
|
46 |
fi |
|
47 |
||
21639
57e0f053e529
buildrpm: collect code for building local hg and using it in one place
Mads Kiilerich <madski@unity3d.com>
parents:
21638
diff
changeset
|
48 |
# build local hg and use it |
57e0f053e529
buildrpm: collect code for building local hg and using it in one place
Mads Kiilerich <madski@unity3d.com>
parents:
21638
diff
changeset
|
49 |
python setup.py build_py -c -d . |
57e0f053e529
buildrpm: collect code for building local hg and using it in one place
Mads Kiilerich <madski@unity3d.com>
parents:
21638
diff
changeset
|
50 |
HG="$PWD/hg" |
57e0f053e529
buildrpm: collect code for building local hg and using it in one place
Mads Kiilerich <madski@unity3d.com>
parents:
21638
diff
changeset
|
51 |
PYTHONPATH="$PWD/mercurial/pure" |
57e0f053e529
buildrpm: collect code for building local hg and using it in one place
Mads Kiilerich <madski@unity3d.com>
parents:
21638
diff
changeset
|
52 |
export PYTHONPATH |
57e0f053e529
buildrpm: collect code for building local hg and using it in one place
Mads Kiilerich <madski@unity3d.com>
parents:
21638
diff
changeset
|
53 |
|
22437
9e2e4fc524fd
buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents:
22436
diff
changeset
|
54 |
mkdir -p $RPMBUILDDIR/SOURCES $RPMBUILDDIR/SPECS $RPMBUILDDIR/RPMS $RPMBUILDDIR/SRPMS $RPMBUILDDIR/BUILD |
564 | 55 |
|
9809
ce145bf2ca5e
buildrpm: build from working dir parent and use hg version for RPM versioning
Gilles Moris <gilles.moris@free.fr>
parents:
8906
diff
changeset
|
56 |
hgversion=`$HG version | sed -ne 's/.*(version \(.*\))$/\1/p'` |
ce145bf2ca5e
buildrpm: build from working dir parent and use hg version for RPM versioning
Gilles Moris <gilles.moris@free.fr>
parents:
8906
diff
changeset
|
57 |
|
ce145bf2ca5e
buildrpm: build from working dir parent and use hg version for RPM versioning
Gilles Moris <gilles.moris@free.fr>
parents:
8906
diff
changeset
|
58 |
if echo $hgversion | grep -- '-' > /dev/null 2>&1; then |
ce145bf2ca5e
buildrpm: build from working dir parent and use hg version for RPM versioning
Gilles Moris <gilles.moris@free.fr>
parents:
8906
diff
changeset
|
59 |
# nightly build case, version is like 1.3.1+250-20b91f91f9ca |
ce145bf2ca5e
buildrpm: build from working dir parent and use hg version for RPM versioning
Gilles Moris <gilles.moris@free.fr>
parents:
8906
diff
changeset
|
60 |
version=`echo $hgversion | cut -d- -f1` |
ce145bf2ca5e
buildrpm: build from working dir parent and use hg version for RPM versioning
Gilles Moris <gilles.moris@free.fr>
parents:
8906
diff
changeset
|
61 |
release=`echo $hgversion | cut -d- -f2 | sed -e 's/+.*//'` |
ce145bf2ca5e
buildrpm: build from working dir parent and use hg version for RPM versioning
Gilles Moris <gilles.moris@free.fr>
parents:
8906
diff
changeset
|
62 |
else |
ce145bf2ca5e
buildrpm: build from working dir parent and use hg version for RPM versioning
Gilles Moris <gilles.moris@free.fr>
parents:
8906
diff
changeset
|
63 |
# official tag, version is like 1.3.1 |
ce145bf2ca5e
buildrpm: build from working dir parent and use hg version for RPM versioning
Gilles Moris <gilles.moris@free.fr>
parents:
8906
diff
changeset
|
64 |
version=`echo $hgversion | sed -e 's/+.*//'` |
ce145bf2ca5e
buildrpm: build from working dir parent and use hg version for RPM versioning
Gilles Moris <gilles.moris@free.fr>
parents:
8906
diff
changeset
|
65 |
release='0' |
ce145bf2ca5e
buildrpm: build from working dir parent and use hg version for RPM versioning
Gilles Moris <gilles.moris@free.fr>
parents:
8906
diff
changeset
|
66 |
fi |
22436
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
67 |
if [ "$PYTHONVER" ]; then |
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
68 |
release=$release+$PYTHONVER |
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
69 |
RPMPYTHONVER=$PYTHONVER |
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
70 |
else |
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
71 |
RPMPYTHONVER=%{nil} |
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
72 |
fi |
564 | 73 |
|
22437
9e2e4fc524fd
buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents:
22436
diff
changeset
|
74 |
$HG archive -t tgz $RPMBUILDDIR/SOURCES/mercurial-$version-$release.tar.gz |
22436
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
75 |
if [ "$PYTHONVER" ]; then |
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
76 |
( |
24730
aa8e5c6d953b
rpms: create missing builds dir if it doesn't exist
Mads Kiilerich <madski@unity3d.com>
parents:
23881
diff
changeset
|
77 |
mkdir -p build |
22436
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
78 |
cd build |
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
79 |
PYTHON_SRCFILE=Python-$PYTHONVER.tgz |
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
80 |
[ -f $PYTHON_SRCFILE ] || curl -Lo $PYTHON_SRCFILE http://www.python.org/ftp/python/$PYTHONVER/$PYTHON_SRCFILE |
23141
a440166d03fc
contrib: buildrpm checking of md5 checksums of downloaded Python and Docutils
Mads Kiilerich <madski@unity3d.com>
parents:
22437
diff
changeset
|
81 |
if [ "$PYTHONMD5" ]; then |
a440166d03fc
contrib: buildrpm checking of md5 checksums of downloaded Python and Docutils
Mads Kiilerich <madski@unity3d.com>
parents:
22437
diff
changeset
|
82 |
echo "$PYTHONMD5 $PYTHON_SRCFILE" | md5sum -w -c |
a440166d03fc
contrib: buildrpm checking of md5 checksums of downloaded Python and Docutils
Mads Kiilerich <madski@unity3d.com>
parents:
22437
diff
changeset
|
83 |
fi |
22437
9e2e4fc524fd
buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents:
22436
diff
changeset
|
84 |
ln -f $PYTHON_SRCFILE $RPMBUILDDIR/SOURCES/$PYTHON_SRCFILE |
22436
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
85 |
|
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
86 |
DOCUTILSVER=`sed -ne "s/^%global docutilsname docutils-//p" $specfile` |
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
87 |
DOCUTILS_SRCFILE=docutils-$DOCUTILSVER.tar.gz |
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
88 |
[ -f $DOCUTILS_SRCFILE ] || curl -Lo $DOCUTILS_SRCFILE http://downloads.sourceforge.net/project/docutils/docutils/$DOCUTILSVER/$DOCUTILS_SRCFILE |
23141
a440166d03fc
contrib: buildrpm checking of md5 checksums of downloaded Python and Docutils
Mads Kiilerich <madski@unity3d.com>
parents:
22437
diff
changeset
|
89 |
DOCUTILSMD5=`sed -ne "s/^%global docutilsmd5 //p" $specfile` |
a440166d03fc
contrib: buildrpm checking of md5 checksums of downloaded Python and Docutils
Mads Kiilerich <madski@unity3d.com>
parents:
22437
diff
changeset
|
90 |
if [ "$DOCUTILSMD5" ]; then |
a440166d03fc
contrib: buildrpm checking of md5 checksums of downloaded Python and Docutils
Mads Kiilerich <madski@unity3d.com>
parents:
22437
diff
changeset
|
91 |
echo "$DOCUTILSMD5 $DOCUTILS_SRCFILE" | md5sum -w -c |
a440166d03fc
contrib: buildrpm checking of md5 checksums of downloaded Python and Docutils
Mads Kiilerich <madski@unity3d.com>
parents:
22437
diff
changeset
|
92 |
fi |
22437
9e2e4fc524fd
buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents:
22436
diff
changeset
|
93 |
ln -f $DOCUTILS_SRCFILE $RPMBUILDDIR/SOURCES/$DOCUTILS_SRCFILE |
22436
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
94 |
) |
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
95 |
fi |
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
96 |
|
22437
9e2e4fc524fd
buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents:
22436
diff
changeset
|
97 |
rpmspec=$RPMBUILDDIR/SPECS/mercurial.spec |
9813
2059795bb5d0
buildrpm: build full RPM package including sources
Gilles Moris <gilles.moris@free.fr>
parents:
9812
diff
changeset
|
98 |
|
9812
dd2c95fc4fe5
buildrpm: cleanup script
Gilles Moris <gilles.moris@free.fr>
parents:
9811
diff
changeset
|
99 |
sed -e "s,^Version:.*,Version: $version," \ |
564 | 100 |
-e "s,^Release:.*,Release: $release," \ |
9813
2059795bb5d0
buildrpm: build full RPM package including sources
Gilles Moris <gilles.moris@free.fr>
parents:
9812
diff
changeset
|
101 |
$specfile > $rpmspec |
564 | 102 |
|
9814
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
103 |
echo >> $rpmspec |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
104 |
echo "%changelog" >> $rpmspec |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
105 |
|
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
106 |
if echo $version | grep '+' > /dev/null 2>&1; then |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
107 |
latesttag="`echo $version | sed -e 's/+.*//'`" |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
108 |
$HG log -r .:"$latesttag" -fM \ |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
109 |
--template '{date|hgdate}\t{author}\t{desc|firstline}\n' | python -c ' |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
110 |
import sys, time |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
111 |
|
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
112 |
def datestr(date, format): |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
113 |
return time.strftime(format, time.gmtime(float(date[0]) - date[1])) |
4754
e5e6dd8ba6bb
buildrpm: auto-generate %changelog in .spec file
Adam Spiers <hg@adamspiers.org>
parents:
564
diff
changeset
|
114 |
|
9814
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
115 |
changelog = [] |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
116 |
for l in sys.stdin.readlines(): |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
117 |
tok = l.split("\t") |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
118 |
hgdate = tuple(int(v) for v in tok[0].split()) |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
119 |
changelog.append((datestr(hgdate, "%F"), tok[1], hgdate, tok[2])) |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
120 |
prevtitle = "" |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
121 |
for l in sorted(changelog, reverse=True): |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
122 |
title = "* %s %s" % (datestr(l[2], "%a %b %d %Y"), l[1]) |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
123 |
if prevtitle != title: |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
124 |
prevtitle = title |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
125 |
|
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
126 |
print title |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
127 |
print "- %s" % l[3].strip() |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
128 |
' >> $rpmspec |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
129 |
|
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
130 |
else |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
131 |
|
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
132 |
$HG log \ |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
133 |
--template '{date|hgdate}\t{author}\t{desc|firstline}\n' \ |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
134 |
.hgtags | python -c ' |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
135 |
import sys, time |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
136 |
|
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
137 |
def datestr(date, format): |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
138 |
return time.strftime(format, time.gmtime(float(date[0]) - date[1])) |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
139 |
|
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
140 |
for l in sys.stdin.readlines(): |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
141 |
tok = l.split("\t") |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
142 |
hgdate = tuple(int(v) for v in tok[0].split()) |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
143 |
print "* %s %s\n- %s" % (datestr(hgdate, "%a %b %d %Y"), tok[1], tok[2]) |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
144 |
' >> $rpmspec |
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
145 |
|
5070e4d57276
buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents:
9813
diff
changeset
|
146 |
fi |
4754
e5e6dd8ba6bb
buildrpm: auto-generate %changelog in .spec file
Adam Spiers <hg@adamspiers.org>
parents:
564
diff
changeset
|
147 |
|
22436
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
148 |
sed -i \ |
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
149 |
-e "s/^%define withpython.*$/%define withpython $RPMPYTHONVER/" \ |
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
150 |
$rpmspec |
96d95b75a63b
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents:
22435
diff
changeset
|
151 |
|
22435
4c4385eb26bc
buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents:
21641
diff
changeset
|
152 |
if [ "$BUILD" ]; then |
22437
9e2e4fc524fd
buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents:
22436
diff
changeset
|
153 |
rpmbuild --define "_topdir $RPMBUILDDIR" -ba $rpmspec --clean |
22435
4c4385eb26bc
buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents:
21641
diff
changeset
|
154 |
if [ $? = 0 ]; then |
4c4385eb26bc
buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents:
21641
diff
changeset
|
155 |
echo |
4c4385eb26bc
buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents:
21641
diff
changeset
|
156 |
echo "Built packages for $version-$release:" |
22437
9e2e4fc524fd
buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents:
22436
diff
changeset
|
157 |
find $RPMBUILDDIR/*RPMS/ -type f -newer $rpmspec |
22435
4c4385eb26bc
buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents:
21641
diff
changeset
|
158 |
fi |
4c4385eb26bc
buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents:
21641
diff
changeset
|
159 |
else |
22437
9e2e4fc524fd
buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents:
22436
diff
changeset
|
160 |
echo "Prepared sources for $version-$release $rpmspec are in $RPMBUILDDIR/SOURCES/ - use like:" |
9e2e4fc524fd
buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents:
22436
diff
changeset
|
161 |
echo "rpmbuild --define '_topdir $RPMBUILDDIR' -ba $rpmspec --clean" |
564 | 162 |
fi |