Show More
@@ -1,88 +1,89 | |||
|
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 |
|
|
|
13 | PYTHONPATH="`dirname $0`/../mercurial/pure" | |
|
12 | cd "`dirname $0`/.." | |
|
13 | HG="$PWD/hg" | |
|
14 | PYTHONPATH="$PWD/mercurial/pure" | |
|
14 | 15 | export PYTHONPATH |
|
15 | 16 | |
|
16 | 17 | root="`$HG root 2>/dev/null`" |
|
17 | 18 | specfile=contrib/mercurial.spec |
|
18 | 19 | |
|
19 | 20 | if [ -z "$root" ]; then |
|
20 | 21 | echo 'You are not inside a Mercurial repository!' 1>&2 |
|
21 | 22 | exit 1 |
|
22 | 23 | fi |
|
23 | 24 | |
|
24 | 25 | if $HG id -i | grep '+$' > /dev/null 2>&1; then |
|
25 | 26 | echo -n "Your local changes will NOT be in the RPM. Continue [y/n] ? " |
|
26 | 27 | read answer |
|
27 | 28 | if echo $answer | grep -iv '^y'; then |
|
28 | 29 | exit |
|
29 | 30 | fi |
|
30 | 31 | fi |
|
31 | 32 | |
|
32 | 33 | rpmdir=/tmp/"`basename $root | sed 's/ /_/'`"-rpm # FIXME: Insecure /tmp handling |
|
33 | 34 | |
|
34 | 35 | cd "$root" |
|
35 | 36 | rm -rf $rpmdir |
|
36 | 37 | mkdir -p $rpmdir/RPMS |
|
37 | 38 | $HG clone -u . "$root" $rpmdir/BUILD |
|
38 | 39 | |
|
39 | 40 | if [ ! -f $specfile ]; then |
|
40 | 41 | echo "Cannot find $specfile!" 1>&2 |
|
41 | 42 | exit 1 |
|
42 | 43 | fi |
|
43 | 44 | |
|
44 | 45 | tmpspec=/tmp/`basename "$specfile"`.$$ # FIXME: Insecure /tmp handling |
|
45 | 46 | # make setup.py build the version string |
|
46 | 47 | python setup.py build_py -c -d . |
|
47 | 48 | hgversion=`$HG version | sed -ne 's/.*(version \(.*\))$/\1/p'` |
|
48 | 49 | |
|
49 | 50 | if echo $hgversion | grep -- '-' > /dev/null 2>&1; then |
|
50 | 51 | # nightly build case, version is like 1.3.1+250-20b91f91f9ca |
|
51 | 52 | version=`echo $hgversion | cut -d- -f1` |
|
52 | 53 | release=`echo $hgversion | cut -d- -f2 | sed -e 's/+.*//'` |
|
53 | 54 | else |
|
54 | 55 | # official tag, version is like 1.3.1 |
|
55 | 56 | version=`echo $hgversion | sed -e 's/+.*//'` |
|
56 | 57 | release='0' |
|
57 | 58 | fi |
|
58 | 59 | tip=`$HG -q tip` |
|
59 | 60 | |
|
60 | 61 | # Beat up the spec file |
|
61 | 62 | sed -e 's,^Source:.*,Source: /dev/null,' \ |
|
62 | 63 | -e "s,^Version:.*,Version: $version," \ |
|
63 | 64 | -e "s,^Release:.*,Release: $release," \ |
|
64 | 65 | -e "s,^%prep.*,Changeset: $tip\n\0," \ |
|
65 | 66 | -e 's,^%setup.*,,' \ |
|
66 | 67 | $specfile > $tmpspec |
|
67 | 68 | |
|
68 | 69 | cat <<EOF >> $tmpspec |
|
69 | 70 | %changelog |
|
70 | 71 | * `LANG=en_US date +'%a %b %d %Y'` `$HG showconfig ui.username` $version-$release |
|
71 | 72 | - Automatically built via $0 |
|
72 | 73 | |
|
73 | 74 | EOF |
|
74 | 75 | $HG log \ |
|
75 | 76 | --template '* {date|rfc822date} {author}\n- {desc|firstline}\n\n' \ |
|
76 | 77 | .hgtags \ |
|
77 | 78 | | sed -e 's/^\(\* [MTWFS][a-z][a-z]\), \([0-3][0-9]\) \([A-Z][a-z][a-z]\) /\1 \3 \2 /' \ |
|
78 | 79 | -e '/^\* [MTWFS][a-z][a-z] /{s/ [012][0-9]:[0-9][0-9]:[0-9][0-9] [+-][0-9]\{4\}//}' \ |
|
79 | 80 | >> $tmpspec |
|
80 | 81 | |
|
81 | 82 | rpmbuild --define "_topdir $rpmdir" -bb $tmpspec |
|
82 | 83 | if [ $? = 0 ]; then |
|
83 | 84 | rm -rf $tmpspec $rpmdir/BUILD |
|
84 | 85 | mv $rpmdir/RPMS/*/* $rpmdir && rm -r $rpmdir/RPMS |
|
85 | 86 | echo |
|
86 | 87 | echo "Packages are in $rpmdir:" |
|
87 | 88 | ls -l $rpmdir/*.rpm |
|
88 | 89 | fi |
General Comments 0
You need to be logged in to leave comments.
Login now