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