Show More
@@ -0,0 +1,19 b'' | |||
|
1 | gethgversion() { | |
|
2 | make clean | |
|
3 | make local || make local PURE=--pure | |
|
4 | HG="$PWD/hg" | |
|
5 | ||
|
6 | $HG version > /dev/null || { echo 'abort: hg version failed!'; exit 1 ; } | |
|
7 | ||
|
8 | hgversion=`$HG version | sed -ne 's/.*(version \(.*\))$/\1/p'` | |
|
9 | ||
|
10 | if echo $hgversion | grep -- '-' > /dev/null 2>&1; then | |
|
11 | # nightly build case, version is like 1.3.1+250-20b91f91f9ca | |
|
12 | version=`echo $hgversion | cut -d- -f1` | |
|
13 | release=`echo $hgversion | cut -d- -f2 | sed -e 's/+.*//'` | |
|
14 | else | |
|
15 | # official tag, version is like 1.3.1 | |
|
16 | version=`echo $hgversion | sed -e 's/+.*//'` | |
|
17 | release='0' | |
|
18 | fi | |
|
19 | } |
@@ -1,76 +1,62 b'' | |||
|
1 | 1 | #!/bin/sh -e |
|
2 | 2 | # |
|
3 | 3 | # Build a Mercurial debian package from the current repo |
|
4 | 4 | # |
|
5 | 5 | # Tested on Jessie (stable as of original script authoring.) |
|
6 | 6 | |
|
7 | . $(dirname $0)/packagelib.sh | |
|
8 | ||
|
7 | 9 | BUILD=1 |
|
8 | 10 | DEBBUILDDIR="$PWD/debbuild" |
|
9 | 11 | while [ "$1" ]; do |
|
10 | 12 | case "$1" in |
|
11 | 13 | --prepare ) |
|
12 | 14 | shift |
|
13 | 15 | BUILD= |
|
14 | 16 | ;; |
|
15 | 17 | --debbuilddir ) |
|
16 | 18 | shift |
|
17 | 19 | DEBBUILDDIR="$1" |
|
18 | 20 | shift |
|
19 | 21 | ;; |
|
20 | 22 | * ) |
|
21 | 23 | echo "Invalid parameter $1!" 1>&2 |
|
22 | 24 | exit 1 |
|
23 | 25 | ;; |
|
24 | 26 | esac |
|
25 | 27 | done |
|
26 | 28 | |
|
27 | 29 | set -u |
|
28 | 30 | |
|
29 | 31 | rm -rf $DEBBUILDDIR |
|
30 | 32 | mkdir -p $DEBBUILDDIR |
|
31 | 33 | |
|
32 | 34 | if [ ! -d .hg ]; then |
|
33 | 35 | echo 'You are not inside a Mercurial repository!' 1>&2 |
|
34 | 36 | exit 1 |
|
35 | 37 | fi |
|
36 | 38 | |
|
37 | # build local hg and use it | |
|
38 | python setup.py build_py -c -d . | |
|
39 | HG="$PWD/hg" | |
|
40 | ||
|
41 | $HG version > /dev/null || { echo 'abort: hg version failed!'; exit 1 ; } | |
|
42 | ||
|
43 | hgversion=`$HG version | sed -ne 's/.*(version \(.*\))$/\1/p'` | |
|
44 | ||
|
45 | if echo $hgversion | grep -- '-' > /dev/null 2>&1; then | |
|
46 | # nightly build case, version is like 1.3.1+250-20b91f91f9ca | |
|
47 | version=`echo $hgversion | cut -d- -f1` | |
|
48 | release=`echo $hgversion | cut -d- -f2 | sed -e 's/+.*//'` | |
|
49 | else | |
|
50 | # official tag, version is like 1.3.1 | |
|
51 | version=`echo $hgversion | sed -e 's/+.*//'` | |
|
52 | release='0' | |
|
53 | fi | |
|
39 | gethgversion | |
|
54 | 40 | |
|
55 | 41 | cp -r $PWD/contrib/debian $DEBBUILDDIR/DEBIAN |
|
56 | 42 | chmod -R 0755 $DEBBUILDDIR/DEBIAN |
|
57 | 43 | |
|
58 | 44 | control=$DEBBUILDDIR/DEBIAN/control |
|
59 | 45 | |
|
60 | 46 | # This looks like sed -i, but sed -i behaves just differently enough |
|
61 | 47 | # between BSD and GNU sed that I gave up and did the dumb thing. |
|
62 | 48 | sed "s/__VERSION__/$version/" < $control > $control.tmp |
|
63 | 49 | mv $control.tmp $control |
|
64 | 50 | |
|
65 | 51 | if [ "$BUILD" ]; then |
|
66 | 52 | dpkg-deb --build $DEBBUILDDIR |
|
67 | 53 | mv $DEBBUILDDIR.deb $DEBBUILDDIR/mercurial-$version-$release.deb |
|
68 | 54 | if [ $? = 0 ]; then |
|
69 | 55 | echo |
|
70 | 56 | echo "Built packages for $version-$release:" |
|
71 | 57 | find $DEBBUILDDIR/ -type f -newer $control |
|
72 | 58 | fi |
|
73 | 59 | else |
|
74 | 60 | echo "Prepared sources for $version-$release $control are in $DEBBUILDDIR - use like:" |
|
75 | 61 | echo "dpkg-deb --build $DEBBUILDDIR" |
|
76 | 62 | fi |
@@ -1,162 +1,147 b'' | |||
|
1 | 1 | #!/bin/sh -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 | . $(dirname $0)/packagelib.sh | |
|
11 | ||
|
10 | 12 | BUILD=1 |
|
11 | 13 | RPMBUILDDIR="$PWD/rpmbuild" |
|
12 | 14 | while [ "$1" ]; do |
|
13 | 15 | case "$1" in |
|
14 | 16 | --prepare ) |
|
15 | 17 | shift |
|
16 | 18 | BUILD= |
|
17 | 19 | ;; |
|
18 | 20 | --withpython | --with-python) |
|
19 | 21 | shift |
|
20 | 22 | PYTHONVER=2.7.9 |
|
21 | 23 | PYTHONMD5=5eebcaa0030dc4061156d3429657fb83 |
|
22 | 24 | ;; |
|
23 | 25 | --rpmbuilddir ) |
|
24 | 26 | shift |
|
25 | 27 | RPMBUILDDIR="$1" |
|
26 | 28 | shift |
|
27 | 29 | ;; |
|
28 | 30 | * ) |
|
29 | 31 | echo "Invalid parameter $1!" 1>&2 |
|
30 | 32 | exit 1 |
|
31 | 33 | ;; |
|
32 | 34 | esac |
|
33 | 35 | done |
|
34 | 36 | |
|
35 | 37 | cd "`dirname $0`/.." |
|
36 | 38 | |
|
37 | 39 | specfile=$PWD/contrib/mercurial.spec |
|
38 | 40 | if [ ! -f $specfile ]; then |
|
39 | 41 | echo "Cannot find $specfile!" 1>&2 |
|
40 | 42 | exit 1 |
|
41 | 43 | fi |
|
42 | 44 | |
|
43 | 45 | if [ ! -d .hg ]; then |
|
44 | 46 | echo 'You are not inside a Mercurial repository!' 1>&2 |
|
45 | 47 | exit 1 |
|
46 | 48 | fi |
|
47 | 49 | |
|
48 | # build local hg and use it | |
|
49 | python setup.py build_py -c -d . | |
|
50 | HG="$PWD/hg" | |
|
51 | PYTHONPATH="$PWD/mercurial/pure" | |
|
52 | export PYTHONPATH | |
|
53 | ||
|
54 | mkdir -p $RPMBUILDDIR/SOURCES $RPMBUILDDIR/SPECS $RPMBUILDDIR/RPMS $RPMBUILDDIR/SRPMS $RPMBUILDDIR/BUILD | |
|
55 | ||
|
56 | hgversion=`$HG version | sed -ne 's/.*(version \(.*\))$/\1/p'` | |
|
50 | gethgversion | |
|
57 | 51 | |
|
58 | if echo $hgversion | grep -- '-' > /dev/null 2>&1; then | |
|
59 | # nightly build case, version is like 1.3.1+250-20b91f91f9ca | |
|
60 | version=`echo $hgversion | cut -d- -f1` | |
|
61 | release=`echo $hgversion | cut -d- -f2 | sed -e 's/+.*//'` | |
|
62 | else | |
|
63 | # official tag, version is like 1.3.1 | |
|
64 | version=`echo $hgversion | sed -e 's/+.*//'` | |
|
65 | release='0' | |
|
66 | fi | |
|
67 | 52 | if [ "$PYTHONVER" ]; then |
|
68 | 53 | release=$release+$PYTHONVER |
|
69 | 54 | RPMPYTHONVER=$PYTHONVER |
|
70 | 55 | else |
|
71 | 56 | RPMPYTHONVER=%{nil} |
|
72 | 57 | fi |
|
73 | 58 | |
|
74 | 59 | $HG archive -t tgz $RPMBUILDDIR/SOURCES/mercurial-$version-$release.tar.gz |
|
75 | 60 | if [ "$PYTHONVER" ]; then |
|
76 | 61 | ( |
|
77 | 62 | mkdir -p build |
|
78 | 63 | cd build |
|
79 | 64 | PYTHON_SRCFILE=Python-$PYTHONVER.tgz |
|
80 | 65 | [ -f $PYTHON_SRCFILE ] || curl -Lo $PYTHON_SRCFILE http://www.python.org/ftp/python/$PYTHONVER/$PYTHON_SRCFILE |
|
81 | 66 | if [ "$PYTHONMD5" ]; then |
|
82 | 67 | echo "$PYTHONMD5 $PYTHON_SRCFILE" | md5sum -w -c |
|
83 | 68 | fi |
|
84 | 69 | ln -f $PYTHON_SRCFILE $RPMBUILDDIR/SOURCES/$PYTHON_SRCFILE |
|
85 | 70 | |
|
86 | 71 | DOCUTILSVER=`sed -ne "s/^%global docutilsname docutils-//p" $specfile` |
|
87 | 72 | DOCUTILS_SRCFILE=docutils-$DOCUTILSVER.tar.gz |
|
88 | 73 | [ -f $DOCUTILS_SRCFILE ] || curl -Lo $DOCUTILS_SRCFILE http://downloads.sourceforge.net/project/docutils/docutils/$DOCUTILSVER/$DOCUTILS_SRCFILE |
|
89 | 74 | DOCUTILSMD5=`sed -ne "s/^%global docutilsmd5 //p" $specfile` |
|
90 | 75 | if [ "$DOCUTILSMD5" ]; then |
|
91 | 76 | echo "$DOCUTILSMD5 $DOCUTILS_SRCFILE" | md5sum -w -c |
|
92 | 77 | fi |
|
93 | 78 | ln -f $DOCUTILS_SRCFILE $RPMBUILDDIR/SOURCES/$DOCUTILS_SRCFILE |
|
94 | 79 | ) |
|
95 | 80 | fi |
|
96 | 81 | |
|
97 | 82 | rpmspec=$RPMBUILDDIR/SPECS/mercurial.spec |
|
98 | 83 | |
|
99 | 84 | sed -e "s,^Version:.*,Version: $version," \ |
|
100 | 85 | -e "s,^Release:.*,Release: $release," \ |
|
101 | 86 | $specfile > $rpmspec |
|
102 | 87 | |
|
103 | 88 | echo >> $rpmspec |
|
104 | 89 | echo "%changelog" >> $rpmspec |
|
105 | 90 | |
|
106 | 91 | if echo $version | grep '+' > /dev/null 2>&1; then |
|
107 | 92 | latesttag="`echo $version | sed -e 's/+.*//'`" |
|
108 | 93 | $HG log -r .:"$latesttag" -fM \ |
|
109 | 94 | --template '{date|hgdate}\t{author}\t{desc|firstline}\n' | python -c ' |
|
110 | 95 | import sys, time |
|
111 | 96 | |
|
112 | 97 | def datestr(date, format): |
|
113 | 98 | return time.strftime(format, time.gmtime(float(date[0]) - date[1])) |
|
114 | 99 | |
|
115 | 100 | changelog = [] |
|
116 | 101 | for l in sys.stdin.readlines(): |
|
117 | 102 | tok = l.split("\t") |
|
118 | 103 | hgdate = tuple(int(v) for v in tok[0].split()) |
|
119 | 104 | changelog.append((datestr(hgdate, "%F"), tok[1], hgdate, tok[2])) |
|
120 | 105 | prevtitle = "" |
|
121 | 106 | for l in sorted(changelog, reverse=True): |
|
122 | 107 | title = "* %s %s" % (datestr(l[2], "%a %b %d %Y"), l[1]) |
|
123 | 108 | if prevtitle != title: |
|
124 | 109 | prevtitle = title |
|
125 | 110 | |
|
126 | 111 | print title |
|
127 | 112 | print "- %s" % l[3].strip() |
|
128 | 113 | ' >> $rpmspec |
|
129 | 114 | |
|
130 | 115 | else |
|
131 | 116 | |
|
132 | 117 | $HG log \ |
|
133 | 118 | --template '{date|hgdate}\t{author}\t{desc|firstline}\n' \ |
|
134 | 119 | .hgtags | python -c ' |
|
135 | 120 | import sys, time |
|
136 | 121 | |
|
137 | 122 | def datestr(date, format): |
|
138 | 123 | return time.strftime(format, time.gmtime(float(date[0]) - date[1])) |
|
139 | 124 | |
|
140 | 125 | for l in sys.stdin.readlines(): |
|
141 | 126 | tok = l.split("\t") |
|
142 | 127 | hgdate = tuple(int(v) for v in tok[0].split()) |
|
143 | 128 | print "* %s %s\n- %s" % (datestr(hgdate, "%a %b %d %Y"), tok[1], tok[2]) |
|
144 | 129 | ' >> $rpmspec |
|
145 | 130 | |
|
146 | 131 | fi |
|
147 | 132 | |
|
148 | 133 | sed -i \ |
|
149 | 134 | -e "s/^%define withpython.*$/%define withpython $RPMPYTHONVER/" \ |
|
150 | 135 | $rpmspec |
|
151 | 136 | |
|
152 | 137 | if [ "$BUILD" ]; then |
|
153 | 138 | rpmbuild --define "_topdir $RPMBUILDDIR" -ba $rpmspec --clean |
|
154 | 139 | if [ $? = 0 ]; then |
|
155 | 140 | echo |
|
156 | 141 | echo "Built packages for $version-$release:" |
|
157 | 142 | find $RPMBUILDDIR/*RPMS/ -type f -newer $rpmspec |
|
158 | 143 | fi |
|
159 | 144 | else |
|
160 | 145 | echo "Prepared sources for $version-$release $rpmspec are in $RPMBUILDDIR/SOURCES/ - use like:" |
|
161 | 146 | echo "rpmbuild --define '_topdir $RPMBUILDDIR' -ba $rpmspec --clean" |
|
162 | 147 | fi |
General Comments 0
You need to be logged in to leave comments.
Login now