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           file://CVE-2023-32324.patch \
19           "
20
21GITHUB_BASE_URI = "https://github.com/OpenPrinting/cups/releases"
22
23# Issue only applies to MacOS
24CVE_CHECK_IGNORE += "CVE-2008-1033"
25# Issue affects pdfdistiller plugin used with but not part of cups
26CVE_CHECK_IGNORE += "CVE-2009-0032"
27# This is an Ubuntu only issue.
28CVE_CHECK_IGNORE += "CVE-2018-6553"
29# This is fixed in 2.4.2 but the cve-check class still reports it
30CVE_CHECK_IGNORE += "CVE-2022-26691"
31
32LEAD_SONAME = "libcupsdriver.so"
33
34CLEANBROKEN = "1"
35
36inherit autotools-brokensep binconfig useradd systemd pkgconfig multilib_script github-releases
37
38USERADD_PACKAGES = "${PN}"
39GROUPADD_PARAM:${PN} = "--system lpadmin"
40
41SYSTEMD_SERVICE:${PN} = "cups.socket cups.path cups.service cups-lpd.socket"
42
43PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'zeroconf', 'avahi', '', d)} \
44                   ${@bb.utils.filter('DISTRO_FEATURES', 'pam systemd', d)}"
45PACKAGECONFIG[avahi] = "--with-dnssd=avahi,--with-dnssd=no,avahi"
46PACKAGECONFIG[acl] = "--enable-acl,--disable-acl,acl"
47PACKAGECONFIG[gnutls] = "--with-tls=gnutls,--with-tls=no,gnutls"
48PACKAGECONFIG[pam] = "--enable-pam --with-pam-module=unix, --disable-pam, libpam"
49PACKAGECONFIG[systemd] = "--with-systemd=${systemd_system_unitdir},--without-systemd,systemd"
50PACKAGECONFIG[xinetd] = "--with-xinetd=${sysconfdir}/xinetd.d,--without-xinetd,xinetd"
51PACKAGECONFIG[webif] = "--enable-webif,--disable-webif"
52
53EXTRA_OECONF = " \
54               --enable-dbus \
55               --with-dbusdir=${sysconfdir}/dbus-1 \
56               --enable-browsing \
57               --disable-gssapi \
58               --enable-debug \
59               --disable-relro \
60               --enable-libusb \
61               --with-system-groups=lpadmin \
62               --with-cups-group=lp \
63               --with-domainsocket=/run/cups/cups.sock \
64               --with-pkgconfpath=${libdir}/pkgconfig \
65               DSOFLAGS='${LDFLAGS}' \
66               "
67
68EXTRA_AUTORECONF += "--exclude=autoheader"
69
70do_install () {
71	oe_runmake "BUILDROOT=${D}" install
72
73	# Remove /var/run from package as cupsd will populate it on startup
74	rm -fr ${D}/${localstatedir}/run
75	rm -fr ${D}/${localstatedir}/log
76	rmdir ${D}/${libexecdir}/${BPN}/driver
77
78	# Fix the pam configuration file permissions
79	if ${@bb.utils.contains('PACKAGECONFIG', 'pam', 'true', 'false', d)}; then
80	    chmod 0644 ${D}${sysconfdir}/pam.d/cups
81	fi
82
83	# Remove sysinit script and symlinks if sysvinit is not in DISTRO_FEATURES
84	if ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','false','true',d)}; then
85	    rm -rf ${D}${sysconfdir}/init.d/
86	    rm -rf ${D}${sysconfdir}/rc*
87	    install -d ${D}${sysconfdir}/tmpfiles.d
88	    install -m 0644 ${WORKDIR}/cups-volatiles.conf \
89		    ${D}${sysconfdir}/tmpfiles.d/cups.conf
90	else
91	    install -d ${D}${sysconfdir}/default/volatiles
92	    install -m 0644 ${WORKDIR}/volatiles.99_cups \
93		    ${D}${sysconfdir}/default/volatiles/99_cups
94	fi
95}
96
97PACKAGES =+ "${PN}-lib ${PN}-libimage ${PN}-webif"
98
99RDEPENDS:${PN} += "${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'procps', '', d)}"
100FILES:${PN} += "${libexecdir}/cups/"
101
102FILES:${PN}-lib = "${libdir}/libcups.so.*"
103
104FILES:${PN}-libimage = "${libdir}/libcupsimage.so.*"
105
106# put the html for the web interface into its own PACKAGE
107FILES:${PN}-webif += "${datadir}/doc/cups/ ${datadir}/icons/"
108RRECOMMENDS:${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'webif', '${PN}-webif', '', d)}"
109
110CONFFILES:${PN} += "${sysconfdir}/cups/cupsd.conf"
111
112MULTILIB_SCRIPTS = "${PN}-dev:${bindir}/cups-config"
113
114SYSROOT_PREPROCESS_FUNCS += "cups_sysroot_preprocess"
115cups_sysroot_preprocess () {
116	sed -i ${SYSROOT_DESTDIR}${bindir_crossscripts}/cups-config -e 's:cups_datadir=.*:cups_datadir=${datadir}/cups:' -e 's:cups_serverbin=.*:cups_serverbin=${libexecdir}/cups:'
117}
118
119# -25317 concerns /var/log/cups having lp ownership.  Our /var/log/cups is
120# root:root, so this doesn't apply.
121CVE_CHECK_IGNORE += "CVE-2021-25317"
122