##// END OF EJS Templates
packaging: introduce generic local rpm build target using python3...
Mads Kiilerich -
r43651:69f5571d stable draft
parent child Browse files
Show More
@@ -1,261 +1,262
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 export PREFIX=/usr/local
8 8 PYTHON?=python
9 9 $(eval HGROOT := $(shell pwd))
10 10 HGPYTHONS ?= $(HGROOT)/build/pythons
11 11 PURE=
12 12 PYFILESCMD=find mercurial hgext doc -name '*.py'
13 13 PYFILES:=$(shell $(PYFILESCMD))
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 OSXVERSIONFLAGS ?= $(shell echo $$OSXVERSIONFLAGS)
19 19 CARGO = cargo
20 20
21 21 # Set this to e.g. "mingw32" to use a non-default compiler.
22 22 COMPILER=
23 23
24 24 COMPILERFLAG_tmp_ =
25 25 COMPILERFLAG_tmp_${COMPILER} ?= -c $(COMPILER)
26 26 COMPILERFLAG=${COMPILERFLAG_tmp_${COMPILER}}
27 27
28 28 help:
29 29 @echo 'Commonly used make targets:'
30 30 @echo ' all - build program and documentation'
31 31 @echo ' install - install program and man pages to $$PREFIX ($(PREFIX))'
32 32 @echo ' install-home - install with setup.py install --home=$$HOME ($(HOME))'
33 33 @echo ' local - build for inplace usage'
34 34 @echo ' tests - run all tests in the automatic test suite'
35 35 @echo ' test-foo - run only specified tests (e.g. test-merge1.t)'
36 36 @echo ' dist - run all tests and create a source tarball in dist/'
37 37 @echo ' clean - remove files created by other targets'
38 38 @echo ' (except installed files or dist source tarball)'
39 39 @echo ' update-pot - update i18n/hg.pot'
40 40 @echo
41 41 @echo 'Example for a system-wide installation under /usr/local:'
42 42 @echo ' make all && su -c "make install" && hg version'
43 43 @echo
44 44 @echo 'Example for a local installation (usable in this directory):'
45 45 @echo ' make local && ./hg version'
46 46
47 47 all: build doc
48 48
49 49 local:
50 50 $(PYTHON) setup.py $(PURE) \
51 51 build_py -c -d . \
52 52 build_ext $(COMPILERFLAG) -i \
53 53 build_hgexe $(COMPILERFLAG) -i \
54 54 build_mo
55 55 env HGRCPATH= $(PYTHON) hg version
56 56
57 57 build:
58 58 $(PYTHON) setup.py $(PURE) build $(COMPILERFLAG)
59 59
60 60 wheel:
61 61 FORCE_SETUPTOOLS=1 $(PYTHON) setup.py $(PURE) bdist_wheel $(COMPILERFLAG)
62 62
63 63 doc:
64 64 $(MAKE) -C doc
65 65
66 66 cleanbutpackages:
67 67 -$(PYTHON) setup.py clean --all # ignore errors from this command
68 68 find contrib doc hgext hgext3rd i18n mercurial tests hgdemandimport \
69 69 \( -name '*.py[cdo]' -o -name '*.so' \) -exec rm -f '{}' ';'
70 70 rm -f MANIFEST MANIFEST.in hgext/__index__.py tests/*.err
71 71 rm -f mercurial/__modulepolicy__.py
72 72 if test -d .hg; then rm -f mercurial/__version__.py; fi
73 73 rm -rf build mercurial/locale
74 74 $(MAKE) -C doc clean
75 75 $(MAKE) -C contrib/chg distclean
76 76 rm -rf rust/target
77 77 rm -f mercurial/rustext.so
78 78
79 79 clean: cleanbutpackages
80 80 rm -rf packages
81 81
82 82 install: install-bin install-doc
83 83
84 84 install-bin: build
85 85 $(PYTHON) setup.py $(PURE) install --root="$(DESTDIR)/" --prefix="$(PREFIX)" --force
86 86
87 87 install-doc: doc
88 88 cd doc && $(MAKE) $(MFLAGS) install
89 89
90 90 install-home: install-home-bin install-home-doc
91 91
92 92 install-home-bin: build
93 93 $(PYTHON) setup.py $(PURE) install --home="$(HOME)" --prefix="" --force
94 94
95 95 install-home-doc: doc
96 96 cd doc && $(MAKE) $(MFLAGS) PREFIX="$(HOME)" install
97 97
98 98 MANIFEST-doc:
99 99 $(MAKE) -C doc MANIFEST
100 100
101 101 MANIFEST.in: MANIFEST-doc
102 102 hg manifest | sed -e 's/^/include /' > MANIFEST.in
103 103 echo include mercurial/__version__.py >> MANIFEST.in
104 104 sed -e 's/^/include /' < doc/MANIFEST >> MANIFEST.in
105 105
106 106 dist: tests dist-notests
107 107
108 108 dist-notests: doc MANIFEST.in
109 109 TAR_OPTIONS="--owner=root --group=root --mode=u+w,go-w,a+rX-s" $(PYTHON) setup.py -q sdist
110 110
111 111 check: tests
112 112
113 113 tests:
114 114 # Run Rust tests if cargo is installed
115 115 if command -v $(CARGO) >/dev/null 2>&1; then \
116 116 $(MAKE) rust-tests; \
117 117 fi
118 118 cd tests && $(PYTHON) run-tests.py $(TESTFLAGS)
119 119
120 120 test-%:
121 121 cd tests && $(PYTHON) run-tests.py $(TESTFLAGS) $@
122 122
123 123 testpy-%:
124 124 @echo Looking for Python $* in $(HGPYTHONS)
125 125 [ -e $(HGPYTHONS)/$*/bin/python ] || ( \
126 126 cd $$(mktemp --directory --tmpdir) && \
127 127 $(MAKE) -f $(HGROOT)/contrib/Makefile.python PYTHONVER=$* PREFIX=$(HGPYTHONS)/$* python )
128 128 cd tests && $(HGPYTHONS)/$*/bin/python run-tests.py $(TESTFLAGS)
129 129
130 130 rust-tests: py_feature = $(shell $(PYTHON) -c \
131 131 'import sys; print(["python27-bin", "python3-bin"][sys.version_info[0] >= 3])')
132 132 rust-tests:
133 133 cd $(HGROOT)/rust/hg-cpython \
134 134 && $(CARGO) test --quiet --all \
135 135 --no-default-features --features "$(py_feature)"
136 136
137 137 check-code:
138 138 hg manifest | xargs python contrib/check-code.py
139 139
140 140 format-c:
141 141 clang-format --style file -i \
142 142 `hg files 'set:(**.c or **.cc or **.h) and not "listfile:contrib/clang-format-ignorelist"'`
143 143
144 144 update-pot: i18n/hg.pot
145 145
146 146 i18n/hg.pot: $(PYFILES) $(DOCFILES) i18n/posplit i18n/hggettext
147 147 $(PYTHON) i18n/hggettext mercurial/commands.py \
148 148 hgext/*.py hgext/*/__init__.py \
149 149 mercurial/fileset.py mercurial/revset.py \
150 150 mercurial/templatefilters.py \
151 151 mercurial/templatefuncs.py \
152 152 mercurial/templatekw.py \
153 153 mercurial/filemerge.py \
154 154 mercurial/hgweb/webcommands.py \
155 155 mercurial/util.py \
156 156 $(DOCFILES) > i18n/hg.pot.tmp
157 157 # All strings marked for translation in Mercurial contain
158 158 # ASCII characters only. But some files contain string
159 159 # literals like this '\037\213'. xgettext thinks it has to
160 160 # parse them even though they are not marked for translation.
161 161 # Extracting with an explicit encoding of ISO-8859-1 will make
162 162 # xgettext "parse" and ignore them.
163 163 $(PYFILESCMD) | xargs \
164 164 xgettext --package-name "Mercurial" \
165 165 --msgid-bugs-address "<mercurial-devel@mercurial-scm.org>" \
166 166 --copyright-holder "Matt Mackall <mpm@selenic.com> and others" \
167 167 --from-code ISO-8859-1 --join --sort-by-file --add-comments=i18n: \
168 168 -d hg -p i18n -o hg.pot.tmp
169 169 $(PYTHON) i18n/posplit i18n/hg.pot.tmp
170 170 # The target file is not created before the last step. So it never is in
171 171 # an intermediate state.
172 172 mv -f i18n/hg.pot.tmp i18n/hg.pot
173 173
174 174 %.po: i18n/hg.pot
175 175 # work on a temporary copy for never having a half completed target
176 176 cp $@ $@.tmp
177 177 msgmerge --no-location --update $@.tmp $^
178 178 mv -f $@.tmp $@
179 179
180 180 # Packaging targets
181 181
182 182 packaging_targets := \
183 183 centos5 \
184 184 centos6 \
185 185 centos7 \
186 186 deb \
187 187 docker-centos5 \
188 188 docker-centos6 \
189 189 docker-centos7 \
190 190 docker-debian-jessie \
191 191 docker-debian-stretch \
192 192 docker-fedora20 \
193 193 docker-fedora21 \
194 194 docker-fedora28 \
195 195 docker-fedora29 \
196 196 docker-ubuntu-trusty \
197 197 docker-ubuntu-trusty-ppa \
198 198 docker-ubuntu-xenial \
199 199 docker-ubuntu-xenial-ppa \
200 200 docker-ubuntu-artful \
201 201 docker-ubuntu-artful-ppa \
202 202 docker-ubuntu-bionic \
203 203 docker-ubuntu-bionic-ppa \
204 204 fedora20 \
205 205 fedora21 \
206 206 fedora28 \
207 207 fedora29 \
208 208 linux-wheels \
209 209 linux-wheels-x86_64 \
210 210 linux-wheels-i686 \
211 ppa
211 ppa \
212 rpm
212 213
213 214 # Forward packaging targets for convenience.
214 215 $(packaging_targets):
215 216 $(MAKE) -C contrib/packaging $@
216 217
217 218 osx:
218 219 rm -rf build/mercurial
219 220 /usr/bin/python2.7 setup.py install --optimize=1 \
220 221 --root=build/mercurial/ --prefix=/usr/local/ \
221 222 --install-lib=/Library/Python/2.7/site-packages/
222 223 make -C doc all install DESTDIR="$(PWD)/build/mercurial/"
223 224 # Place a bogon .DS_Store file in the target dir so we can be
224 225 # sure it doesn't get included in the final package.
225 226 touch build/mercurial/.DS_Store
226 227 # install zsh completions - this location appears to be
227 228 # searched by default as of macOS Sierra.
228 229 install -d build/mercurial/usr/local/share/zsh/site-functions/
229 230 install -m 0644 contrib/zsh_completion build/mercurial/usr/local/share/zsh/site-functions/_hg
230 231 # install bash completions - there doesn't appear to be a
231 232 # place that's searched by default for bash, so we'll follow
232 233 # the lead of Apple's git install and just put it in a
233 234 # location of our own.
234 235 install -d build/mercurial/usr/local/hg/contrib/
235 236 install -m 0644 contrib/bash_completion build/mercurial/usr/local/hg/contrib/hg-completion.bash
236 237 make -C contrib/chg \
237 238 HGPATH=/usr/local/bin/hg \
238 239 PYTHON=/usr/bin/python2.7 \
239 240 HGEXTDIR=/Library/Python/2.7/site-packages/hgext \
240 241 DESTDIR=../../build/mercurial \
241 242 PREFIX=/usr/local \
242 243 clean install
243 244 mkdir -p $${OUTPUTDIR:-dist}
244 245 HGVER=$$(python contrib/genosxversion.py $(OSXVERSIONFLAGS) build/mercurial/Library/Python/2.7/site-packages/mercurial/__version__.py) && \
245 246 OSXVER=$$(sw_vers -productVersion | cut -d. -f1,2) && \
246 247 pkgbuild --filter \\.DS_Store --root build/mercurial/ \
247 248 --identifier org.mercurial-scm.mercurial \
248 249 --version "$${HGVER}" \
249 250 build/mercurial.pkg && \
250 251 productbuild --distribution contrib/packaging/macosx/distribution.xml \
251 252 --package-path build/ \
252 253 --version "$${HGVER}" \
253 254 --resources contrib/packaging/macosx/ \
254 255 "$${OUTPUTDIR:-dist/}"/Mercurial-"$${HGVER}"-macosx"$${OSXVER}".pkg
255 256
256 257 .PHONY: help all local build doc cleanbutpackages clean install install-bin \
257 258 install-doc install-home install-home-bin install-home-doc \
258 259 dist dist-notests check tests rust-tests check-code format-c \
259 260 update-pot \
260 261 $(packaging_targets) \
261 262 osx
@@ -1,145 +1,156
1 1 $(eval HGROOT := $(shell cd ../..; pwd))
2 2
3 3 DEBIAN_CODENAMES := \
4 4 stretch \
5 5 buster \
6 6 bullseye
7 7
8 8 UBUNTU_CODENAMES := \
9 9 xenial \
10 10 bionic \
11 11 cosmic \
12 12 disco
13 13
14 14 FEDORA_RELEASES := \
15 15 20 \
16 16 21 \
17 17 28 \
18 18 29
19 19
20 20 CENTOS_RELEASES := \
21 21 5 \
22 22 6 \
23 23 7
24 24
25 25 # Build a Python for these CentOS releases.
26 26 CENTOS_WITH_PYTHON_RELEASES := 5 6
27 27
28 28 help:
29 29 @echo 'Packaging Make Targets'
30 30 @echo ''
31 31 @echo 'docker-centos{$(strip $(CENTOS_RELEASES))}'
32 32 @echo ' Build an RPM for a specific CentOS version using Docker.'
33 33 @echo ''
34 34 @echo 'docker-debian-{$(strip $(DEBIAN_CODENAMES))}'
35 35 @echo ' Build Debian packages specific to a Debian distro using Docker.'
36 36 @echo ''
37 37 @echo 'docker-fedora{$(strip $(FEDORA_RELEASES))}'
38 38 @echo ' Build an RPM for a specific Fedora version using Docker.'
39 39 @echo ''
40 40 @echo 'docker-ubuntu-{$(strip $(UBUNTU_CODENAMES))}'
41 41 @echo ' Build Debian package specific to an Ubuntu distro using Docker.'
42 42 @echo ''
43 43 @echo 'docker-ubuntu-{$(strip $(UBUNTU_CODENAMES))}-ppa'
44 44 @echo ' Build a source-only Debian package specific to an Ubuntu distro'
45 45 @echo ' using Docker.'
46 46 @echo ''
47 47 @echo 'linux-wheels'
48 48 @echo ' Build Linux manylinux wheels using Docker.'
49 49 @echo ''
50 50 @echo 'linux-wheels-{x86_64, i686}'
51 51 @echo ' Build Linux manylinux wheels for a specific architecture using Docker'
52 52 @echo ''
53 53 @echo 'deb'
54 54 @echo ' Build a Debian package locally targeting the current system'
55 55 @echo ''
56 56 @echo 'ppa'
57 57 @echo ' Build a Debian source package locally targeting the current system'
58 58 @echo ''
59 @echo 'rpm'
60 @echo ' Build a RPM targeting the current system using Python 3'
61 @echo ''
59 62 @echo 'centos{$(strip $(CENTOS_RELEASES))}'
60 63 @echo ' Build an RPM for a specific CentOS version locally'
61 64 @echo ''
62 65 @echo 'fedora{$(strip $(FEDORA_RELEASES))}'
63 66 @echo ' Build an RPM for a specific Fedora version locally'
64 67
65 68 .PHONY: help
66 69
67 70 .PHONY: deb
68 71 deb:
69 72 ./builddeb
70 73
71 74 .PHONY: ppa
72 75 ppa:
73 76 ./builddeb --source-only
74 77
75 78 # Debian targets.
76 79 define debian_targets =
77 80 .PHONY: docker-debian-$(1)
78 81 docker-debian-$(1):
79 82 ./dockerdeb debian $(1)
80 83
81 84 endef
82 85
83 86 $(foreach codename,$(DEBIAN_CODENAMES),$(eval $(call debian_targets,$(codename))))
84 87
85 88 # Ubuntu targets.
86 89 define ubuntu_targets =
87 90 .PHONY: docker-ubuntu-$(1)
88 91 docker-ubuntu-$(1):
89 92 ./dockerdeb ubuntu $(1)
90 93
91 94 .PHONY: docker-ubuntu-$(1)-ppa
92 95 docker-ubuntu-$(1)-ppa:
93 96 ./dockerdeb ubuntu $(1) --source-only
94 97
95 98 endef
96 99
97 100 $(foreach codename,$(UBUNTU_CODENAMES),$(eval $(call ubuntu_targets,$(codename))))
98 101
102 # Generic RPM target, mainly for Fedora/CentOS/RHEL.
103 rpm:
104 mkdir -p $$(HGROOT)/packages/rpm
105 ./buildrpm --python3
106 cp $$(HGROOT)/contrib/packaging/rpmbuild/RPMS/*/* $$(HGROOT)/packages/rpm
107 cp $$(HGROOT)/contrib/packaging/rpmbuild/SRPMS/* $$(HGROOT)/packages/rpm
108 rm -rf $(HGROOT)/rpmbuild
109
99 110 # Fedora targets.
100 111 define fedora_targets
101 112 .PHONY: fedora$(1)
102 113 fedora$(1):
103 114 mkdir -p $$(HGROOT)/packages/fedora$(1)
104 115 ./buildrpm
105 116 cp $$(HGROOT)/contrib/packaging/rpmbuild/RPMS/*/* $$(HGROOT)/packages/fedora$(1)
106 117 cp $$(HGROOT)/contrib/packaging/rpmbuild/SRPMS/* $$(HGROOT)/packages/fedora$(1)
107 118 rm -rf $(HGROOT)/rpmbuild
108 119
109 120 .PHONY: docker-fedora$(1)
110 121 docker-fedora$(1):
111 122 mkdir -p $$(HGROOT)/packages/fedora$(1)
112 123 ./dockerrpm fedora$(1)
113 124
114 125 endef
115 126
116 127 $(foreach release,$(FEDORA_RELEASES),$(eval $(call fedora_targets,$(release))))
117 128
118 129 # CentOS targets.
119 130 define centos_targets
120 131 .PHONY: centos$(1)
121 132 centos$(1):
122 133 mkdir -p $$(HGROOT)/packages/centos$(1)
123 134 ./buildrpm $$(if $$(filter $(1),$$(CENTOS_WITH_PYTHON_RELEASES)),--withpython)
124 135 cp $$(HGROOT)/contrib/packaging/rpmbuild/RPMS/*/* $$(HGROOT)/packages/centos$(1)
125 136 cp $$(HGROOT)/contrib/packaging/rpmbuild/SRPMS/* $$(HGROOT)/packages/centos$(1)
126 137
127 138 .PHONY: docker-centos$(1)
128 139 docker-centos$(1):
129 140 mkdir -p $$(HGROOT)/packages/centos$(1)
130 141 ./dockerrpm centos$(1) $$(if $$(filter $(1),$$(CENTOS_WITH_PYTHON_RELEASES)),--withpython)
131 142
132 143 endef
133 144
134 145 $(foreach release,$(CENTOS_RELEASES),$(eval $(call centos_targets,$(release))))
135 146
136 147 .PHONY: linux-wheels
137 148 linux-wheels: linux-wheels-x86_64 linux-wheels-i686
138 149
139 150 .PHONY: linux-wheels-x86_64
140 151 linux-wheels-x86_64:
141 152 docker run -e "HGTEST_JOBS=$(shell nproc)" --rm -ti -v `pwd`/../..:/src quay.io/pypa/manylinux1_x86_64 /src/contrib/packaging/build-linux-wheels.sh
142 153
143 154 .PHONY: linux-wheels-i686
144 155 linux-wheels-i686:
145 156 docker run -e "HGTEST_JOBS=$(shell nproc)" --rm -ti -v `pwd`/../..:/src quay.io/pypa/manylinux1_i686 linux32 /src/contrib/packaging/build-linux-wheels.sh
General Comments 0
You need to be logged in to leave comments. Login now