summaryrefslogtreecommitdiff
path: root/debian/rules
blob: dd37739ec1e3e4d1b1b2709d110de28a0c9a42f8 (plain)
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
#!/usr/bin/make -f

derives_from_ubuntu := $(shell (dpkg-vendor --derives-from Ubuntu && echo "yes") || echo "no")

%:
	dh $@

override_dh_auto_configure:
	echo "#!/bin/sh\n/bin/gzip --best \$$1" > debian/mygzip
	chmod +x debian/mygzip
	GZIP='$(CURDIR)/debian/mygzip' dh_auto_configure -- --with-drivers=NOOBSOLETES,NOEMPTYCMDLINE

override_dh_auto_clean:
	dh_auto_clean
	rm -f debian/mygzip
	rm -f pyppd-ppdfile
	rm -rf foomatic

override_dh_install:
	# Some files have the executable bit set.
	- find debian/tmp/ -executable -type f -print0 | xargs -0 chmod -x

	# Remove non-PPD files from PPD repositories, CUPS 1.4 reports errors
	# on these files.
	- find $(CURDIR)/debian/tmp/usr/share/foomatic/db/source/PPD -type f \! -name '*.ppd.gz' -print0 | xargs -0 rm

	# Remove entries for drivers never shipped in Debian nor in Ubuntu
	( cd $(CURDIR)/debian/tmp/usr/share/foomatic/db/source/driver; \
	    rm ppmtomd.xml; \
	    rm lpstyl.xml; \
	    rm pbm2lwxl.xml; \
	    rm bjc800j.xml; \
	    rm pbm2l7k.xml; \
	    rm lm1100.xml; \
	    rm pbm2l2030.xml; \
	    rm c2070.xml; \
	    rm drv_x125.xml; \
	    rm pentaxpj.xml; \
	    rm ml85p.xml; \
	)

	# Fix common errors in PPDs that make CUPS choke (OpenPrinting
	# bug #164, Debian bug #493104)
	for f in `find $(CURDIR)/debian/tmp/usr/share/foomatic/db/source/PPD -name '*.ppd.gz'`; do gzip -cd $$f | perl -p -e 's/^\*CloseUI(\s+)/*CloseUI:\1/' | perl -p -e 's/\*1284DeviceId/*1284DeviceID/' | gzip --best>  $$f.tmp; rm $$f; mv $$f.tmp $$f; done

	dh_install --list-missing

	# Pre-build PPD files for foomatic-db-compressed-ppds
	FOOMATICDB=$(CURDIR)/debian/foomatic-db-xml/usr/share/foomatic foomatic-compiledb -j 16 -t ppd -d $(CURDIR)/foomatic `ls -1 $(CURDIR)/debian/foomatic-db-xml/usr/share/foomatic/db/source/driver/*.xml | perl -p -e 's:^.*db/source/driver/(\S*)\.xml\s*$$:\1\n:'`

	# Compress the PPD files with Vitor Baptista's pyppd PPD
	# archiving tool. This makes the space needed for PPDs at least
	# 10 times smaller.
	( mkdir -p $(CURDIR)/debian/openprinting-ppds/usr/lib/cups/driver/ && \
	  pyppd --output=$(CURDIR)/debian/openprinting-ppds/usr/lib/cups/driver/openprinting-ppds \
	        $(CURDIR)/debian/openprinting-ppds/usr/share/ppd/openprinting && \
	  rm -rf $(CURDIR)/debian/openprinting-ppds/usr/share/ppd \
	)
	( mkdir -p $(CURDIR)/debian/foomatic-db-compressed-ppds/usr/lib/cups/driver/ && \
	  pyppd --output=$(CURDIR)/debian/foomatic-db-compressed-ppds/usr/lib/cups/driver/foomatic-db-compressed-ppds \
	        $(CURDIR)/foomatic && \
	  rm -rf $(CURDIR)/foomatic \
	)

	# Install the apport hook on Ubuntu and derivatives
ifeq ($(derives_from_ubuntu),yes)
	install -D -m 644 debian/ubuntu/apport-hook.py $(CURDIR)/debian/foomatic-db-compressed-ppds/usr/share/apport/package-hooks/source_foomatic-db.py
endif