File: rules

package info (click to toggle)
hplip 3.16.11%2Brepack0-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 129,416 kB
  • ctags: 20,423
  • sloc: python: 78,229; ansic: 67,606; cpp: 59,753; sh: 11,285; perl: 4,353; makefile: 693
file content (288 lines) | stat: -rwxr-xr-x 10,405 bytes parent folder | download
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
#!/usr/bin/make -f
# debian/rules for hplip
# GNU copyright 1997 to 1999 by Joey Hess.
# Copyright (c) 2003 Torsten Landschoff <torsten@debian.org>
# Copyright (c) 2004-2006 Henrique de Moraes Holschuh <hmh@debian.org>

PACKAGE=hplip
BASEPKG=hplip

-include /usr/share/python3/python.mk
ifeq (,$(py_sitename))
   py_sitename = site-packages
   py_libdir = /usr/lib/python$(subst python,,$(1))/site-packages
   py_sitename_sh = $(py_sitename)
   py_libdir_sh = $(py_libdir)
endif

# Override py_sitename as the python.mk module gives the wrong "dist-packages"
py_sitename = site-packages

PYTHON=python3
PYTHON_DEFAULT_VERSION:=$(shell py3versions -dv)
PYTHON_SITENAME:=$(call py_sitename, $(PYTHON_DEFAULT_VERSION))


DBGPKG:=$(BASEPKG)-dbg
PKGTMP:=$(CURDIR)/debian/tmp
PPDDIR:=$(PKGTMP)/usr/share/ppd

# Autoconf
export DEB_HOST_ARCH_OS   ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
export DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

CONFFLAGS =

ifeq ($(DEB_HOST_ARCH_OS), linux)
  CONFFLAGS += --enable-pp-build
else
  CONFFLAGS += --disable-pp-build --enable-libusb01_build
endif

GZIP = gzip -n --best

##
##  Build-tree preparation
##

%:
	dh $@ --buildsystem=autoconf --with autoreconf --with python3 --with pyppd

override_dh_autoreconf:
	dh_autoreconf --as-needed sh -- debian/autogen.sh

# Clean everything up, including everything auto-generated
# at build time that needs not to be kept around in the Debian diff
override_dh_clean:
	dh_clean
	find . -regextype posix-extended -iregex '.*\.(ldl|ppd|pdf|ps|pcl)\.gz' | xargs gunzip -f ;\
	rm -f *.1
	-rm -f prnt/hpijs/platform.h prnt/hpijs/auto-include.h
	find -type d -name build -print0 | xargs -0 -r rm -rf \;
	# We prefer to regenerate these using pyuic
	(cd ui5 && for i in *.ui ; do rm -f $${i%.ui}.py ; done)


##
##  Package build
##

override_dh_auto_configure:
	dh_auto_configure -- \
		PYTHON="$(PYTHON)" \
		HPLIP_PPD_PATH=/usr/share/ppd \
		$(CONFFLAGS) \
	 	--config-cache \
		--docdir=\$${prefix}/share/doc/hplip \
		--with-docdir=\$${prefix}/share/doc/hplip \
		--with-htmldir=\$${prefix}/share/doc/hplip-doc \
		--enable-foomatic-drv-install \
		--disable-foomatic-rip-hplip-install \
		--with-drvdir=\$${prefix}/share/cups/drv \
		--with-hpppddir=\$${prefix}/share/ppd/hplip/HP \
		--datadir=\$${prefix}/share \
		--without-icondir \
		--disable-foomatic-ppd-install \
		--enable-hpcups-install \
		--enable-cups-drv-install \
		--enable-hpijs-install \
		--enable-foomatic-drv-install \
		--enable-foomatic-ppd-install \
		--enable-network-build \
		--enable-scan-build \
		--enable-gui-build \
		--enable-fax-build \
		--disable-qt3 \
		--disable-qt4 \
		--enable-qt5 \
		--enable-policykit \
		--enable-udev-acl-rules

override_dh_auto_build:
	# Compress various files before building, they are needed for the build, and were
	# compressed in the non-repacked upstream tarballs
	-find . -name '*.ppd' | xargs ${GZIP} -f
	-find data/ -regextype posix-extended -regex '.*\.(ldl|pcl|ps|pdf)' | xargs ${GZIP} -f

	# Rebuild the UI files and patch the imports to be relative
	(set -e; cd ui5; \
		for i in *.ui ; do pyuic5 -o $${i%.ui}.py $$i; done; \
		modules=$$(for i in *.py; do echo -n $${i%%.py}\|; done; echo dummyalternative); \
		sed -r "s#from ($$modules)#from .\1#" -i *.py \
	)
	# Patch out retranslateUi call like upstream does
	sed -i s/self.retranslateUi/#self.retranslateUi/ ui5/devmgr5_base.py


	dh_auto_build


