Show More
@@ -1,78 +1,110 | |||
|
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 | 37 | mkdir -p $rpmdir/SOURCES $rpmdir/SPECS $rpmdir/RPMS $rpmdir/SRPMS $rpmdir/BUILD |
|
38 | 38 | |
|
39 | 39 | # make setup.py build the version string |
|
40 | 40 | python setup.py build_py -c -d . |
|
41 | 41 | hgversion=`$HG version | sed -ne 's/.*(version \(.*\))$/\1/p'` |
|
42 | 42 | |
|
43 | 43 | if echo $hgversion | grep -- '-' > /dev/null 2>&1; then |
|
44 | 44 | # nightly build case, version is like 1.3.1+250-20b91f91f9ca |
|
45 | 45 | version=`echo $hgversion | cut -d- -f1` |
|
46 | 46 | release=`echo $hgversion | cut -d- -f2 | sed -e 's/+.*//'` |
|
47 | 47 | else |
|
48 | 48 | # official tag, version is like 1.3.1 |
|
49 | 49 | version=`echo $hgversion | sed -e 's/+.*//'` |
|
50 | 50 | release='0' |
|
51 | 51 | fi |
|
52 | 52 | |
|
53 | 53 | $HG archive -t tgz $rpmdir/SOURCES/mercurial-$version.tar.gz |
|
54 | 54 | rpmspec=$rpmdir/SPECS/mercurial-$version.spec |
|
55 | 55 | |
|
56 | 56 | sed -e "s,^Version:.*,Version: $version," \ |
|
57 | 57 | -e "s,^Release:.*,Release: $release," \ |
|
58 | 58 | $specfile > $rpmspec |
|
59 | 59 | |
|
60 |
|
|
|
61 | %changelog | |
|
62 | * `LANG=en_US date +'%a %b %d %Y'` `$HG showconfig ui.username` $version-$release | |
|
63 | - Automatically built via $0 | |
|
60 | echo >> $rpmspec | |
|
61 | echo "%changelog" >> $rpmspec | |
|
62 | ||
|
63 | if echo $version | grep '+' > /dev/null 2>&1; then | |
|
64 | latesttag="`echo $version | sed -e 's/+.*//'`" | |
|
65 | $HG log -r .:"$latesttag" -fM \ | |
|
66 | --template '{date|hgdate}\t{author}\t{desc|firstline}\n' | python -c ' | |
|
67 | import sys, time | |
|
68 | ||
|
69 | def datestr(date, format): | |
|
70 | return time.strftime(format, time.gmtime(float(date[0]) - date[1])) | |
|
64 | 71 | |
|
65 | EOF | |
|
66 | $HG log \ | |
|
67 | --template '* {date|rfc822date} {author}\n- {desc|firstline}\n\n' \ | |
|
68 | .hgtags \ | |
|
69 | | sed -e 's/^\(\* [MTWFS][a-z][a-z]\), \([0-3][0-9]\) \([A-Z][a-z][a-z]\) /\1 \3 \2 /' \ | |
|
70 | -e '/^\* [MTWFS][a-z][a-z] /{s/ [012][0-9]:[0-9][0-9]:[0-9][0-9] [+-][0-9]\{4\}//}' \ | |
|
71 | >> $rpmspec | |
|
72 | changelog = [] | |
|
73 | for l in sys.stdin.readlines(): | |
|
74 | tok = l.split("\t") | |
|
75 | hgdate = tuple(int(v) for v in tok[0].split()) | |
|
76 | changelog.append((datestr(hgdate, "%F"), tok[1], hgdate, tok[2])) | |
|
77 | prevtitle = "" | |
|
78 | for l in sorted(changelog, reverse=True): | |
|
79 | title = "* %s %s" % (datestr(l[2], "%a %b %d %Y"), l[1]) | |
|
80 | if prevtitle != title: | |
|
81 | prevtitle = title | |
|
82 | ||
|
83 | print title | |
|
84 | print "- %s" % l[3].strip() | |
|
85 | ' >> $rpmspec | |
|
86 | ||
|
87 | else | |
|
88 | ||
|
89 | $HG log \ | |
|
90 | --template '{date|hgdate}\t{author}\t{desc|firstline}\n' \ | |
|
91 | .hgtags | python -c ' | |
|
92 | import sys, time | |
|
93 | ||
|
94 | def datestr(date, format): | |
|
95 | return time.strftime(format, time.gmtime(float(date[0]) - date[1])) | |
|
96 | ||
|
97 | for l in sys.stdin.readlines(): | |
|
98 | tok = l.split("\t") | |
|
99 | hgdate = tuple(int(v) for v in tok[0].split()) | |
|
100 | print "* %s %s\n- %s" % (datestr(hgdate, "%a %b %d %Y"), tok[1], tok[2]) | |
|
101 | ' >> $rpmspec | |
|
102 | ||
|
103 | fi | |
|
72 | 104 | |
|
73 | 105 | rpmbuild --define "_topdir $rpmdir" -ba $rpmspec --clean |
|
74 | 106 | if [ $? = 0 ]; then |
|
75 | 107 | echo |
|
76 | 108 | echo "Packages are in $rpmdir:" |
|
77 | 109 | ls -l $rpmdir/*RPMS/* |
|
78 | 110 | fi |
General Comments 0
You need to be logged in to leave comments.
Login now