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