annotate contrib/buildrpm @ 9813:2059795bb5d0

buildrpm: build full RPM package including sources
author Gilles Moris <gilles.moris@free.fr>
date Fri, 06 Nov 2009 09:59:55 +0100
parents dd2c95fc4fe5
children 5070e4d57276
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
564
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
1 #!/bin/sh
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
2 #
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
3 # Build a Mercurial RPM in place.
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
4 #
8867
ff817723280a contrib/buildrpm: Support python 2.4 and 2.6
Mads Kiilerich <mads@kiilerich.com>
parents: 7431
diff changeset
5 # Tested on
9812
dd2c95fc4fe5 buildrpm: cleanup script
Gilles Moris <gilles.moris@free.fr>
parents: 9811
diff changeset
6 # - Fedora 8 (with docutils 0.5)
8867
ff817723280a contrib/buildrpm: Support python 2.4 and 2.6
Mads Kiilerich <mads@kiilerich.com>
parents: 7431
diff changeset
7 # - Fedora 11
9812
dd2c95fc4fe5 buildrpm: cleanup script
Gilles Moris <gilles.moris@free.fr>
parents: 9811
diff changeset
8 # - OpenSuse 11.2
564
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
9
9811
c92ac5a56f69 buildrpm: enable to start the script from anywhere
Gilles Moris <gilles.moris@free.fr>
parents: 9810
diff changeset
10 cd "`dirname $0`/.."
c92ac5a56f69 buildrpm: enable to start the script from anywhere
Gilles Moris <gilles.moris@free.fr>
parents: 9810
diff changeset
11 HG="$PWD/hg"
c92ac5a56f69 buildrpm: enable to start the script from anywhere
Gilles Moris <gilles.moris@free.fr>
parents: 9810
diff changeset
12 PYTHONPATH="$PWD/mercurial/pure"
8869
d244ee52ac30 contrib/buildrpm: Don't require installed hg, use local hg with pure extensions
Mads Kiilerich <mads@kiilerich.com>
parents: 8868
diff changeset
13 export PYTHONPATH
7431
3d827cc616b6 buildrpm: complain when hg command isn't available
Mads Kiilerich <mads@kiilerich.com>
parents: 7277
diff changeset
14
564
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
15 specfile=contrib/mercurial.spec
9812
dd2c95fc4fe5 buildrpm: cleanup script
Gilles Moris <gilles.moris@free.fr>
parents: 9811
diff changeset
16 if [ ! -f $specfile ]; then
dd2c95fc4fe5 buildrpm: cleanup script
Gilles Moris <gilles.moris@free.fr>
parents: 9811
diff changeset
17 echo "Cannot find $specfile!" 1>&2
dd2c95fc4fe5 buildrpm: cleanup script
Gilles Moris <gilles.moris@free.fr>
parents: 9811
diff changeset
18 exit 1
dd2c95fc4fe5 buildrpm: cleanup script
Gilles Moris <gilles.moris@free.fr>
parents: 9811
diff changeset
19 fi
564
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
20
9812
dd2c95fc4fe5 buildrpm: cleanup script
Gilles Moris <gilles.moris@free.fr>
parents: 9811
diff changeset
21 if [ ! -d .hg ]; then
564
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
22 echo 'You are not inside a Mercurial repository!' 1>&2
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
23 exit 1
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
24 fi
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
25
9810
326a0a6453a3 buildrpm: warn if there is outstanding uncommitted changes
Gilles Moris <gilles.moris@free.fr>
parents: 9809
diff changeset
26 if $HG id -i | grep '+$' > /dev/null 2>&1; then
326a0a6453a3 buildrpm: warn if there is outstanding uncommitted changes
Gilles Moris <gilles.moris@free.fr>
parents: 9809
diff changeset
27 echo -n "Your local changes will NOT be in the RPM. Continue [y/n] ? "
326a0a6453a3 buildrpm: warn if there is outstanding uncommitted changes
Gilles Moris <gilles.moris@free.fr>
parents: 9809
diff changeset
28 read answer
326a0a6453a3 buildrpm: warn if there is outstanding uncommitted changes
Gilles Moris <gilles.moris@free.fr>
parents: 9809
diff changeset
29 if echo $answer | grep -iv '^y'; then
326a0a6453a3 buildrpm: warn if there is outstanding uncommitted changes
Gilles Moris <gilles.moris@free.fr>
parents: 9809
diff changeset
30 exit
326a0a6453a3 buildrpm: warn if there is outstanding uncommitted changes
Gilles Moris <gilles.moris@free.fr>
parents: 9809
diff changeset
31 fi
326a0a6453a3 buildrpm: warn if there is outstanding uncommitted changes
Gilles Moris <gilles.moris@free.fr>
parents: 9809
diff changeset
32 fi
326a0a6453a3 buildrpm: warn if there is outstanding uncommitted changes
Gilles Moris <gilles.moris@free.fr>
parents: 9809
diff changeset
33
9812
dd2c95fc4fe5 buildrpm: cleanup script
Gilles Moris <gilles.moris@free.fr>
parents: 9811
diff changeset
34 rpmdir="$PWD/rpmbuild"
564
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
35
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
36 rm -rf $rpmdir
9813
2059795bb5d0 buildrpm: build full RPM package including sources
Gilles Moris <gilles.moris@free.fr>
parents: 9812
diff changeset
37 mkdir -p $rpmdir/SOURCES $rpmdir/SPECS $rpmdir/RPMS $rpmdir/SRPMS $rpmdir/BUILD
564
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
38
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
39 # make setup.py build the version string
ce145bf2ca5e buildrpm: build from working dir parent and use hg version for RPM versioning
Gilles Moris <gilles.moris@free.fr>
parents: 8906
diff changeset
40 python setup.py build_py -c -d .
ce145bf2ca5e buildrpm: build from working dir parent and use hg version for RPM versioning
Gilles Moris <gilles.moris@free.fr>
parents: 8906
diff changeset
41 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
42
ce145bf2ca5e buildrpm: build from working dir parent and use hg version for RPM versioning
Gilles Moris <gilles.moris@free.fr>
parents: 8906
diff changeset
43 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
44 # 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
45 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
46 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
47 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
48 # 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
49 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
50 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
51 fi
564
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
52
9813
2059795bb5d0 buildrpm: build full RPM package including sources
Gilles Moris <gilles.moris@free.fr>
parents: 9812
diff changeset
53 $HG archive -t tgz $rpmdir/SOURCES/mercurial-$version.tar.gz
2059795bb5d0 buildrpm: build full RPM package including sources
Gilles Moris <gilles.moris@free.fr>
parents: 9812
diff changeset
54 rpmspec=$rpmdir/SPECS/mercurial-$version.spec
2059795bb5d0 buildrpm: build full RPM package including sources
Gilles Moris <gilles.moris@free.fr>
parents: 9812
diff changeset
55
9812
dd2c95fc4fe5 buildrpm: cleanup script
Gilles Moris <gilles.moris@free.fr>
parents: 9811
diff changeset
56 sed -e "s,^Version:.*,Version: $version," \
564
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
57 -e "s,^Release:.*,Release: $release," \
9813
2059795bb5d0 buildrpm: build full RPM package including sources
Gilles Moris <gilles.moris@free.fr>
parents: 9812
diff changeset
58 $specfile > $rpmspec
564
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
59
9813
2059795bb5d0 buildrpm: build full RPM package including sources
Gilles Moris <gilles.moris@free.fr>
parents: 9812
diff changeset
60 cat <<EOF >> $rpmspec
4754
e5e6dd8ba6bb buildrpm: auto-generate %changelog in .spec file
Adam Spiers <hg@adamspiers.org>
parents: 564
diff changeset
61 %changelog
8906
bb255fe7c27e contrib/buildrpm: force en_US locale during changelog's creation
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 8869
diff changeset
62 * `LANG=en_US date +'%a %b %d %Y'` `$HG showconfig ui.username` $version-$release
4754
e5e6dd8ba6bb buildrpm: auto-generate %changelog in .spec file
Adam Spiers <hg@adamspiers.org>
parents: 564
diff changeset
63 - Automatically built via $0
e5e6dd8ba6bb buildrpm: auto-generate %changelog in .spec file
Adam Spiers <hg@adamspiers.org>
parents: 564
diff changeset
64
e5e6dd8ba6bb buildrpm: auto-generate %changelog in .spec file
Adam Spiers <hg@adamspiers.org>
parents: 564
diff changeset
65 EOF
8869
d244ee52ac30 contrib/buildrpm: Don't require installed hg, use local hg with pure extensions
Mads Kiilerich <mads@kiilerich.com>
parents: 8868
diff changeset
66 $HG log \
4754
e5e6dd8ba6bb buildrpm: auto-generate %changelog in .spec file
Adam Spiers <hg@adamspiers.org>
parents: 564
diff changeset
67 --template '* {date|rfc822date} {author}\n- {desc|firstline}\n\n' \
e5e6dd8ba6bb buildrpm: auto-generate %changelog in .spec file
Adam Spiers <hg@adamspiers.org>
parents: 564
diff changeset
68 .hgtags \
e5e6dd8ba6bb buildrpm: auto-generate %changelog in .spec file
Adam Spiers <hg@adamspiers.org>
parents: 564
diff changeset
69 | sed -e 's/^\(\* [MTWFS][a-z][a-z]\), \([0-3][0-9]\) \([A-Z][a-z][a-z]\) /\1 \3 \2 /' \
e5e6dd8ba6bb buildrpm: auto-generate %changelog in .spec file
Adam Spiers <hg@adamspiers.org>
parents: 564
diff changeset
70 -e '/^\* [MTWFS][a-z][a-z] /{s/ [012][0-9]:[0-9][0-9]:[0-9][0-9] [+-][0-9]\{4\}//}' \
9813
2059795bb5d0 buildrpm: build full RPM package including sources
Gilles Moris <gilles.moris@free.fr>
parents: 9812
diff changeset
71 >> $rpmspec
4754
e5e6dd8ba6bb buildrpm: auto-generate %changelog in .spec file
Adam Spiers <hg@adamspiers.org>
parents: 564
diff changeset
72
9813
2059795bb5d0 buildrpm: build full RPM package including sources
Gilles Moris <gilles.moris@free.fr>
parents: 9812
diff changeset
73 rpmbuild --define "_topdir $rpmdir" -ba $rpmspec --clean
564
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
74 if [ $? = 0 ]; then
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
75 echo
7277
3e000e2bf5f6 Make contrib/buildrpm work on Fedora 9.
Mads Kiilerich <mads@kiilerich.com>
parents: 4755
diff changeset
76 echo "Packages are in $rpmdir:"
9813
2059795bb5d0 buildrpm: build full RPM package including sources
Gilles Moris <gilles.moris@free.fr>
parents: 9812
diff changeset
77 ls -l $rpmdir/*RPMS/*
564
ced5f5ceb172 [PATCH] Add contrib/buildrpm script
mpm@selenic.com
parents:
diff changeset
78 fi