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