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