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