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

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

# work around libpng crash on our test PNGs with 8 bit colormaps (LP #710881)
export NO_PNG_PKG_MANGLE=1

# Enabling PIE globally doesn't work, but ./configure already enables PIE
# where necessary.
export DEB_BUILD_MAINT_OPTIONS = hardening=+all,-pie
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

# The build system uses only DSOFLAGS but not LDFLAGS to build some libraries.
# Add LDFLAGS to enable (hardening) build flags.
export DSOFLAGS = $(shell dpkg-buildflags --get LDFLAGS)

DEB_HOST_ARCH_OS := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)


APPARMOR := no
CONFIG_LIBUSB := --enable-libusb
DH_WITH :=
ifeq (linux,$(DEB_HOST_ARCH_OS))
DH_WITH += systemd
CONFIG_SYSTEMD := --with-systemdsystemunitdir=/lib/systemd/system
endif
ifeq (illumos,$(DEB_HOST_ARCH_OS))
DH_WITH += smf
CONFIG_SMF := --with-smfmanifestdir=/lib/svc/manifest/application
CONFIG_LIBUSB := --disable-libusb
APPARMOR := yes
endif
ifeq ($(DEB_HOST_ARCH_OS),hurd)
CONFIG_LIBUSB := --disable-libusb
endif

%:
	dh $@ $(DH_WITH:%=--with %)

override_dh_auto_configure:
ifeq ($(derives_from_ubuntu),yes)
	set -e; if ! [ -e debian/patches/ubuntu/stamp-applied ]; then \
	    echo '---- Applying Ubuntu specific patches'; \
	    for p in debian/patches/ubuntu/*; do \
	        patch -p1 --no-backup-if-mismatch < $$p; \
	    done; \
	    touch debian/patches/ubuntu/stamp-applied; \
	fi
endif
	# Rebuild ./configure to get build system patches working
	aclocal
	autoconf
	dh_auto_configure -- \
		--with-docdir=/usr/share/cups/doc-root \
		--localedir=/usr/share/cups/locale \
		--enable-libpaper \
		--enable-ssl \
		--enable-gnutls \
		--disable-openssl \
		--enable-threads \
		--enable-static \
		--enable-debug \
		--enable-dbus \
		--with-dbusdir=/etc/dbus-1 \
		--enable-gssapi \
		--enable-avahi \
		--disable-launchd \
		--with-cups-group=lp \
		--with-system-groups=lpadmin \
		--with-printcap=/var/run/cups/printcap \
		--with-log-file-perm=0640 \
		--with-local_protocols='dnssd' \
		$(CONFIG_SMF) $(CONFIG_SYSTEMD) $(CONFIG_LIBUSB)

override_dh_auto_install:
	dh_auto_install -- install BUILDROOT=$(shell pwd)/debian/tmp

MANPAGES_L10N_CUPS=man5/subscriptions.conf.5 man5/mime.convs.5 man7/filter.7 man8/cupsfilter.8 man8/cups-deviced.8 man8/cups-driverd.8 man8/cupsd-lpd.8
MANPAGES_L10N_CUPS_DAEMON=man5/classes.conf.5 man5/cupsd.conf.5 man5/cups-files.conf.5 man5/cups-snmp.conf.5 man5/mailto.conf.5 man5/mime.types.5 man5/printers.conf.5 man7/backend.7 man8/cupsd.8
MANPAGES_L10N_CUPS_CLIENT=man1/cupstestppd.1 man1/cupstestdsc.1 man1/ippfind.1 man1/ipptool.1 man1/lp.1 man1/lpoptions.1 man1/lppasswd.1 man1/lpstat.1 man1/cancel.1 man5/client.conf.5 man5/ipptoolfile.5 man8/cupsaddsmb.8 man8/cupsenable.8 man8/lpadmin.8 man8/lpinfo.8 man8/lpmove.8 man8/cupsreject.8 man8/cupsdisable.8 man8/cupsaccept.8 man8/cupsctl.8
MANPAGES_L10N_CUPS_BSD=man1/lpr.1 man1/lprm.1 man1/lpq.1 man8/lpc.8

override_dh_install:
ifeq ($(derives_from_ubuntu),yes)
	# Use upstart script on Ubuntu; we need to hide it away for Debian
	# builds, as dh_installinit does not have a --sysvinit-only
	cp debian/local/*.upstart debian
endif
	dh_install
ifneq (,$(CONFIG_SYSTEMD))
	dh_install -pcups-daemon lib/systemd
endif
ifneq (,$(CONFIG_SMF))
	dh_install -pcups-daemon lib/svc
endif

ifneq (,$(filter cups-server-common,$(shell dh_listpackages)))
	# Remove all files which get replaced by the ones in the cups-filters
	# package
	rm -f debian/cups-server-common/usr/share/cups/data/testprint
endif

	# Ensure that we don't ship anything in /var/run
	rm -rf debian/cups*/var/run

