File: rules

package info (click to toggle)
twisted 18.9.0-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 20,404 kB
  • sloc: python: 186,805; ansic: 458; makefile: 342; sh: 71; xml: 31
file content (241 lines) | stat: -rwxr-xr-x 8,170 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
#! /usr/bin/make -f

SHELL = /bin/bash

# all versions
PYVERS	:= $(shell pyversions -vs)
VER	:= $(shell /usr/bin/python -c 'import sys; print sys.version[:3]')
PY3VERS	:= $(shell py3versions -vs)
VER3	:= $(shell /usr/bin/python3 -c 'import sys; print(sys.version[:3])')
DEBVERS := $(shell dpkg-parsechangelog | sed -n -e 's/^Version: //p')

twversion := $(subst twisted-,,$(notdir $(CURDIR)))

include /usr/share/python/python.mk

ifeq (,$(findstring nodocs,$(DEB_BUILD_OPTIONS)))
  with_docs=yes
endif
with_docs=

build: build-stamp
build-arch: build-stamp
build-indep: build-stamp
build-indep: build-stamp build-doc
build-stamp: $(PYVERS:%=build-python%) $(PY3VERS:%=build3-python%)
	touch $@
build-python%:
	python$* setup.py build
	python$*-dbg setup.py build
	touch $@

build3-python%:
	python$* setup.py build
	python$*-dbg setup.py build
	touch $@

build-doc:
	$(MAKE) -C docs html
	touch $@

clean:
	rm -rf *-stamp build-python* build tmp
	rm -rf docs/_build build-doc
	rm -rf build3-python*
	rm -rf apidocs py3
	rm -rf $(addprefix debian/,$(packages)) debian/files debian/substvars
	rm -rf _trial_temp test.log
	rm -f twisted/plugins/dropin.cache
	find -name '__pycache__' -type d | xargs -r rm -rf
	find . -name "*.pyc" |xargs -r rm
	dh_clean

install: build-stamp install-prereq $(PYVERS:%=install-python%) $(PY3VERS:%=install3-python%) install-nover

install-prereq: build-stamp
	dh_testdir
	dh_testroot
	dh_prep

install-python%: install-prereq
	: # python-twisted-core
	python$* setup.py install --root=debian/python-twisted-core --install-layout=deb

	-find debian/python-twisted-core -name '*.py[co]' | xargs rm -f
	rm -rf debian/python-twisted-core$(call py_libdir,$*)/twisted/topfiles
	rm -rf debian/python-twisted-core$(call py_libdir,$*)/Twisted-$(twversion).egg-info

	python$* setup.py install --root=tmp --install-layout=deb
	cp -r tmp$(call py_libdir,$*)/Twisted-*.egg-info debian/python-twisted-core$(call py_libdir,$*)/

	find debian/python-twisted-core -name 'topfiles' -type d | xargs -r rm -rf

	: # python-twisted
	mkdir -p debian/python-twisted/$(call py_libdir,$*)

	: # python-twisted-bin
	dh_movefiles -ppython-twisted-bin \
	  --sourcedir=debian/python-twisted-core \
	    $(call py_libdir,$*)/twisted/python/_sendmsg.so \
	    $(call py_libdir,$*)/twisted/test/raiser.so

	: # python-twisted-bin-dbg
	python$*-dbg setup.py install --root=debian/python-twisted-bin-dbg --no-compile --install-layout=deb
	find debian/python-twisted-bin-dbg ! -type d ! -name '*_d.so' | xargs rm -f
	find debian/python-twisted-bin-dbg -depth -empty -exec rmdir {} \;

	: # Replace all '#!' calls to python with /usr/bin/python2
	: # and make them executable
	for i in `find debian/python-twisted-* -mindepth 3 -type f`; do \
	  sed '1s,#!.*python[^ ]*\(.*\),#! /usr/bin/python2\1,' \
		$$i > $$i.temp; \
	  if cmp --quiet $$i $$i.temp; then \
	    rm -f $$i.temp; \
	  else \
	    mv -f $$i.temp $$i; \
	    chmod 755 $$i; \
	    echo "fixed interpreter: $$i"; \
	  fi; \
	done

install3-python%: install-prereq
	: # python3-twisted $*
	python$* setup.py install \
		--root=$(CURDIR)/debian/python3-twisted --install-layout=deb

	find debian/python3-twisted -name '__pycache__' | xargs -r rm -rf

	: # python3-twisted-bin
	dh_movefiles -ppython3-twisted-bin \
	  --sourcedir=debian/python3-twisted \
	    $(call py_libdir,$*)/twisted/test/raiser.cpython-$(subst .,,$*)$(if $(filter 3.7,$*),m)-$(DEB_HOST_MULTIARCH).so
#	    $(call py_libdir,$*)/twisted/python/sendmsg.cpython-$(subst .,,$*)$(if $(filter 3.7,$*),m)-$(DEB_HOST_MULTIARCH).so

	: # Replace all '#!' calls to python with /usr/bin/python3
	: # and make them executable
	for i in `find debian/python3-twisted debian/python3-twisted-* -mindepth 3 -type f`; do \
	  sed '1s,#!.*python[^ ]*\(.*\),#! /usr/bin/python3\1,' \
		$$i > $$i.temp; \
	  if cmp --quiet $$i $$i.temp; then \
	    rm -f $$i.temp; \
	  else \
	    mv -f $$i.temp $$i; \
	    chmod 755 $$i; \
	    echo "fixed interpreter: $$i"; \
	  fi; \
	done

	: # python-twisted-bin-dbg
	python$*-dbg setup.py install \
		--root=$(CURDIR)/debian/python3-twisted-bin-dbg --no-compile --install-layout=deb
	find debian/python3-twisted-bin-dbg ! -type d ! -name '*.so' | xargs rm -f
	find debian/python3-twisted-bin-dbg -depth -empty -exec rmdir {} \;

