1SUMMARY = "An Internet printing system for Unix"
2DESCRIPTION = "The Common UNIX Printing System is a printing system and \
3general replacement for lpd and the like. It supports the Internet Printing \
4Protocol (IPP), and has its own filtering driver model for handling various \
5document types."
6HOMEPAGE = "https://www.cups.org/"
7SECTION = "console/utils"
8LICENSE = "Apache-2.0"
9DEPENDS = "libpng jpeg dbus zlib libusb1"
10
11SRC_URI = "${GITHUB_BASE_URI}/download/v${PV}/cups-${PV}-source.tar.gz \
12           file://0001-use-echo-only-in-init.patch \
13           file://0002-don-t-try-to-run-generated-binaries.patch \
14           file://libexecdir.patch \
15           file://0004-cups-fix-multilib-install-file-conflicts.patch \
16           file://volatiles.99_cups \
17           file://cups-volatiles.conf \
18           "
19
20GITHUB_BASE_URI = "https://github.com/OpenPrinting/cups/releases"
21
22CVE_STATUS[CVE-2008-1033] = "not-applicable-platform: Issue only applies to MacOS"
23CVE_STATUS[CVE-2009-0032] = "cpe-incorrect: Issue affects pdfdistiller plugin used with but not part of cups"
24CVE_STATUS[CVE-2018-6553] = "not-applicable-platform: This is an Ubuntu only issue"
25CVE_STATUS[CVE-2022-26691] = "fixed-version: This is fixed in 2.4.2 but the cve-check class still reports it"
26CVE_STATUS[CVE-2021-25317] = "not-applicable-config: This concerns /var/log/cups having lp ownership, our /var/log/cups is root:root, so this doesn't apply."
27
28LEAD_SONAME = "libcupsdriver.so"
29
30CLEANBROKEN = "1"
31
32inherit autotools-brokensep binconfig useradd systemd pkgconfig multilib_script github-releases
33
34USERADD_PACKAGES = "${PN}"
35GROUPADD_PARAM:${PN} = "--system lpadmin"
36
37SYSTEMD_SERVICE:${PN} = "cups.socket cups.path cups.service cups-lpd.socket"
38
39PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'zeroconf', 'avahi', '', d)} \
40                   ${@bb.utils.filter('DISTRO_FEATURES', 'pam systemd', d)} \
41                   openssl \
42"
43PACKAGECONFIG[avahi] = "--with-dnssd=avahi,--with-dnssd=no,avahi"
44PACKAGECONFIG[acl] = "--enable-acl,--disable-acl,acl"
45PACKAGECONFIG[gnutls] = "--with-tls=gnutls,,gnutls,,,openssl"
46PACKAGECONFIG[openssl] = "--with-tls=openssl,,openssl,,,gnutls"
47PACKAGECONFIG[pam] = "--enable-pam --with-pam-module=unix, --disable-pam, libpam"
48PACKAGECONFIG[systemd] = "--with-systemd=${systemd_system_unitdir},--without-systemd,systemd"
49PACKAGECONFIG[xinetd] = "--with-xinetd=${sysconfdir}/xinetd.d,--without-xinetd,xinetd"
50PACKAGECONFIG[webif] = "--enable-webif,--disable-webif"
51
52EXTRA_OECONF = " \
53               --enable-dbus \
54               --with-dbusdir=${sysconfdir}/dbus-1 \
55               --enable-browsing \
56               --disable-gssapi \
57               --enable-debug \
58               --disable-relro \
59               --enable-libusb \
60               --with-system-groups=lpadmin,root,sys,wheel \
61               --with-cups-group=lp \
62               --with-domainsocket=/run/cups/cups.sock \
63               --with-pkgconfpath=${libdir}/pkgconfig \
64               DSOFLAGS='${LDFLAGS}' \
65               "
66
67EXTRA_AUTORECONF += "--exclude=autoheader"
68
69do_install () {
70	oe_runmake "BUILDROOT=${D}" install
71
72	# Remove /var/run from package as cupsd will populate it on startup
73	rm -fr ${D}/${localstatedir}/run
74	rm -fr ${D}/${localstatedir}/log
75	rmdir ${D}/${libexecdir}/${BPN}/driver
76
77	# Fix the pam configuration file permissions
78	if ${@bb.utils.contains('PACKAGECONFIG', 'pam', 'true', 'false', d)}; then
79	    chmod 0644 ${D}${sysconfdir}/pam.d/cups
80	fi
81
82	# Remove sysinit script and symlinks if sysvinit is not in DISTRO_FEATURES
83	if ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','false','true',d)}; then
84	    rm -rf ${D}${sysconfdir}/init.d/
85	    rm -rf ${D}${sysconfdir}/rc*
86	    install -d ${D}${sysconfdir}/tmpfiles.d
87	    install -m 0644 ${WORKDIR}/cups-volatiles.conf \
88		    ${D}${sysconfdir}/tmpfiles.d/cups.conf
89	else
90	    install -d ${D}${sysconfdir}/default/volatiles
91	    install -m 0644 ${WORKDIR}/volatiles.99_cups \
92		    ${D}${sysconfdir}/default/volatiles/99_cups
93	fi
94}
95
96PACKAGES =+ "${PN}-lib ${PN}-libimage ${PN}-webif"
97
98RDEPENDS:${PN} += "${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'procps', '', d)}"
99FILES:${PN} += "${libexecdir}/cups/"
100
101FILES:${PN}-lib = "${libdir}/libcups.so.*"
102
103FILES:${PN}-libimage = "${libdir}/libcupsimage.so.*"
104
105# put the html for the web interface into its own PACKAGE
106FILES:${PN}-webif += "${datadir}/doc/cups/ ${datadir}/icons/"
107RRECOMMENDS:${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'webif', '${PN}-webif', '', d)}"
108
109CONFFILES:${PN} += "${sysconfdir}/cups/cupsd.conf"
110
111MULTILIB_SCRIPTS = "${PN}-dev:${bindir}/cups-config"
112
113LOCALE_PATHS += "${datadir}/cups/templates"
114
115SYSROOT_PREPROCESS_FUNCS += "cups_sysroot_preprocess"
116cups_sysroot_preprocess () {
117	sed -i ${SYSROOT_DESTDIR}${bindir_crossscripts}/cups-config -e 's:cups_datadir=.*:cups_datadir=${datadir}/cups:' -e 's:cups_serverbin=.*:cups_serverbin=${libexecdir}/cups:'
118}
119