cups-2.1.4.ebuild 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=6
  4. PYTHON_COMPAT=( python2_7 )
  5. inherit autotools fdo-mime gnome2-utils flag-o-matic linux-info \
  6. multilib multilib-minimal pam python-single-r1 user versionator \
  7. java-pkg-opt-2 systemd toolchain-funcs
  8. MY_P=${P/_rc/rc}
  9. MY_P=${MY_P/_beta/b}
  10. MY_PV=${PV/_rc/rc}
  11. MY_PV=${MY_PV/_beta/b}
  12. if [[ ${PV} == *9999 ]]; then
  13. inherit git-r3
  14. EGIT_REPO_URI="http://www.cups.org/cups.git"
  15. if [[ ${PV} != 9999 ]]; then
  16. EGIT_BRANCH=branch-${PV/.9999}
  17. fi
  18. else
  19. SRC_URI="https://github.com/apple/${PN}/archive/release-${PV}.tar.gz -> ${P}.tar.gz"
  20. KEYWORDS="alpha amd64 arm ~arm64 hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~m68k-mint"
  21. fi
  22. DESCRIPTION="The Common Unix Printing System"
  23. HOMEPAGE="http://www.cups.org/"
  24. LICENSE="GPL-2"
  25. SLOT="0"
  26. IUSE="acl dbus debug java kerberos lprng-compat pam
  27. python selinux +ssl static-libs systemd +threads usb X xinetd zeroconf"
  28. LANGS="ca cs de es fr it ja ru"
  29. for X in ${LANGS} ; do
  30. IUSE="${IUSE} +linguas_${X}"
  31. done
  32. CDEPEND="
  33. app-text/libpaper
  34. sys-libs/zlib
  35. acl? (
  36. kernel_linux? (
  37. sys-apps/acl
  38. sys-apps/attr
  39. )
  40. )
  41. dbus? ( >=sys-apps/dbus-1.6.18-r1[${MULTILIB_USEDEP}] )
  42. java? ( >=virtual/jre-1.6:* )
  43. kerberos? ( >=virtual/krb5-0-r1[${MULTILIB_USEDEP}] )
  44. !lprng-compat? ( !net-print/lprng )
  45. pam? ( virtual/pam )
  46. python? ( ${PYTHON_DEPS} )
  47. ssl? (
  48. >=dev-libs/libgcrypt-1.5.3:0[${MULTILIB_USEDEP}]
  49. >=net-libs/gnutls-2.12.23-r6[${MULTILIB_USEDEP}]
  50. )
  51. systemd? ( sys-apps/systemd )
  52. usb? ( virtual/libusb:1 )
  53. X? ( x11-misc/xdg-utils )
  54. xinetd? ( sys-apps/xinetd )
  55. zeroconf? ( >=net-dns/avahi-0.6.31-r2[${MULTILIB_USEDEP}] )
  56. abi_x86_32? (
  57. !<=app-emulation/emul-linux-x86-baselibs-20140508
  58. !app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)]
  59. )
  60. "
  61. DEPEND="${CDEPEND}
  62. >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}]
  63. "
  64. RDEPEND="${CDEPEND}
  65. selinux? ( sec-policy/selinux-cups )
  66. "
  67. PDEPEND=">=net-print/cups-filters-1.0.43"
  68. REQUIRED_USE="
  69. python? ( ${PYTHON_REQUIRED_USE} )
  70. usb? ( threads )
  71. "
  72. # upstream includes an interactive test which is a nono for gentoo
  73. RESTRICT="test"
  74. S="${WORKDIR}/${PN}-release-${MY_PV}"
  75. # systemd-socket.patch from Fedora
  76. PATCHES=(
  77. "${FILESDIR}/${PN}-1.6.0-dont-compress-manpages.patch"
  78. "${FILESDIR}/${PN}-1.6.0-fix-install-perms.patch"
  79. "${FILESDIR}/${PN}-1.4.4-nostrip.patch"
  80. "${FILESDIR}/${PN}-2.0.2-rename-systemd-service-files.patch"
  81. "${FILESDIR}/${PN}-2.1.2-systemd-socket.patch"
  82. "${FILESDIR}/${PN}-2.0.1-xinetd-installation-fix.patch"
  83. "${FILESDIR}/${PN}-2.0.3-cross-compile.patch"
  84. )
  85. MULTILIB_CHOST_TOOLS=(
  86. /usr/bin/cups-config
  87. )
  88. pkg_setup() {
  89. enewgroup lp
  90. enewuser lp -1 -1 -1 lp
  91. enewgroup lpadmin 106
  92. use python && python-single-r1_pkg_setup
  93. if use kernel_linux; then
  94. linux-info_pkg_setup
  95. if ! linux_config_exists; then
  96. ewarn "Can't check the linux kernel configuration."
  97. ewarn "You might have some incompatible options enabled."
  98. else
  99. # recheck that we don't have usblp to collide with libusb
  100. if use usb; then
  101. if linux_chkconfig_present USB_PRINTER; then
  102. eerror "Your usb printers will be managed via libusb. In this case, "
  103. eerror "${P} requires the USB_PRINTER support disabled."
  104. eerror "Please disable it:"
  105. eerror " CONFIG_USB_PRINTER=n"
  106. eerror "in /usr/src/linux/.config or"
  107. eerror " Device Drivers --->"
  108. eerror " USB support --->"
  109. eerror " [ ] USB Printer support"
  110. eerror "Alternatively, just disable the usb useflag for cups (your printer will still work)."
  111. fi
  112. else
  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."
  124. fi
  125. fi
  126. fi
  127. fi
  128. }
  129. src_prepare() {
  130. default
  131. # Remove ".SILENT" rule for verbose output (bug 524338).
  132. sed 's#^.SILENT:##g' -i "${S}"/Makedefs.in || die "sed failed"
  133. # Fix install-sh, posix sh does not have 'function'.
  134. sed 's#function gzipcp#gzipcp()#g' -i "${S}/install-sh"
  135. AT_M4DIR=config-scripts eaclocal
  136. eautoconf
  137. # custom Makefiles
  138. multilib_copy_sources
  139. }
  140. multilib_src_configure() {
  141. export DSOFLAGS="${LDFLAGS}"
  142. einfo LANGS=\"${LANGS}\"
  143. einfo LINGUAS=\"${LINGUAS}\"
  144. local myconf=()
  145. if tc-is-static-only; then
  146. myconf+=(
  147. --disable-shared
  148. )
  149. fi
  150. # explicitly specify compiler wrt bug 524340
  151. #
  152. # need to override KRB5CONFIG for proper flags
  153. # https://www.cups.org/str.php?L4423
  154. econf \
  155. CC="$(tc-getCC)" \
  156. CXX="$(tc-getCXX)" \
  157. KRB5CONFIG="${EPREFIX}"/usr/bin/${CHOST}-krb5-config \
  158. --libdir="${EPREFIX}"/usr/$(get_libdir) \
  159. --localstatedir="${EPREFIX}"/var \
  160. --with-rundir="${EPREFIX}"/run/cups \
  161. --with-cups-user=lp \
  162. --with-cups-group=lp \
  163. --with-docdir="${EPREFIX}"/usr/share/cups/html \
  164. --with-languages="${LINGUAS}" \
  165. --with-system-groups=lpadmin \
  166. --with-xinetd=/etc/xinetd.d \
  167. $(multilib_native_use_enable acl) \
  168. $(use_enable dbus) \
  169. $(use_enable debug) \
  170. $(use_enable debug debug-guards) \
  171. $(use_enable debug debug-printfs) \
  172. $(multilib_native_use_with java) \
  173. $(use_enable kerberos gssapi) \
  174. $(multilib_native_use_enable pam) \
  175. $(multilib_native_use_with python python "${PYTHON}") \
  176. $(use_enable static-libs static) \
  177. $(use_enable threads) \
  178. $(use_enable ssl gnutls) \
  179. $(use_enable systemd) \
  180. $(multilib_native_use_enable usb libusb) \
  181. $(use_enable zeroconf avahi) \
  182. --disable-dnssd \
  183. --without-perl \
  184. --without-php \
  185. $(multilib_is_native_abi && echo --enable-libpaper || echo --disable-libpaper) \
  186. "${myconf[@]}"
  187. # install in /usr/libexec always, instead of using /usr/lib/cups, as that
  188. # makes more sense when facing multilib support.
  189. sed -i -e "s:SERVERBIN.*:SERVERBIN = \"\$\(BUILDROOT\)${EPREFIX}/usr/libexec/cups\":" Makedefs || die
  190. sed -i -e "s:#define CUPS_SERVERBIN.*:#define CUPS_SERVERBIN \"${EPREFIX}/usr/libexec/cups\":" config.h || die
  191. sed -i -e "s:cups_serverbin=.*:cups_serverbin=\"${EPREFIX}/usr/libexec/cups\":" cups-config || die
  192. }
  193. multilib_src_compile() {
  194. if multilib_is_native_abi; then
  195. default
  196. else
  197. emake libs
  198. fi
  199. }
  200. multilib_src_test() {
  201. multilib_is_native_abi && default
  202. }
  203. multilib_src_install() {
  204. if multilib_is_native_abi; then
  205. emake BUILDROOT="${D}" install
  206. else
  207. emake BUILDROOT="${D}" install-libs install-headers
  208. dobin cups-config
  209. fi
  210. }
  211. multilib_src_install_all() {
  212. dodoc {CHANGES,CREDITS,README}.txt
  213. # move the default config file to docs
  214. dodoc "${ED}"/etc/cups/cupsd.conf.default
  215. rm -f "${ED}"/etc/cups/cupsd.conf.default
  216. # clean out cups init scripts
  217. rm -rf "${ED}"/etc/{init.d/cups,rc*,pam.d/cups}
  218. # install our init script
  219. local neededservices
  220. use zeroconf && neededservices+=" avahi-daemon"
  221. use dbus && neededservices+=" dbus"
  222. [[ -n ${neededservices} ]] && neededservices="need${neededservices}"
  223. cp "${FILESDIR}"/cupsd.init.d-r2 "${T}"/cupsd || die
  224. sed -i \
  225. -e "s/@neededservices@/$neededservices/" \
  226. "${T}"/cupsd || die
  227. doinitd "${T}"/cupsd
  228. # install our pam script
  229. pamd_mimic_system cups auth account
  230. if use xinetd ; then
  231. # correct path
  232. sed -i \
  233. -e "s:server = .*:server = /usr/libexec/cups/daemon/cups-lpd:" \
  234. "${ED}"/etc/xinetd.d/cups-lpd || die
  235. # it is safer to disable this by default, bug #137130
  236. grep -w 'disable' "${ED}"/etc/xinetd.d/cups-lpd || \
  237. { sed -i -e "s:}:\tdisable = yes\n}:" "${ED}"/etc/xinetd.d/cups-lpd || die ; }
  238. # write permission for file owner (root), bug #296221
  239. fperms u+w /etc/xinetd.d/cups-lpd || die "fperms failed"
  240. else
  241. # always configure with --with-xinetd= and clean up later,
  242. # bug #525604
  243. rm -rf "${ED}"/etc/xinetd.d
  244. fi
  245. keepdir /usr/libexec/cups/driver /usr/share/cups/{model,profiles} \
  246. /var/log/cups /var/spool/cups/tmp
  247. keepdir /etc/cups/{interfaces,ppd,ssl}
  248. use X || rm -r "${ED}"/usr/share/applications
  249. # create /etc/cups/client.conf, bug #196967 and #266678
  250. echo "ServerName ${EPREFIX}/run/cups/cups.sock" >> "${ED}"/etc/cups/client.conf
  251. # the following file is now provided by cups-filters:
  252. rm -r "${ED}"/usr/share/cups/banners || die
  253. # the following are created by the init script
  254. rm -r "${ED}"/var/cache/cups || die
  255. rm -r "${ED}"/run || die
  256. # for the special case of running lprng and cups together, bug 467226
  257. if use lprng-compat ; then
  258. rm -fv "${ED}"/usr/bin/{lp*,cancel}
  259. rm -fv "${ED}"/usr/sbin/lp*
  260. rm -fv "${ED}"/usr/share/man/man1/{lp*,cancel*}
  261. rm -fv "${ED}"/usr/share/man/man8/lp*
  262. ewarn "Not installing lp... binaries, since the lprng-compat useflag is set."
  263. ewarn "Unless you plan to install an exotic server setup, you most likely"
  264. ewarn "do not want this. Disable the useflag then and all will be fine."
  265. fi
  266. }
  267. pkg_preinst() {
  268. gnome2_icon_savelist
  269. }
  270. pkg_postinst() {
  271. # Update desktop file database and gtk icon cache (bug 370059)
  272. gnome2_icon_cache_update
  273. fdo-mime_desktop_database_update
  274. # not slotted - at most one value
  275. if ! [[ "${REPLACING_VERSIONS}" ]]; then
  276. echo
  277. elog "For information about installing a printer and general cups setup"
  278. elog "take a look at: https://wiki.gentoo.org/wiki/Printing"
  279. echo
  280. fi
  281. if [[ "${REPLACING_VERSIONS}" ]] && [[ "${REPLACING_VERSIONS}" < "1.6" ]]; then
  282. echo
  283. elog "CUPS-1.6 no longer supports automatic remote printers or implicit classes"
  284. elog "via the CUPS, LDAP, or SLP protocols, i.e. \"network browsing\"."
  285. elog "You will have to find printers using zeroconf/avahi instead, enter"
  286. elog "the location manually, or run cups-browsed from net-print/cups-filters"
  287. elog "which re-adds that functionality as a separate daemon."
  288. echo
  289. fi
  290. if [[ "${REPLACING_VERSIONS}" == "1.6.2-r4" ]]; then
  291. ewarn
  292. ewarn "You are upgrading from the broken version net-print/cups-1.6.2-r4."
  293. ewarn "Please rebuild net-print/cups-filters now to make sure everything is OK."
  294. ewarn
  295. fi
  296. }
  297. pkg_postrm() {
  298. # Update desktop file database and gtk icon cache (bug 370059)
  299. gnome2_icon_cache_update
  300. fdo-mime_desktop_database_update
  301. }