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