Show More
@@ -1,72 +1,80 b'' | |||
|
1 | 1 | #!/bin/sh |
|
2 | 2 | # |
|
3 | 3 | # Build a Mercurial RPM in place. |
|
4 | 4 | # |
|
5 | 5 | # Bryan O'Sullivan <bos@serpentine.com> |
|
6 | 6 | # |
|
7 | 7 | # Tested on |
|
8 | 8 | # - Fedora 10 |
|
9 | 9 | # - Fedora 11 |
|
10 | 10 | # - Centos 5.3 (with Fedora EPEL repo for asciidoc) |
|
11 | 11 | |
|
12 | 12 | HG="`dirname $0`/../hg" |
|
13 | 13 | PYTHONPATH="`dirname $0`/../mercurial/pure" |
|
14 | 14 | export PYTHONPATH |
|
15 | 15 | |
|
16 | 16 | root="`$HG root 2>/dev/null`" |
|
17 | 17 | specfile=contrib/mercurial.spec |
|
18 | 18 | |
|
19 | 19 | if [ -z "$root" ]; then |
|
20 | 20 | echo 'You are not inside a Mercurial repository!' 1>&2 |
|
21 | 21 | exit 1 |
|
22 | 22 | fi |
|
23 | 23 | |
|
24 | 24 | rpmdir=/tmp/"`basename $root | sed 's/ /_/'`"-rpm # FIXME: Insecure /tmp handling |
|
25 | 25 | |
|
26 | 26 | cd "$root" |
|
27 | 27 | rm -rf $rpmdir |
|
28 | 28 | mkdir -p $rpmdir/RPMS |
|
29 | $HG clone "$root" $rpmdir/BUILD | |
|
29 | $HG clone -u . "$root" $rpmdir/BUILD | |
|
30 | 30 | |
|
31 | 31 | if [ ! -f $specfile ]; then |
|
32 | 32 | echo "Cannot find $specfile!" 1>&2 |
|
33 | 33 | exit 1 |
|
34 | 34 | fi |
|
35 | 35 | |
|
36 | 36 | tmpspec=/tmp/`basename "$specfile"`.$$ # FIXME: Insecure /tmp handling |
|
37 | # Use the most recent tag as the version. | |
|
38 | version=`$HG tags | python -c 'import sys; print [l for l in sys.stdin.readlines() if l[0].isdigit()][0].split()[0]'` | |
|
39 | # Compute the release number as the difference in revision numbers | |
|
40 | # between the tip and the most recent tag. | |
|
41 | release=`$HG tags | python -c 'import sys; l = sys.stdin.readlines(); print int(l[0].split()[1].split(":")[0]) - int([x for x in l if x[0].isdigit()][0].split()[1].split(":")[0])'` | |
|
37 | # make setup.py build the version string | |
|
38 | python setup.py build_py -c -d . | |
|
39 | hgversion=`$HG version | sed -ne 's/.*(version \(.*\))$/\1/p'` | |
|
40 | ||
|
41 | if echo $hgversion | grep -- '-' > /dev/null 2>&1; then | |
|
42 | # nightly build case, version is like 1.3.1+250-20b91f91f9ca | |
|
43 | version=`echo $hgversion | cut -d- -f1` | |
|
44 | release=`echo $hgversion | cut -d- -f2 | sed -e 's/+.*//'` | |
|
45 | else | |
|
46 | # official tag, version is like 1.3.1 | |
|
47 | version=`echo $hgversion | sed -e 's/+.*//'` | |
|
48 | release='0' | |
|
49 | fi | |
|
42 | 50 | tip=`$HG -q tip` |
|
43 | 51 | |
|
44 | 52 | # Beat up the spec file |
|
45 | 53 | sed -e 's,^Source:.*,Source: /dev/null,' \ |
|
46 | 54 | -e "s,^Version:.*,Version: $version," \ |
|
47 | 55 | -e "s,^Release:.*,Release: $release," \ |
|
48 | 56 | -e "s,^%prep.*,Changeset: $tip\n\0," \ |
|
49 | 57 | -e 's,^%setup.*,,' \ |
|
50 | 58 | $specfile > $tmpspec |
|
51 | 59 | |
|
52 | 60 | cat <<EOF >> $tmpspec |
|
53 | 61 | %changelog |
|
54 | 62 | * `LANG=en_US date +'%a %b %d %Y'` `$HG showconfig ui.username` $version-$release |
|
55 | 63 | - Automatically built via $0 |
|
56 | 64 | |
|
57 | 65 | EOF |
|
58 | 66 | $HG log \ |
|
59 | 67 | --template '* {date|rfc822date} {author}\n- {desc|firstline}\n\n' \ |
|
60 | 68 | .hgtags \ |
|
61 | 69 | | sed -e 's/^\(\* [MTWFS][a-z][a-z]\), \([0-3][0-9]\) \([A-Z][a-z][a-z]\) /\1 \3 \2 /' \ |
|
62 | 70 | -e '/^\* [MTWFS][a-z][a-z] /{s/ [012][0-9]:[0-9][0-9]:[0-9][0-9] [+-][0-9]\{4\}//}' \ |
|
63 | 71 | >> $tmpspec |
|
64 | 72 | |
|
65 | 73 | rpmbuild --define "_topdir $rpmdir" -bb $tmpspec |
|
66 | 74 | if [ $? = 0 ]; then |
|
67 | 75 | rm -rf $tmpspec $rpmdir/BUILD |
|
68 | 76 | mv $rpmdir/RPMS/*/* $rpmdir && rm -r $rpmdir/RPMS |
|
69 | 77 | echo |
|
70 | 78 | echo "Packages are in $rpmdir:" |
|
71 | 79 | ls -l $rpmdir/*.rpm |
|
72 | 80 | fi |
General Comments 0
You need to be logged in to leave comments.
Login now