##
## Debian packaging
##

override_dh_install:
	# Clean up libtool archives
	find debian/tmp -name '*.la' -delete

	# Remove hpcups support for the HP Officejet Pro K550 as it is known
	# to not work. This way hpijs (which works) will be used (Ubuntu bugs
	# #981473, #1311697)
	perl -e '$$content = join("", <>); $$content =~ s:^\s*\{[^\n]*?\n[^\n]*?pro.k550.*?\}\s*\n::ism; print $$content' $(PKGTMP)/usr/share/cups/drv/hpcups.drv > $(PKGTMP)/usr/share/cups/drv/hpcups.drv.new
	rm $(PKGTMP)/usr/share/cups/drv/hpcups.drv
	mv $(PKGTMP)/usr/share/cups/drv/hpcups.drv.new $(PKGTMP)/usr/share/cups/drv/hpcups.drv

	# Modify all Ghostscript command lines to have the "-dNOINTERPOLATE"
	# coomand line option. This makes rendering the pages much faster
	perl -p -i -e "s/(\-sDEVICE=)/-dNOINTERPOLATE \1/" $(PKGTMP)/usr/share/cups/drv/hpijs.drv $(PKGTMP)/usr/lib/cups/filter/pstotiff

	# Install wrapper script for hp-plugin, to be called by update-notifier
	# on udev signal (Ubuntu only)
	if [ "`lsb_release -is 2>/dev/null`" = "Ubuntu" ]; then \
		install -d $(CURDIR)/debian/hplip/usr/bin/; \
		install -m 755 debian/local/scripts/hp-plugin-ubuntu $(CURDIR)/debian/hplip/usr/bin/; \
	fi

	# Install Apport hook
	install -D -m 644 debian/local/apport-hook.py $(PKGTMP)/usr/share/apport/package-hooks/source_hplip.py

	# Uncompress PPDs, this makes the package smaller for distribution
	-find $(PPDDIR) -name '*.ppd.gz' | xargs gunzip -f

	# Remove identical PPD files shipped under different names
	( cd "$(PKGTMP)" && fdupes -r1q usr/share/ppd | while read s; do \
	      set -- $$(echo $$s | tr ' ' '\n' | sort); \
	      f=$$1; shift; \
	      for d; do \
		  echo "Removing duplicate PPD file $$d, original is $$f"; \
		  rm $$d; \
	      done; \
	  done )

	# Generate man pages corresponding to the programs
	export HPLIP_BUILD=1; \
	( cd ./debian/tmp/usr/bin/; \
	    for file in *; do \
			if readlink $$file | grep ".py"; then \
				PYTHONPATH=../lib/python$(PYTHON_DEFAULT_VERSION)/$(PYTHON_SITENAME)/ \
				HOME=./ \
				LD_LIBRARY_PATH=../lib/$(DEB_HOST_MULTIARCH) python3 ./$$file --help-man > $(CURDIR)/$$file.1 ; \
			fi; \
	    done \
	)

	# Correct Python interpreter path in all executables
	for file in ./debian/tmp/usr/bin/* ./debian/tmp/usr/lib/cups/*/*; do \
	    perl -p -i -e 's:^\s*\#\!\s*/usr/bin/env\s+python.*:#!/usr/bin/python:' `readlink -f $$file`; \
	done

	# "Upgrade" Python interpreter path to Python3
	for file in ./debian/tmp/usr/bin/* ./debian/tmp/usr/lib/cups/*/*; do \
	    perl -p -i -e 's:^\s*\#\!\s*/usr/bin/python\b:#!/usr/bin/python3:' `readlink -f $$file`; \
	done

	# Remove unneeded explicit calls of the Python interpreter to let the
	# (upgraded) shebangs rule
	for file in ./debian/tmp/*/udev/rules.d/*.rules; do \
	    perl -p -i -e 's:/usr/bin/python\b\s*::' `readlink -f $$file`; \
	done

	# Remove all *.pyc files, they do not need to be shipped with the
	# package
	find ./debian/tmp/ -name '*.pyc' -print0 | xargs -0 rm -f

	# Remove files we are not to ship from the install tree
	@echo Removing non-shipped files, see debian/non-shipped-files.txt
	@cat debian/non-shipped-files.txt | \
		( cd "$(PKGTMP)" && xargs -d '\n' -t -r rm -fv )

# install arch-dependent packages specific files

	# Remove stray #! lines on python libraries, and fix permissions
	find "$(PKGTMP)/usr/share/hplip" -maxdepth 1 -mindepth 1 -type d -print0 | \
		xargs -0 -r -i@ find @ -type f -name '*.py' | \
		while read -r i ; do \
			chmod a-x "$$i" && \
			sed < "$$i" > "$$i.tmp" -e '/^#!/ {1 d}' && \
			mv -f "$$i.tmp" "$$i" ; \
		done
	# executable-not-elf-or-script
	chmod -x $(PKGTMP)/usr/share/hplip/installer/distros.dat

	mkdir -p "$(PKGTMP)/usr/share/applications"
	install -m 644 debian/*.desktop "$(PKGTMP)/usr/share/applications"

	mkdir -p "$(PKGTMP)/etc/sane.d/dll.d"
	install -m 644 debian/$(BASEPKG).sane "$(PKGTMP)/etc/sane.d/dll.d/$(PACKAGE)"

	# Uncompress PPDs, this makes the package smaller for distribution
	#-find "$(CURDIR)/debian/printer-driver-hpijs/usr/share/ppd/" -name '*.ppd.gz' | xargs gunzip -f
	#-find "$(CURDIR)/debian/printer-driver-hpcups/usr/share/ppd/" -name '*.ppd.gz' | xargs gunzip -f

	# Modify all Ghostscript command lines to have the "-dNOINTERPOLATE"
	# coomand line option. This makes rendering the pages much faster
	perl -p -i -e "s/(\-sDEVICE=)/-dNOINTERPOLATE \1/" $(CURDIR)/debian/*/usr/share/ppd/hplip/HP/HP-Fax*.ppd

	dh_install -a --list-missing

	# Remove the Fax PPDs, we have handled them in the arch-dependent part
	-find $(PPDDIR) -name '*Fax*.ppd*' | xargs rm

	dh_install -i --list-missing

	# Patch the PPDs for the hpijs-ppds package to use foomatic-rip
	# as CUPS filter and not foomatic-rip-hplip. Also add
	# "-dNOINTERPOLATE" to the Ghostscript command lines to make rendering
	# by Ghostscript faster.
	(if dh_listpackages | grep -q hpijs-ppds; then  \
	  cd $(CURDIR)/debian/hpijs-ppds/usr/share/ppd/hplip/HP/ && \
	  for ppd in *.ppd; do \
	    perl -p -i -e 's/foomatic-rip-hplip/foomatic-rip/g' $$ppd; \
	    perl -p -i -e "s/(\-sDEVICE=)/-dNOINTERPOLATE \1/" $$ppd; \
	  done; fi \
	)

	# Remove models.dat from hplip-data - we ship with libsane-hpaio
	if dh_listpackages | grep -q hplip-data; then \
		rm $(CURDIR)/debian/hplip-data/usr/share/hplip/data/models/models.dat; \
	fi

