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