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