annotate contrib/packaging/buildrpm @ 43358:518655314fc5 stable

packaging: use "python3" for fedora29 ... and as buildrpm default Change the buidrpm default. The CentOS targets explicitly use "python", and changing the default will only influence Fedora 29. A Python 3 package needs python3 dependencies, so pythonexe (and pythonver) is used for specifying dependencies. Other OS versions will keep using "python" as before ... or potentially change to explicit "python2". Fedora 29 packages can thus also still be built for Python 2 - just not in the docker image that is updated for Python 3.
author Mads Kiilerich <mads@kiilerich.com>
date Fri, 01 Nov 2019 12:59:22 +0100
parents 90dc0d3111d0
children de1f4c431619
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27878
e7bd55db011b buildrpm: use bash shebang, since we use bash features in the script
Mathias De Maré <mathias.demare@gmail.com>
parents: 27788
diff changeset
1 #!/bin/bash -e
564
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
2 #
43344
825f8f42333a packaging: drop outdated buildrpm "tested on" comment
Mads Kiilerich <mads@kiilerich.com>
parents: 43342
diff changeset
3 # Build a Mercurial RPM from the current repo, mainly for Fedora/CentOS/RHEL
564
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
4
38008
b7cd9e94c259 packaging: move buildrpm to contrib/packaging/
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38007
diff changeset
5 . $(dirname $0)/packagelib.sh
24972
56c64c91b429 packaging: extract packagelib for common code from builddeb and buildrpm
Augie Fackler <augie@google.com>
parents: 24730
diff changeset
6
22435
4c4385eb26bc buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents: 21641
diff changeset
7 BUILD=1
22437
9e2e4fc524fd buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents: 22436
diff changeset
8 RPMBUILDDIR="$PWD/rpmbuild"
43358
518655314fc5 packaging: use "python3" for fedora29 ... and as buildrpm default
Mads Kiilerich <mads@kiilerich.com>
parents: 43357
diff changeset
9 PYTHONEXE=python3
33686
5aac617a028d buildrpm: do not break in presence of custom user configs
muxator <a.mux@inwind.it>
parents: 27878
diff changeset
10
22435
4c4385eb26bc buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents: 21641
diff changeset
11 while [ "$1" ]; do
4c4385eb26bc buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents: 21641
diff changeset
12 case "$1" in
4c4385eb26bc buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents: 21641
diff changeset
13 --prepare )
4c4385eb26bc buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents: 21641
diff changeset
14 shift
4c4385eb26bc buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents: 21641
diff changeset
15 BUILD=
4c4385eb26bc buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents: 21641
diff changeset
16 ;;
43357
90dc0d3111d0 packaging: use "--python python" for centos7 to avoid explicit "python2"
Mads Kiilerich <mads@kiilerich.com>
parents: 43356
diff changeset
17 --python)
43342
a6dcac6454c1 packaging: introduce Python3 support as buildrpm --python3
Mads Kiilerich <mads@kiilerich.com>
parents: 43340
diff changeset
18 shift
43357
90dc0d3111d0 packaging: use "--python python" for centos7 to avoid explicit "python2"
Mads Kiilerich <mads@kiilerich.com>
parents: 43356
diff changeset
19 PYTHONEXE=$1
90dc0d3111d0 packaging: use "--python python" for centos7 to avoid explicit "python2"
Mads Kiilerich <mads@kiilerich.com>
parents: 43356
diff changeset
20 shift
43342
a6dcac6454c1 packaging: introduce Python3 support as buildrpm --python3
Mads Kiilerich <mads@kiilerich.com>
parents: 43340
diff changeset
21 ;;
22436
96d95b75a63b buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents: 22435
diff changeset
22 --withpython | --with-python)
96d95b75a63b buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents: 22435
diff changeset
23 shift
42191
ae68418cc3a1 buildrpm: bump bundled Python version to 2.7.16 when building for centos{5,6}
Antonio Muci <a.mux@inwind.it>
parents: 39455
diff changeset
24 PYTHONVER=2.7.16
ae68418cc3a1 buildrpm: bump bundled Python version to 2.7.16 when building for centos{5,6}
Antonio Muci <a.mux@inwind.it>
parents: 39455
diff changeset
25 PYTHONMD5=f1a2ace631068444831d01485466ece0
43356
5989f697890a packaging: fix docker-centos5 - use pythonexe and set to "python" as before
Mads Kiilerich <mads@kiilerich.com>
parents: 43345
diff changeset
26 PYTHONEXE=python
22436
96d95b75a63b buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents: 22435
diff changeset
27 ;;
22437
9e2e4fc524fd buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents: 22436
diff changeset
28 --rpmbuilddir )
9e2e4fc524fd buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents: 22436
diff changeset
29 shift
9e2e4fc524fd buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents: 22436
diff changeset
30 RPMBUILDDIR="$1"
9e2e4fc524fd buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents: 22436
diff changeset
31 shift
9e2e4fc524fd buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents: 22436
diff changeset
32 ;;
22435
4c4385eb26bc buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents: 21641
diff changeset
33 * )
4c4385eb26bc buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents: 21641
diff changeset
34 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
35 exit 1
4c4385eb26bc buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents: 21641
diff changeset
36 ;;
4c4385eb26bc buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents: 21641
diff changeset
37 esac
4c4385eb26bc buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents: 21641
diff changeset
38 done
4c4385eb26bc buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents: 21641
diff changeset
39
38008
b7cd9e94c259 packaging: move buildrpm to contrib/packaging/
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38007
diff changeset
40 cd "`dirname $0`/../.."
7431
3d827cc616b6 buildrpm: complain when hg command isn't available
Mads Kiilerich <mads@kiilerich.com>
parents: 7277
diff changeset
41
38007
c1a028d15005 packaging: move mercurial.spec to contrib/packaging/
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38005
diff changeset
42 specfile=$PWD/contrib/packaging/mercurial.spec
9812
dd2c95fc4fe5 buildrpm: cleanup script
Gilles Moris <gilles.moris@free.fr>
parents: 9811
diff changeset
43 if [ ! -f $specfile ]; then
dd2c95fc4fe5 buildrpm: cleanup script
Gilles Moris <gilles.moris@free.fr>
parents: 9811
diff changeset
44 echo "Cannot find $specfile!" 1>&2
dd2c95fc4fe5 buildrpm: cleanup script
Gilles Moris <gilles.moris@free.fr>
parents: 9811
diff changeset
45 exit 1
dd2c95fc4fe5 buildrpm: cleanup script
Gilles Moris <gilles.moris@free.fr>
parents: 9811
diff changeset
46 fi
564
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
47
9812
dd2c95fc4fe5 buildrpm: cleanup script
Gilles Moris <gilles.moris@free.fr>
parents: 9811
diff changeset
48 if [ ! -d .hg ]; then
564
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
49 echo 'You are not inside a Mercurial repository!' 1>&2
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
50 exit 1
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
51 fi
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
52
24972
56c64c91b429 packaging: extract packagelib for common code from builddeb and buildrpm
Augie Fackler <augie@google.com>
parents: 24730
diff changeset
53 gethgversion
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
54
26833
6474b64045fb packaging: rework version detection and declaration (issue4912)
Augie Fackler <augie@google.com>
parents: 26735
diff changeset
55 if [ -z "$type" ] ; then
43345
dc3fe251de72 packaging: fix buildrpm whitespace
Mads Kiilerich <mads@kiilerich.com>
parents: 43344
diff changeset
56 release=1
26833
6474b64045fb packaging: rework version detection and declaration (issue4912)
Augie Fackler <augie@google.com>
parents: 26735
diff changeset
57 else
6474b64045fb packaging: rework version detection and declaration (issue4912)
Augie Fackler <augie@google.com>
parents: 26735
diff changeset
58 release=0.9_$type
6474b64045fb packaging: rework version detection and declaration (issue4912)
Augie Fackler <augie@google.com>
parents: 26735
diff changeset
59 fi
6474b64045fb packaging: rework version detection and declaration (issue4912)
Augie Fackler <augie@google.com>
parents: 26735
diff changeset
60
6474b64045fb packaging: rework version detection and declaration (issue4912)
Augie Fackler <augie@google.com>
parents: 26735
diff changeset
61 if [ -n "$distance" ] ; then
39454
c68cfc55af9d buildrpm: fix embarassing bug in shell variable expansions
Augie Fackler <raf@durin42.com>
parents: 38008
diff changeset
62 release=$release+${distance}_${node}
26833
6474b64045fb packaging: rework version detection and declaration (issue4912)
Augie Fackler <augie@google.com>
parents: 26735
diff changeset
63 fi
6474b64045fb packaging: rework version detection and declaration (issue4912)
Augie Fackler <augie@google.com>
parents: 26735
diff changeset
64
22436
96d95b75a63b buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents: 22435
diff changeset
65 if [ "$PYTHONVER" ]; then
96d95b75a63b buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents: 22435
diff changeset
66 release=$release+$PYTHONVER
96d95b75a63b buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents: 22435
diff changeset
67 RPMPYTHONVER=$PYTHONVER
96d95b75a63b buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents: 22435
diff changeset
68 else
96d95b75a63b buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents: 22435
diff changeset
69 RPMPYTHONVER=%{nil}
96d95b75a63b buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents: 22435
diff changeset
70 fi
564
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
71
27788
d713fa934fb9 buildrpm: move creation of RPM directories from dockerrpm
Mathias De Maré <mathias.demare@gmail.com>
parents: 26833
diff changeset
72 mkdir -p $RPMBUILDDIR/{SOURCES,BUILD,SRPMS,RPMS}
22437
9e2e4fc524fd buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents: 22436
diff changeset
73 $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
74 if [ "$PYTHONVER" ]; then
96d95b75a63b buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents: 22435
diff changeset
75 (
24730
aa8e5c6d953b rpms: create missing builds dir if it doesn't exist
Mads Kiilerich <madski@unity3d.com>
parents: 23881
diff changeset
76 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
77 cd build
96d95b75a63b buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents: 22435
diff changeset
78 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
79 [ -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
80 if [ "$PYTHONMD5" ]; then
a440166d03fc contrib: buildrpm checking of md5 checksums of downloaded Python and Docutils
Mads Kiilerich <madski@unity3d.com>
parents: 22437
diff changeset
81 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
82 fi
22437
9e2e4fc524fd buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents: 22436
diff changeset
83 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
84
96d95b75a63b buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents: 22435
diff changeset
85 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
86 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
87 [ -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
88 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
89 if [ "$DOCUTILSMD5" ]; then
a440166d03fc contrib: buildrpm checking of md5 checksums of downloaded Python and Docutils
Mads Kiilerich <madski@unity3d.com>
parents: 22437
diff changeset
90 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
91 fi
22437
9e2e4fc524fd buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents: 22436
diff changeset
92 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
93 )
96d95b75a63b buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents: 22435
diff changeset
94 fi
96d95b75a63b buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents: 22435
diff changeset
95
26139
f643b6863382 buildrpm: mkdir -p two needed directories (issue4779)
Augie Fackler <augie@google.com>
parents: 24972
diff changeset
96 mkdir -p $RPMBUILDDIR/SPECS
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
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
100 -e "s,^Release:.*,Release: $release," \
43342
a6dcac6454c1 packaging: introduce Python3 support as buildrpm --python3
Mads Kiilerich <mads@kiilerich.com>
parents: 43340
diff changeset
101 -e "s/^%global pythonexe .*/%global pythonexe $PYTHONEXE/" \
9813
2059795bb5d0 buildrpm: build full RPM package including sources
Gilles Moris <gilles.moris@free.fr>
parents: 9812
diff changeset
102 $specfile > $rpmspec
564
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
103
9814
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
104 echo >> $rpmspec
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
105 echo "%changelog" >> $rpmspec
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
106
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
107 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
108 latesttag="`echo $version | sed -e 's/+.*//'`"
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
109 $HG log -r .:"$latesttag" -fM \
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
110 --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
111 import sys, time
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
112
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
113 def datestr(date, format):
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
114 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
115
9814
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
116 changelog = []
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
117 for l in sys.stdin.readlines():
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
118 tok = l.split("\t")
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
119 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
120 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
121 prevtitle = ""
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
122 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
123 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
124 if prevtitle != title:
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
125 prevtitle = title
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
126 print
43340
e0812b032bcc packaging: make python snippets in rpm building python3 compatible
Mads Kiilerich <mads@kiilerich.com>
parents: 42191
diff changeset
127 print(title)
e0812b032bcc packaging: make python snippets in rpm building python3 compatible
Mads Kiilerich <mads@kiilerich.com>
parents: 42191
diff changeset
128 print("- %s" % l[3].strip())
9814
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
129 ' >> $rpmspec
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
130
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
131 else
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
132
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
133 $HG log \
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
134 --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
135 .hgtags | python -c '
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
136 import sys, time
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
137
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
138 def datestr(date, format):
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
139 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
140
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
141 for l in sys.stdin.readlines():
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
142 tok = l.split("\t")
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
143 hgdate = tuple(int(v) for v in tok[0].split())
43340
e0812b032bcc packaging: make python snippets in rpm building python3 compatible
Mads Kiilerich <mads@kiilerich.com>
parents: 42191
diff changeset
144 print("* %s %s\n- %s" % (datestr(hgdate, "%a %b %d %Y"), tok[1], tok[2]))
9814
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
145 ' >> $rpmspec
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
146
5070e4d57276 buildrpm: enhance changelog of the RPM file
Gilles Moris <gilles.moris@free.fr>
parents: 9813
diff changeset
147 fi
4754
e5e6dd8ba6bb buildrpm: auto-generate %changelog in .spec file
Adam Spiers <hg@adamspiers.org>
parents: 564
diff changeset
148
22436
96d95b75a63b buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents: 22435
diff changeset
149 sed -i \
96d95b75a63b buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents: 22435
diff changeset
150 -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
151 $rpmspec
96d95b75a63b buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich <madski@unity3d.com>
parents: 22435
diff changeset
152
22435
4c4385eb26bc buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents: 21641
diff changeset
153 if [ "$BUILD" ]; then
22437
9e2e4fc524fd buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents: 22436
diff changeset
154 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
155 if [ $? = 0 ]; then
4c4385eb26bc buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents: 21641
diff changeset
156 echo
4c4385eb26bc buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents: 21641
diff changeset
157 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
158 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
159 fi
4c4385eb26bc buildrpm: introduce --prepare for preparing without actually building rpms
Mads Kiilerich <madski@unity3d.com>
parents: 21641
diff changeset
160 else
22437
9e2e4fc524fd buildrpm: introduce --rpmdir instead of using hardcoded rpmbuild dir
Mads Kiilerich <madski@unity3d.com>
parents: 22436
diff changeset
161 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
162 echo "rpmbuild --define '_topdir $RPMBUILDDIR' -ba $rpmspec --clean"
564
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
163 fi