1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python2_7 )
8 inherit autotools flag-o-matic linux-info xdg multilib-minimal pam systemd toolchain-funcs
11 MY_PV="${MY_PV/_beta/b}"
14 if [[ ${PV} == *9999 ]]; then
16 EGIT_REPO_URI="https://github.com/apple/cups.git"
17 if [[ ${PV} != 9999 ]]; then
18 EGIT_BRANCH=branch-${PV/.9999}
21 #SRC_URI="https://github.com/apple/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
22 SRC_URI="https://github.com/apple/cups/releases/download/v${MY_PV}/${MY_P}-source.tar.gz"
23 if [[ "${PV}" != *_beta* ]] && [[ "${PV}" != *_rc* ]] ; then
24 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~m68k-mint"
28 DESCRIPTION="The Common Unix Printing System"
29 HOMEPAGE="https://www.cups.org/"
33 IUSE="acl dbus debug kerberos lprng-compat pam selinux +ssl static-libs systemd +threads usb X xinetd zeroconf"
44 dbus? ( >=sys-apps/dbus-1.6.18-r1[${MULTILIB_USEDEP}] )
45 kerberos? ( >=virtual/krb5-0-r1[${MULTILIB_USEDEP}] )
46 !lprng-compat? ( !net-print/lprng )
48 ssl? ( >=net-libs/gnutls-2.12.23-r6:0=[${MULTILIB_USEDEP}] )
49 systemd? ( sys-apps/systemd )
50 usb? ( virtual/libusb:1 )
51 X? ( x11-misc/xdg-utils )
52 xinetd? ( sys-apps/xinetd )
53 zeroconf? ( >=net-dns/avahi-0.6.31-r2[${MULTILIB_USEDEP}] )
60 >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}]
66 selinux? ( sec-policy/selinux-cups )
69 PDEPEND=">=net-print/cups-filters-1.0.43"
75 # upstream includes an interactive test which is a nono for gentoo
78 # systemd-socket.patch from Fedora
80 "${FILESDIR}/${PN}-2.2.6-fix-install-perms.patch"
81 "${FILESDIR}/${PN}-1.4.4-nostrip.patch"
82 "${FILESDIR}/${PN}-2.0.2-rename-systemd-service-files.patch"
83 "${FILESDIR}/${PN}-2.0.1-xinetd-installation-fix.patch"
86 MULTILIB_CHOST_TOOLS=(
90 S="${WORKDIR}/${MY_P}"
93 #enewgroup lp -> acct-group/lp
94 # user lp already provided by baselayout
95 #enewuser lp -1 -1 -1 lp
96 #enewgroup lpadmin 106
98 if use kernel_linux; then
100 if ! linux_config_exists; then
101 ewarn "Can't check the linux kernel configuration."
102 ewarn "You might have some incompatible options enabled."
104 # recheck that we don't have usblp to collide with libusb; this should now work in most cases (bug 501122)
106 if linux_chkconfig_present USB_PRINTER; then
107 elog "Your USB printers will be managed via libusb. In case you run into problems, "
108 elog "please try disabling USB_PRINTER support in your kernel or blacklisting the"
109 elog "usblp kernel module."
110 elog "Alternatively, just disable the usb useflag for cups (your printer will still work)."
113 #here we should warn user that he should enable it so he can print
114 if ! linux_chkconfig_present USB_PRINTER; then
115 ewarn "If you plan to use USB printers you should enable the USB_PRINTER"
116 ewarn "support in your kernel."
117 ewarn "Please enable it:"
118 ewarn " CONFIG_USB_PRINTER=y"
119 ewarn "in /usr/src/linux/.config or"
120 ewarn " Device Drivers --->"
121 ewarn " USB support --->"
122 ewarn " [*] USB Printer support"
123 ewarn "Alternatively, enable the usb useflag for cups and use the libusb code."
133 # Remove ".SILENT" rule for verbose output (bug 524338).
134 sed 's#^.SILENT:##g' -i "${S}"/Makedefs.in || die "sed failed"
136 # Fix install-sh, posix sh does not have 'function'.
137 sed 's#function gzipcp#gzipcp()#g' -i "${S}/install-sh"
139 # Do not add -Werror even for live ebuilds
140 sed '/WARNING_OPTIONS/s@-Werror@@' \
141 -i config-scripts/cups-compiler.m4 || die
143 AT_M4DIR=config-scripts eaclocal
147 multilib_copy_sources
150 multilib_src_configure() {
151 export DSOFLAGS="${LDFLAGS}"
153 einfo LINGUAS=\"${LINGUAS}\"
155 # explicitly specify compiler wrt bug 524340
157 # need to override KRB5CONFIG for proper flags
158 # https://github.com/apple/cups/issues/4423
162 KRB5CONFIG="${EPREFIX}"/usr/bin/${CHOST}-krb5-config
163 --libdir="${EPREFIX}"/usr/$(get_libdir)
164 --localstatedir="${EPREFIX}"/var
165 --with-exe-file-perm=755
166 --with-rundir="${EPREFIX}"/run/cups
169 --with-docdir="${EPREFIX}"/usr/share/cups/html
170 --with-languages="${LINGUAS}"
171 --with-system-groups=lpadmin
172 --with-xinetd="${EPREFIX}"/etc/xinetd.d
173 $(multilib_native_use_enable acl)
176 $(use_enable debug debug-guards)
177 $(use_enable debug debug-printfs)
178 $(use_enable kerberos gssapi)
179 $(multilib_native_use_enable pam)
180 $(use_enable static-libs static)
181 $(use_enable threads)
182 $(use_enable ssl gnutls)
183 $(use_enable systemd)
184 $(multilib_native_use_enable usb libusb)
185 $(use_enable zeroconf avahi)
187 $(multilib_is_native_abi && echo --enable-libpaper || echo --disable-libpaper)
190 if tc-is-static-only; then
196 econf "${myeconfargs[@]}"
198 # install in /usr/libexec always, instead of using /usr/lib/cups, as that
199 # makes more sense when facing multilib support.
200 sed -i -e "s:SERVERBIN.*:SERVERBIN = \"\$\(BUILDROOT\)${EPREFIX}/usr/libexec/cups\":" Makedefs || die
201 sed -i -e "s:#define CUPS_SERVERBIN.*:#define CUPS_SERVERBIN \"${EPREFIX}/usr/libexec/cups\":" config.h || die
202 sed -i -e "s:cups_serverbin=.*:cups_serverbin=\"${EPREFIX}/usr/libexec/cups\":" cups-config || die
204 # additional path corrections needed for prefix, see bug 597728
206 -e "s:ICONDIR.*:ICONDIR = ${EPREFIX}/usr/share/icons:" \
207 -e "s:INITDIR.*:INITDIR = ${EPREFIX}/etc:" \
208 -e "s:DBUSDIR.*:DBUSDIR = ${EPREFIX}/etc/dbus-1:" \
209 -e "s:MENUDIR.*:MENUDIR = ${EPREFIX}/usr/share/applications:" \
213 multilib_src_compile() {
214 if multilib_is_native_abi; then
221 multilib_src_test() {
222 multilib_is_native_abi && default
225 multilib_src_install() {
226 if multilib_is_native_abi; then
227 emake BUILDROOT="${D}" install
229 emake BUILDROOT="${D}" install-libs install-headers
234 multilib_src_install_all() {
235 dodoc {CHANGES,CREDITS,README}.md
237 # move the default config file to docs
238 dodoc "${ED}"/etc/cups/cupsd.conf.default
239 rm -f "${ED}"/etc/cups/cupsd.conf.default
241 # clean out cups init scripts
242 rm -rf "${ED}"/etc/{init.d/cups,rc*,pam.d/cups}
244 # install our init script
245 local neededservices=(
246 $(usex zeroconf avahi-daemon '')
249 [[ -n ${neededservices[@]} ]] && neededservices="need ${neededservices[@]}"
250 cp "${FILESDIR}"/cupsd.init.d-r3 "${T}"/cupsd || die
252 -e "s/@neededservices@/${neededservices}/" \
256 # install our pam script
257 pamd_mimic_system cups auth account
262 -e "s:server = .*:server = /usr/libexec/cups/daemon/cups-lpd:" \
263 "${ED}"/etc/xinetd.d/cups-lpd || die
264 # it is safer to disable this by default, bug #137130
265 grep -w 'disable' "${ED}"/etc/xinetd.d/cups-lpd || \
266 { sed -i -e "s:}:\tdisable = yes\n}:" "${ED}"/etc/xinetd.d/cups-lpd || die ; }
267 # write permission for file owner (root), bug #296221
268 fperms u+w /etc/xinetd.d/cups-lpd
270 # always configure with --with-xinetd= and clean up later,
272 rm -rf "${ED}"/etc/xinetd.d
275 keepdir /usr/libexec/cups/driver /usr/share/cups/{model,profiles} \
276 /var/log/cups /var/spool/cups/tmp
278 keepdir /etc/cups/{interfaces,ppd,ssl}
281 rm -r "${ED}"/usr/share/applications || die
284 # create /etc/cups/client.conf, bug #196967 and #266678
285 echo "ServerName ${EPREFIX}/run/cups/cups.sock" >> "${ED}"/etc/cups/client.conf
287 # the following file is now provided by cups-filters:
288 rm -r "${ED}"/usr/share/cups/banners || die
290 # the following are created by the init script
291 rm -r "${ED}"/var/cache/cups || die
292 rm -r "${ED}"/run || die
294 # for the special case of running lprng and cups together, bug 467226
295 if use lprng-compat ; then
296 rm -fv "${ED}"/usr/bin/{lp*,cancel}
297 rm -fv "${ED}"/usr/sbin/lp*
298 rm -fv "${ED}"/usr/share/man/man1/{lp*,cancel*}
299 rm -fv "${ED}"/usr/share/man/man8/lp*
300 ewarn "Not installing lp... binaries, since the lprng-compat useflag is set."
301 ewarn "Unless you plan to install an exotic server setup, you most likely"
302 ewarn "do not want this. Disable the useflag then and all will be fine."
311 # Update desktop file database and gtk icon cache (bug 370059)
316 for v in ${REPLACING_VERSIONS}; do
317 if ! ver_test ${v} -ge 2.2.2-r2 ; then
319 ewarn "The cupsd init script switched to using pidfiles. Shutting down"
320 ewarn "cupsd will fail the next time. To fix this, please run once as root"
321 ewarn " killall cupsd ; /etc/init.d/cupsd zap ; /etc/init.d/cupsd start"
327 for v in ${REPLACING_VERSIONS}; do
329 elog "For information about installing a printer and general cups setup"
330 elog "take a look at: https://wiki.gentoo.org/wiki/Printing"
337 # Update desktop file database and gtk icon cache (bug 370059)