##// END OF EJS Templates
builddeb: new script for building a deb package...
Augie Fackler -
r24971:ab75baaf default
parent child Browse files
Show More
@@ -0,0 +1,76 b''
1 #!/bin/sh -e
2 #
3 # Build a Mercurial debian package from the current repo
4 #
5 # Tested on Jessie (stable as of original script authoring.)
6
7 BUILD=1
8 DEBBUILDDIR="$PWD/debbuild"
9 while [ "$1" ]; do
10 case "$1" in
11 --prepare )
12 shift
13 BUILD=
14 ;;
15 --debbuilddir )
16 shift
17 DEBBUILDDIR="$1"
18 shift
19 ;;
20 * )
21 echo "Invalid parameter $1!" 1>&2
22 exit 1
23 ;;
24 esac
25 done
26
27 set -u
28
29 rm -rf $DEBBUILDDIR
30 mkdir -p $DEBBUILDDIR
31
32 if [ ! -d .hg ]; then
33 echo 'You are not inside a Mercurial repository!' 1>&2
34 exit 1
35 fi
36
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
54
55 cp -r $PWD/contrib/debian $DEBBUILDDIR/DEBIAN
56 chmod -R 0755 $DEBBUILDDIR/DEBIAN
57
58 control=$DEBBUILDDIR/DEBIAN/control
59
60 # This looks like sed -i, but sed -i behaves just differently enough
61 # between BSD and GNU sed that I gave up and did the dumb thing.
62 sed "s/__VERSION__/$version/" < $control > $control.tmp
63 mv $control.tmp $control
64
65 if [ "$BUILD" ]; then
66 dpkg-deb --build $DEBBUILDDIR
67 mv $DEBBUILDDIR.deb $DEBBUILDDIR/mercurial-$version-$release.deb
68 if [ $? = 0 ]; then
69 echo
70 echo "Built packages for $version-$release:"
71 find $DEBBUILDDIR/ -type f -newer $control
72 fi
73 else
74 echo "Prepared sources for $version-$release $control are in $DEBBUILDDIR - use like:"
75 echo "dpkg-deb --build $DEBBUILDDIR"
76 fi
@@ -0,0 +1,9 b''
1 Package: mercurial
2 Version: __VERSION__
3 Section: vcs
4 Priority: optional
5 Architecture: all
6 Depends: python
7 Conflicts: mercurial-common
8 Maintainer: Mercurial Developers <mercurial-devel@selenic.com>
9 Description: Mercurial (probably nightly) package built by upstream.
@@ -1,216 +1,222 b''
1 1 # If you want to change PREFIX, do not just edit it below. The changed
2 2 # value wont get passed on to recursive make calls. You should instead
3 3 # override the variable on the command like:
4 4 #
5 5 # % make PREFIX=/opt/ install
6 6
7 7 PREFIX=/usr/local
8 8 export PREFIX
9 9 PYTHON=python
10 10 $(eval HGROOT := $(shell pwd))
11 11 HGPYTHONS ?= $(HGROOT)/build/pythons
12 12 PURE=
13 13 PYFILES:=$(shell find mercurial hgext doc -name '*.py')
14 14 DOCFILES=mercurial/help/*.txt
15 15 export LANGUAGE=C
16 16 export LC_ALL=C
17 17 TESTFLAGS ?= $(shell echo $$HGTESTFLAGS)
18 18
19 19 # Set this to e.g. "mingw32" to use a non-default compiler.
20 20 COMPILER=
21 21
22 22 help:
23 23 @echo 'Commonly used make targets:'
24 24 @echo ' all - build program and documentation'
25 25 @echo ' install - install program and man pages to $$PREFIX ($(PREFIX))'
26 26 @echo ' install-home - install with setup.py install --home=$$HOME ($(HOME))'
27 27 @echo ' local - build for inplace usage'
28 28 @echo ' tests - run all tests in the automatic test suite'
29 29 @echo ' test-foo - run only specified tests (e.g. test-merge1.t)'
30 30 @echo ' dist - run all tests and create a source tarball in dist/'
31 31 @echo ' clean - remove files created by other targets'
32 32 @echo ' (except installed files or dist source tarball)'
33 33 @echo ' update-pot - update i18n/hg.pot'
34 34 @echo
35 35 @echo 'Example for a system-wide installation under /usr/local:'
36 36 @echo ' make all && su -c "make install" && hg version'
37 37 @echo
38 38 @echo 'Example for a local installation (usable in this directory):'
39 39 @echo ' make local && ./hg version'
40 40
41 41 all: build doc
42 42
43 43 local:
44 44 $(PYTHON) setup.py $(PURE) \
45 45 build_py -c -d . \
46 46 build_ext $(COMPILER:%=-c %) -i \
47 47 build_hgexe $(COMPILER:%=-c %) -i \
48 48 build_mo
49 49 env HGRCPATH= $(PYTHON) hg version
50 50
51 51 build:
52 52 $(PYTHON) setup.py $(PURE) build $(COMPILER:%=-c %)
53 53
54 54 doc:
55 55 $(MAKE) -C doc
56 56
57 57 clean:
58 58 -$(PYTHON) setup.py clean --all # ignore errors from this command
59 59 find contrib doc hgext i18n mercurial tests \
60 60 \( -name '*.py[cdo]' -o -name '*.so' \) -exec rm -f '{}' ';'
61 61 rm -f $(addprefix mercurial/,$(notdir $(wildcard mercurial/pure/[a-z]*.py)))
62 62 rm -f MANIFEST MANIFEST.in hgext/__index__.py tests/*.err
63 63 if test -d .hg; then rm -f mercurial/__version__.py; fi
64 64 rm -rf build mercurial/locale
65 65 $(MAKE) -C doc clean
66 66
67 67 install: install-bin install-doc
68 68
69 69 install-bin: build
70 70 $(PYTHON) setup.py $(PURE) install --root="$(DESTDIR)/" --prefix="$(PREFIX)" --force
71 71
72 72 install-doc: doc
73 73 cd doc && $(MAKE) $(MFLAGS) install
74 74
75 75 install-home: install-home-bin install-home-doc
76 76
77 77 install-home-bin: build
78 78 $(PYTHON) setup.py $(PURE) install --home="$(HOME)" --prefix="" --force
79 79
80 80 install-home-doc: doc
81 81 cd doc && $(MAKE) $(MFLAGS) PREFIX="$(HOME)" install
82 82
83 83 MANIFEST-doc:
84 84 $(MAKE) -C doc MANIFEST
85 85
86 86 MANIFEST.in: MANIFEST-doc
87 87 hg manifest | sed -e 's/^/include /' > MANIFEST.in
88 88 echo include mercurial/__version__.py >> MANIFEST.in
89 89 sed -e 's/^/include /' < doc/MANIFEST >> MANIFEST.in
90 90
91 91 dist: tests dist-notests
92 92
93 93 dist-notests: doc MANIFEST.in
94 94 TAR_OPTIONS="--owner=root --group=root --mode=u+w,go-w,a+rX-s" $(PYTHON) setup.py -q sdist
95 95
96 96 check: tests
97 97
98 98 tests:
99 99 cd tests && $(PYTHON) run-tests.py $(TESTFLAGS)
100 100
101 101 test-%:
102 102 cd tests && $(PYTHON) run-tests.py $(TESTFLAGS) $@
103 103
104 104 testpy-%:
105 105 @echo Looking for Python $* in $(HGPYTHONS)
106 106 [ -e $(HGPYTHONS)/$*/bin/python ] || ( \
107 107 cd $$(mktemp --directory --tmpdir) && \
108 108 $(MAKE) -f $(HGROOT)/contrib/Makefile.python PYTHONVER=$* PREFIX=$(HGPYTHONS)/$* python )
109 109 cd tests && $(HGPYTHONS)/$*/bin/python run-tests.py $(TESTFLAGS)
110 110
111 111 check-code:
112 112 hg manifest | xargs python contrib/check-code.py
113 113
114 114 update-pot: i18n/hg.pot
115 115
116 116 i18n/hg.pot: $(PYFILES) $(DOCFILES) i18n/posplit i18n/hggettext
117 117 $(PYTHON) i18n/hggettext mercurial/commands.py \
118 118 hgext/*.py hgext/*/__init__.py \
119 119 mercurial/fileset.py mercurial/revset.py \
120 120 mercurial/templatefilters.py mercurial/templatekw.py \
121 121 mercurial/templater.py \
122 122 mercurial/filemerge.py \
123 123 mercurial/hgweb/webcommands.py \
124 124 $(DOCFILES) > i18n/hg.pot.tmp
125 125 # All strings marked for translation in Mercurial contain
126 126 # ASCII characters only. But some files contain string
127 127 # literals like this '\037\213'. xgettext thinks it has to
128 128 # parse them even though they are not marked for translation.
129 129 # Extracting with an explicit encoding of ISO-8859-1 will make
130 130 # xgettext "parse" and ignore them.
131 131 echo $(PYFILES) | xargs \
132 132 xgettext --package-name "Mercurial" \
133 133 --msgid-bugs-address "<mercurial-devel@selenic.com>" \
134 134 --copyright-holder "Matt Mackall <mpm@selenic.com> and others" \
135 135 --from-code ISO-8859-1 --join --sort-by-file --add-comments=i18n: \
136 136 -d hg -p i18n -o hg.pot.tmp
137 137 $(PYTHON) i18n/posplit i18n/hg.pot.tmp
138 138 # The target file is not created before the last step. So it never is in
139 139 # an intermediate state.
140 140 mv -f i18n/hg.pot.tmp i18n/hg.pot
141 141
142 142 %.po: i18n/hg.pot
143 143 # work on a temporary copy for never having a half completed target
144 144 cp $@ $@.tmp
145 145 msgmerge --no-location --update $@.tmp $^
146 146 mv -f $@.tmp $@
147 147
148 148 # Packaging targets
149 149
150 150 osx:
151 151 python -c 'import bdist_mpkg.script_bdist_mpkg' || \
152 152 (echo "Missing bdist_mpkg (easy_install bdist_mpkg)"; false)
153 153 rm -rf dist/mercurial-*.mpkg
154 154 python -m bdist_mpkg.script_bdist_mpkg setup.py --
155 155 python contrib/fixpax.py dist/mercurial-*.mpkg/Contents/Packages/*.pkg/Contents/Archive.pax.gz
156 156 mkdir -p packages/osx
157 157 N=`cd dist && echo mercurial-*.mpkg | sed 's,\.mpkg$$,,'` && hdiutil create -srcfolder dist/$$N.mpkg/ -scrub -volname "$$N" -ov packages/osx/$$N.dmg
158 158 rm -rf dist/mercurial-*.mpkg
159 159
160 debian-jessie:
161 mkdir -p packages/debian-jessie
162 contrib/builddeb
163 mv debbuild/*.deb packages/debian-jessie
164 rm -rf debbuild
165
160 166 fedora20:
161 167 mkdir -p packages/fedora20
162 168 contrib/buildrpm
163 169 cp rpmbuild/RPMS/*/* packages/fedora20
164 170 cp rpmbuild/SRPMS/* packages/fedora20
165 171 rm -rf rpmbuild
166 172
167 173 docker-fedora20:
168 174 mkdir -p packages/fedora20
169 175 contrib/dockerrpm fedora20
170 176
171 177 fedora21:
172 178 mkdir -p packages/fedora21
173 179 contrib/buildrpm
174 180 cp rpmbuild/RPMS/*/* packages/fedora21
175 181 cp rpmbuild/SRPMS/* packages/fedora21
176 182 rm -rf rpmbuild
177 183
178 184 docker-fedora21:
179 185 mkdir -p packages/fedora21
180 186 contrib/dockerrpm fedora21
181 187
182 188 centos5:
183 189 mkdir -p packages/centos5
184 190 contrib/buildrpm --withpython
185 191 cp rpmbuild/RPMS/*/* packages/centos5
186 192 cp rpmbuild/SRPMS/* packages/centos5
187 193
188 194 docker-centos5:
189 195 mkdir -p packages/centos5
190 196 contrib/dockerrpm centos5 --withpython
191 197
192 198 centos6:
193 199 mkdir -p packages/centos6
194 200 contrib/buildrpm
195 201 cp rpmbuild/RPMS/*/* packages/centos6
196 202 cp rpmbuild/SRPMS/* packages/centos6
197 203
198 204 docker-centos6:
199 205 mkdir -p packages/centos6
200 206 contrib/dockerrpm centos6
201 207
202 208 centos7:
203 209 mkdir -p packages/centos7
204 210 contrib/buildrpm
205 211 cp rpmbuild/RPMS/*/* packages/centos7
206 212 cp rpmbuild/SRPMS/* packages/centos7
207 213
208 214 docker-centos7:
209 215 mkdir -p packages/centos7
210 216 contrib/dockerrpm centos7
211 217
212 218 .PHONY: help all local build doc clean install install-bin install-doc \
213 219 install-home install-home-bin install-home-doc \
214 220 dist dist-notests check tests check-code update-pot \
215 221 osx fedora20 docker-fedora20 fedora21 docker-fedora21 \
216 222 centos5 docker-centos5 centos6 docker-centos6 centos7 docker-centos7
General Comments 0
You need to be logged in to leave comments. Login now