Show More
@@ -1,72 +1,72 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 "$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 | # 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]'` |
|
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 |
|
39 | # Compute the release number as the difference in revision numbers | |
40 | # between the tip and the most recent tag. |
|
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])'` |
|
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])'` | |
42 | tip=`$HG -q tip` |
|
42 | tip=`$HG -q tip` | |
43 |
|
43 | |||
44 | # Beat up the spec file |
|
44 | # Beat up the spec file | |
45 | sed -e 's,^Source:.*,Source: /dev/null,' \ |
|
45 | sed -e 's,^Source:.*,Source: /dev/null,' \ | |
46 | -e "s,^Version:.*,Version: $version," \ |
|
46 | -e "s,^Version:.*,Version: $version," \ | |
47 | -e "s,^Release:.*,Release: $release," \ |
|
47 | -e "s,^Release:.*,Release: $release," \ | |
48 | -e "s,^%prep.*,Changeset: $tip\n\0," \ |
|
48 | -e "s,^%prep.*,Changeset: $tip\n\0," \ | |
49 | -e 's,^%setup.*,,' \ |
|
49 | -e 's,^%setup.*,,' \ | |
50 | $specfile > $tmpspec |
|
50 | $specfile > $tmpspec | |
51 |
|
51 | |||
52 | cat <<EOF >> $tmpspec |
|
52 | cat <<EOF >> $tmpspec | |
53 | %changelog |
|
53 | %changelog | |
54 | * `date +'%a %b %d %Y'` `$HG showconfig ui.username` $version-$release |
|
54 | * `LANG=en_US date +'%a %b %d %Y'` `$HG showconfig ui.username` $version-$release | |
55 | - Automatically built via $0 |
|
55 | - Automatically built via $0 | |
56 |
|
56 | |||
57 | EOF |
|
57 | EOF | |
58 | $HG log \ |
|
58 | $HG log \ | |
59 | --template '* {date|rfc822date} {author}\n- {desc|firstline}\n\n' \ |
|
59 | --template '* {date|rfc822date} {author}\n- {desc|firstline}\n\n' \ | |
60 | .hgtags \ |
|
60 | .hgtags \ | |
61 | | sed -e 's/^\(\* [MTWFS][a-z][a-z]\), \([0-3][0-9]\) \([A-Z][a-z][a-z]\) /\1 \3 \2 /' \ |
|
61 | | 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\}//}' \ |
|
62 | -e '/^\* [MTWFS][a-z][a-z] /{s/ [012][0-9]:[0-9][0-9]:[0-9][0-9] [+-][0-9]\{4\}//}' \ | |
63 | >> $tmpspec |
|
63 | >> $tmpspec | |
64 |
|
64 | |||
65 | rpmbuild --define "_topdir $rpmdir" -bb $tmpspec |
|
65 | rpmbuild --define "_topdir $rpmdir" -bb $tmpspec | |
66 | if [ $? = 0 ]; then |
|
66 | if [ $? = 0 ]; then | |
67 | rm -rf $tmpspec $rpmdir/BUILD |
|
67 | rm -rf $tmpspec $rpmdir/BUILD | |
68 | mv $rpmdir/RPMS/*/* $rpmdir && rm -r $rpmdir/RPMS |
|
68 | mv $rpmdir/RPMS/*/* $rpmdir && rm -r $rpmdir/RPMS | |
69 | echo |
|
69 | echo | |
70 | echo "Packages are in $rpmdir:" |
|
70 | echo "Packages are in $rpmdir:" | |
71 | ls -l $rpmdir/*.rpm |
|
71 | ls -l $rpmdir/*.rpm | |
72 | fi |
|
72 | fi |
General Comments 0
You need to be logged in to leave comments.
Login now