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