install-nover:
	: # python man pages
	mkdir -p debian/python-twisted-core/usr/share/man/man1
	for i in \
	  docs/core/man/{manhole,pyhtmlizer,tap2deb,tap2rpm,trial,twistd}.1 \
	  docs/conch/man/{cftp,ckeygen,conch,tkconch}.1 \
	  docs/mail/man/mailmail.1; \
	do \
	  cp $$i debian/python-twisted-core/usr/share/man/man1/.; \
	done
	mv debian/python-twisted-core/usr/bin/cftp \
		debian/python-twisted-core/usr/bin/conchftp
	mv debian/python-twisted-core/usr/share/man/man1/cftp.1 \
		debian/python-twisted-core/usr/share/man/man1/conchftp.1
	sed -i '/^\.Nm /s/cftp/conchftp/;s/CFTP/CONCHFTP/' \
		debian/python-twisted-core/usr/share/man/man1/conchftp.1

	: # python3 man pages
	for i in debian/python3-twisted/usr/bin/*; do \
	  mv $$i $${i}3; \
	done
	mkdir -p debian/python3-twisted/usr/share/man/man1
	for i in docs/core/man/{trial,twistd}.1; do \
	  i2=$$(basename $$i .1)3.1; \
	  cp -p $$i debian/python3-twisted/usr/share/man/man1/$$i2; \
	done

ifeq ($(with_docs),yes)
	: # twisted-doc
	mkdir -p debian/twisted-doc/usr/share/doc/twisted-doc
	cp -a docs/core/* debian/twisted-doc/usr/share/doc/twisted-doc/
	-find debian/twisted-doc -type d -name man | xargs rm -rf
endif

binary-indep: build-indep build-doc install
	dh_testdir
	dh_testroot
	dh_installchangelogs -i
	dh_installdocs -i
	cp -a docs/_build/html debian/twisted-doc/usr/share/doc/twisted-doc/.
	dh_sphinxdoc -ptwisted-doc

	rm -rf debian/python-twisted-runner-dbg/usr/share/doc/python-twisted-runner-dbg
	ln -s python-twisted-runner \
	    debian/python-twisted-runner-dbg/usr/share/doc/python-twisted-runner-dbg

ifeq ($(with_docs),yes)
	cp -ua apidocs debian/twisted-doc/usr/share/doc/twisted-doc/
	# Replace links to Twisted website API doc by links to the local doc. We
	# need to compute path to the API which goes up enough in the folder
	# hierarchy to access the doc.
	for i in $$(cd debian/twisted-doc/usr/share/doc/twisted-doc/ && \
	  grep -rl "http://twistedmatrix.com/documents/$(twversion)/api/" .); do \
	  path="$$(echo $$i | sed "s:[^/]::g" | sed "s:/:../:g" | cut -c 4-)apidocs/"; \
	  sed -i "s:http\://twistedmatrix.com/documents/$(twversion)/api/:$$path:g" \
	  debian/twisted-doc/usr/share/doc/twisted-doc/$$i; \
	done
endif
	dh_installmenu -i
	dh_compress -i -X.py
	dh_fixperms -i
	dh_lintian -i
	dh_python2 -i -X hamcrest
	dh_python3 -i -X hamcrest
	# post-process .substvars until #806316 is fixed and -X starts working
	sed -i 's/ python3*-hamcrest,//' debian/python-twisted-core.substvars debian/python3-twisted.substvars
	dh_installdeb -i
	dh_gencontrol -ppython-twisted-core -ppython-twisted-mail \
	    -ppython-twisted-names -ppython-twisted-news -ppython-twisted-web \
	    -ppython-twisted-runner -ppython-twisted-runner-dbg \
            -ppython-twisted-words -ptwisted-doc -ppython-twisted \
	    -ppython3-twisted
	: # Add the epoch to python-twisted-conch, for upgrades
	dh_gencontrol -ppython-twisted-conch -- -v1:$(DEBVERS)
	dh_md5sums -i
	dh_builddeb -i

binary-arch: build-arch install
	dh_testdir
	dh_testroot
	dh_installchangelogs -a
	dh_lintian -a
	dh_installdocs -a
	dh_installmenu -a

	dh_strip -ppython-twisted-bin --dbg-package=python-twisted-bin-dbg
	rm -rf debian/python-twisted-bin-dbg/usr/share/doc/python-twisted-bin-dbg
	ln -s python-twisted-bin \
	    debian/python-twisted-bin-dbg/usr/share/doc/python-twisted-bin-dbg

	dh_strip -ppython3-twisted-bin --dbg-package=python3-twisted-bin-dbg
	rm -rf debian/python3-twisted-bin-dbg/usr/share/doc/python3-twisted-bin-dbg
	ln -s python3-twisted-bin \
	    debian/python3-twisted-bin-dbg/usr/share/doc/python3-twisted-bin-dbg

	dh_compress -a -X.py
	dh_fixperms -a
	dh_python2 -a
	dh_python3 -a
	dh_installdeb -a
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install install-nover install-prereq
.NOTPARALLEL: