Show More
@@ -1,161 +1,163 | |||
|
1 | 1 | #!/bin/bash -e |
|
2 | 2 | # |
|
3 | 3 | # Build a Mercurial RPM from the current repo |
|
4 | 4 | # |
|
5 | 5 | # Tested on |
|
6 | 6 | # - Fedora 20 |
|
7 | 7 | # - CentOS 5 |
|
8 | 8 | # - centOS 6 |
|
9 | 9 | |
|
10 | 10 | . $(dirname $0)/packagelib.sh |
|
11 | 11 | |
|
12 | 12 | BUILD=1 |
|
13 | 13 | RPMBUILDDIR="$PWD/rpmbuild" |
|
14 | export HGPLAIN= | |
|
15 | ||
|
14 | 16 | while [ "$1" ]; do |
|
15 | 17 | case "$1" in |
|
16 | 18 | --prepare ) |
|
17 | 19 | shift |
|
18 | 20 | BUILD= |
|
19 | 21 | ;; |
|
20 | 22 | --withpython | --with-python) |
|
21 | 23 | shift |
|
22 | 24 | PYTHONVER=2.7.10 |
|
23 | 25 | PYTHONMD5=d7547558fd673bd9d38e2108c6b42521 |
|
24 | 26 | ;; |
|
25 | 27 | --rpmbuilddir ) |
|
26 | 28 | shift |
|
27 | 29 | RPMBUILDDIR="$1" |
|
28 | 30 | shift |
|
29 | 31 | ;; |
|
30 | 32 | * ) |
|
31 | 33 | echo "Invalid parameter $1!" 1>&2 |
|
32 | 34 | exit 1 |
|
33 | 35 | ;; |
|
34 | 36 | esac |
|
35 | 37 | done |
|
36 | 38 | |
|
37 | 39 | cd "`dirname $0`/.." |
|
38 | 40 | |
|
39 | 41 | specfile=$PWD/contrib/mercurial.spec |
|
40 | 42 | if [ ! -f $specfile ]; then |
|
41 | 43 | echo "Cannot find $specfile!" 1>&2 |
|
42 | 44 | exit 1 |
|
43 | 45 | fi |
|
44 | 46 | |
|
45 | 47 | if [ ! -d .hg ]; then |
|
46 | 48 | echo 'You are not inside a Mercurial repository!' 1>&2 |
|
47 | 49 | exit 1 |
|
48 | 50 | fi |
|
49 | 51 | |
|
50 | 52 | gethgversion |
|
51 | 53 | |
|
52 | 54 | # TODO: handle distance/node set, and type set |
|
53 | 55 | |
|
54 | 56 | if [ -z "$type" ] ; then |
|
55 | 57 | release=1 |
|
56 | 58 | else |
|
57 | 59 | release=0.9_$type |
|
58 | 60 | fi |
|
59 | 61 | |
|
60 | 62 | if [ -n "$distance" ] ; then |
|
61 | 63 | release=$release+$distance_$node |
|
62 | 64 | fi |
|
63 | 65 | |
|
64 | 66 | if [ "$PYTHONVER" ]; then |
|
65 | 67 | release=$release+$PYTHONVER |
|
66 | 68 | RPMPYTHONVER=$PYTHONVER |
|
67 | 69 | else |
|
68 | 70 | RPMPYTHONVER=%{nil} |
|
69 | 71 | fi |
|
70 | 72 | |
|
71 | 73 | mkdir -p $RPMBUILDDIR/{SOURCES,BUILD,SRPMS,RPMS} |
|
72 | 74 | $HG archive -t tgz $RPMBUILDDIR/SOURCES/mercurial-$version-$release.tar.gz |
|
73 | 75 | if [ "$PYTHONVER" ]; then |
|
74 | 76 | ( |
|
75 | 77 | mkdir -p build |
|
76 | 78 | cd build |
|
77 | 79 | PYTHON_SRCFILE=Python-$PYTHONVER.tgz |
|
78 | 80 | [ -f $PYTHON_SRCFILE ] || curl -Lo $PYTHON_SRCFILE http://www.python.org/ftp/python/$PYTHONVER/$PYTHON_SRCFILE |
|
79 | 81 | if [ "$PYTHONMD5" ]; then |
|
80 | 82 | echo "$PYTHONMD5 $PYTHON_SRCFILE" | md5sum -w -c |
|
81 | 83 | fi |
|
82 | 84 | ln -f $PYTHON_SRCFILE $RPMBUILDDIR/SOURCES/$PYTHON_SRCFILE |
|
83 | 85 | |
|
84 | 86 | DOCUTILSVER=`sed -ne "s/^%global docutilsname docutils-//p" $specfile` |
|
85 | 87 | DOCUTILS_SRCFILE=docutils-$DOCUTILSVER.tar.gz |
|
86 | 88 | [ -f $DOCUTILS_SRCFILE ] || curl -Lo $DOCUTILS_SRCFILE http://downloads.sourceforge.net/project/docutils/docutils/$DOCUTILSVER/$DOCUTILS_SRCFILE |
|
87 | 89 | DOCUTILSMD5=`sed -ne "s/^%global docutilsmd5 //p" $specfile` |
|
88 | 90 | if [ "$DOCUTILSMD5" ]; then |
|
89 | 91 | echo "$DOCUTILSMD5 $DOCUTILS_SRCFILE" | md5sum -w -c |
|
90 | 92 | fi |
|
91 | 93 | ln -f $DOCUTILS_SRCFILE $RPMBUILDDIR/SOURCES/$DOCUTILS_SRCFILE |
|
92 | 94 | ) |
|
93 | 95 | fi |
|
94 | 96 | |
|
95 | 97 | mkdir -p $RPMBUILDDIR/SPECS |
|
96 | 98 | rpmspec=$RPMBUILDDIR/SPECS/mercurial.spec |
|
97 | 99 | |
|
98 | 100 | sed -e "s,^Version:.*,Version: $version," \ |
|
99 | 101 | -e "s,^Release:.*,Release: $release," \ |
|
100 | 102 | $specfile > $rpmspec |
|
101 | 103 | |
|
102 | 104 | echo >> $rpmspec |
|
103 | 105 | echo "%changelog" >> $rpmspec |
|
104 | 106 | |
|
105 | 107 | if echo $version | grep '+' > /dev/null 2>&1; then |
|
106 | 108 | latesttag="`echo $version | sed -e 's/+.*//'`" |
|
107 | 109 | $HG log -r .:"$latesttag" -fM \ |
|
108 | 110 | --template '{date|hgdate}\t{author}\t{desc|firstline}\n' | python -c ' |
|
109 | 111 | import sys, time |
|
110 | 112 | |
|
111 | 113 | def datestr(date, format): |
|
112 | 114 | return time.strftime(format, time.gmtime(float(date[0]) - date[1])) |
|
113 | 115 | |
|
114 | 116 | changelog = [] |
|
115 | 117 | for l in sys.stdin.readlines(): |
|
116 | 118 | tok = l.split("\t") |
|
117 | 119 | hgdate = tuple(int(v) for v in tok[0].split()) |
|
118 | 120 | changelog.append((datestr(hgdate, "%F"), tok[1], hgdate, tok[2])) |
|
119 | 121 | prevtitle = "" |
|
120 | 122 | for l in sorted(changelog, reverse=True): |
|
121 | 123 | title = "* %s %s" % (datestr(l[2], "%a %b %d %Y"), l[1]) |
|
122 | 124 | if prevtitle != title: |
|
123 | 125 | prevtitle = title |
|
124 | 126 | |
|
125 | 127 | print title |
|
126 | 128 | print "- %s" % l[3].strip() |
|
127 | 129 | ' >> $rpmspec |
|
128 | 130 | |
|
129 | 131 | else |
|
130 | 132 | |
|
131 | 133 | $HG log \ |
|
132 | 134 | --template '{date|hgdate}\t{author}\t{desc|firstline}\n' \ |
|
133 | 135 | .hgtags | python -c ' |
|
134 | 136 | import sys, time |
|
135 | 137 | |
|
136 | 138 | def datestr(date, format): |
|
137 | 139 | return time.strftime(format, time.gmtime(float(date[0]) - date[1])) |
|
138 | 140 | |
|
139 | 141 | for l in sys.stdin.readlines(): |
|
140 | 142 | tok = l.split("\t") |
|
141 | 143 | hgdate = tuple(int(v) for v in tok[0].split()) |
|
142 | 144 | print "* %s %s\n- %s" % (datestr(hgdate, "%a %b %d %Y"), tok[1], tok[2]) |
|
143 | 145 | ' >> $rpmspec |
|
144 | 146 | |
|
145 | 147 | fi |
|
146 | 148 | |
|
147 | 149 | sed -i \ |
|
148 | 150 | -e "s/^%define withpython.*$/%define withpython $RPMPYTHONVER/" \ |
|
149 | 151 | $rpmspec |
|
150 | 152 | |
|
151 | 153 | if [ "$BUILD" ]; then |
|
152 | 154 | rpmbuild --define "_topdir $RPMBUILDDIR" -ba $rpmspec --clean |
|
153 | 155 | if [ $? = 0 ]; then |
|
154 | 156 | echo |
|
155 | 157 | echo "Built packages for $version-$release:" |
|
156 | 158 | find $RPMBUILDDIR/*RPMS/ -type f -newer $rpmspec |
|
157 | 159 | fi |
|
158 | 160 | else |
|
159 | 161 | echo "Prepared sources for $version-$release $rpmspec are in $RPMBUILDDIR/SOURCES/ - use like:" |
|
160 | 162 | echo "rpmbuild --define '_topdir $RPMBUILDDIR' -ba $rpmspec --clean" |
|
161 | 163 | fi |
General Comments 0
You need to be logged in to leave comments.
Login now