ifneq (,$(filter cups,$(shell dh_listpackages)))
	# Make the usb backend run as root, since /dev/bus/usb/* are
	# root:root in udev < 147, and cups does not use the usblp kernel
	# module any more; udev 147 makes most of those printers accessible to
	# lp, but apparently not all of them
	chmod go-x debian/cups/usr/lib/cups/backend-available/usb

        # Try to install the translated manpages to cups
	set -e; for m in $(MANPAGES_L10N_CUPS); do \
	       for manp in $$(ls debian/tmp/usr/share/man/*/$$m.gz); do \
                        install -D -m 644 $$manp $$(echo $$manp | sed -e 's#^debian/tmp#debian/cups#');\
                done; \
        done
endif

ifneq (,$(filter libcups2-dev,$(shell dh_listpackages)))
	# debian/libcups2-dev.install entry cannot rename files on-the-fly
	cp cups/language-private.h debian/libcups2-dev/usr/include/cups/i18n.h
endif

ifneq (,$(filter cups-daemon,$(shell dh_listpackages)))
ifeq ($(APPARMOR),yes)
	# Install AppArmor, ufw profile, and Apport hook
	install -D -m 644 debian/local/apparmor-profile debian/cups-daemon/etc/apparmor.d/usr.sbin.cupsd
	dh_apparmor --profile-name=usr.sbin.cupsd -p cups-daemon
	install -D -m 644 debian/local/cups.ufw.profile debian/cups-daemon/etc/ufw/applications.d/cups
	install -D -m 644 debian/local/apport-hook.py debian/cups-daemon/usr/share/apport/package-hooks/source_cups.py
endif

        # Try to install the translated manpages to cups-daemon
	set -e; for m in $(MANPAGES_L10N_CUPS_DAEMON); do \
	       for manp in $$(ls debian/tmp/usr/share/man/*/$$m.gz); do \
                        install -D -m 644 $$manp $$(echo $$manp | sed -e 's#^debian/tmp#debian/cups-daemon#');\
                done; \
        done
endif

ifneq (,$(filter cups-client,$(shell dh_listpackages)))
        # Try to install the translated manpages to cups-client
	set -e; for m in $(MANPAGES_L10N_CUPS_CLIENT); do \
	       for manp in $$(ls debian/tmp/usr/share/man/*/$$m.gz); do \
                        install -D -m 644 $$manp $$(echo $$manp | sed -e 's#^debian/tmp#debian/cups-client#');\
                done; \
        done
endif

ifneq (,$(filter cups-bsd,$(shell dh_listpackages)))
        # Try to install the translated manpages to cups-bsd
	set -e; for m in $(MANPAGES_L10N_CUPS_BSD); do \
	       for manp in $$(ls debian/tmp/usr/share/man/*/$$m.gz); do \
                        install -D -m 644 $$manp $$(echo $$manp | sed -e 's#^debian/tmp#debian/cups-bsd#');\
                done; \
        done
endif

override_dh_installchangelogs:
	dh_installchangelogs CHANGES.txt

override_dh_installinit:
ifeq ($(derives_from_ubuntu),yes)
	dh_installinit --name=cups --upstart-only
else
	dh_installinit --name=cups
endif

override_dh_fixperms:
	dh_fixperms -Xusr/lib/cups/backend-available

override_dh_auto_test:
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
	make check
	# Check that cups-config is not architecture-specific
	[ -r cups-config ] && grep -vq $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) cups-config
endif

ifeq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
override_dh_makeshlibs:
	dh_makeshlibs -- -c4
endif

override_dh_clean:
	dh_clean
	if [ -e debian/patches/ubuntu/stamp-applied ]; then \
	    echo '---- Unapplying Ubuntu specific patches'; \
	    for p in debian/patches/ubuntu/*; do \
	        patch -Rp1 --no-backup-if-mismatch < $$p; \
	    done; \
	    rm debian/patches/ubuntu/stamp-applied; \
	fi

override_dh_auto_clean:
	[ ! -f Makedefs ] || dh_auto_clean
	rm -f man/client.conf.man packaging/cups.list
	rm -f conf/mime.convs conf/snmp.conf init/org.cups.cups-lpd.plist
	[ ! -f Makedefs ] || make distclean
	rm -f debian/*.upstart # master copy is in debian/local

override_dh_installdocs:
	dh_installdocs -plibcupsimage2-dev --link-doc=libcupsimage2
	dh_installdocs -pcups-bsd --link-doc=libcups2
	dh_installdocs --remaining-packages

	rm -f debian/libcups2-dev/usr/share/doc/libcups2-dev/examples/scripting/php/*.o
	rm -f debian/libcups2-dev/usr/share/doc/libcups2-dev/examples/scripting/php/*.so

override_dh_installpam:
	dh_installpam -pcups-daemon --name=cups
	dh_installpam --remaining-packages

override_dh_strip:
	dh_strip --dbg-package=cups-dbg