override_dh_pyppd:
	# Not sure why only that package
	dh_pyppd -pprinter-driver-postscript-hp

override_dh_strip:
	dh_strip  --dbgsym-migration='$(DBGPKG) (<< 3.15.11+repack0-1~), hplip (<< 3.10.2-2ubuntu2)'

override_dh_makeshlibs:
	dh_makeshlibs -plibsane-hpaio --no-scripts
	dh_makeshlibs --remaining-packages

override_dh_python3:
	dh_python3 --no-shebang-rewrite
	dh_python3 /usr/share/hplip --no-shebang-rewrite

override_dh_shlibdeps:
	dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info

get-orig-source:
	set -e;\
	quilt pop -af || true ;\
	rm -Rf .pc ;\
	gbp import-orig --no-pristine-tar --no-merge --uscan --upstream-branch=upstream/latest;\
	git checkout upstream/latest-repack ;\
	utag=`git describe --exact-match heads/upstream/latest | sed -e 's#^upstream/##'` ;\
	git merge --strategy-option=theirs --no-commit upstream/$$utag || true ;\
	find . -regextype posix-extended -iregex '.*\.(ldl|ppd|pdf|ps|pcl)\.gz' | xargs gunzip -f ;\
	git add -A . ;\
	git commit  -m "Merge upstream $$utag version; un-gzip source files" ;\
	urtag=$$utag+repack0 ;\
	urcommit=`git rev-parse --verify HEAD`;\
	git tag upstream/$$urtag -m "Upstream repacked $$utag version" ;\
	git archive --format=tar --prefix=hplip-$$urtag/ upstream/$$urtag | xz -6e > ../hplip_$$urtag.orig.tar.xz ;\
	pristine-tar commit ../hplip_$$urtag.orig.tar.xz upstream/$$urtag ;\
	git checkout debian/master ;\
	git dpm record-new-upstream --rebase-patched ../hplip_$$urtag.orig.tar.xz $$urcommit ;\
	git dpm update-patches -m "Merge upstream-repacked $$urtag version and refresh git-dpm patches"