cups-2.2.2-r1.ebuild 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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/v${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. # systemd-socket.patch from Fedora
  75. PATCHES=(
  76. "${FILESDIR}/${PN}-2.2.0-dont-compress-manpages.patch"
  77. "${FILESDIR}/${PN}-1.6.0-fix-install-perms.patch"
  78. "${FILESDIR}/${PN}-1.4.4-nostrip.patch"
  79. "${FILESDIR}/${PN}-2.0.2-rename-systemd-service-files.patch"
  80. "${FILESDIR}/${PN}-2.0.1-xinetd-installation-fix.patch"
  81. "${FILESDIR}/${PN}-2.0.3-cross-compile.patch"
  82. )
  83. MULTILIB_CHOST_TOOLS=(
  84. /usr/bin/cups-config
  85. )
  86. pkg_setup() {
  87. enewgroup lp
  88. enewuser lp -1 -1 -1 lp
  89. enewgroup lpadmin 106
  90. use python && python-single-r1_pkg_setup
  91. if use kernel_linux; then
  92. linux-info_pkg_setup
  93. if ! linux_config_exists; then
  94. ewarn "Can't check the linux kernel configuration."
  95. ewarn "You might have some incompatible options enabled."
  96. else
  97. # recheck that we don't have usblp to collide with libusb; this should now work in most cases (bug 501122)
  98. if use usb; then
  99. if linux_chkconfig_present USB_PRINTER; then
  100. elog "Your USB printers will be managed via libusb. In case you run into problems, "
  101. elog "please try disabling USB_PRINTER support in your kernel or blacklisting the"
  102. elog "usblp kernel module."
  103. elog "Alternatively, just disable the usb useflag for cups (your printer will still work)."
  104. fi
  105. else
  106. #here we should warn user that he should enable it so he can print
  107. if ! linux_chkconfig_present USB_PRINTER; then
  108. ewarn "If you plan to use USB printers you should enable the USB_PRINTER"
  109. ewarn "support in your kernel."
  110. ewarn "Please enable it:"
  111. ewarn " CONFIG_USB_PRINTER=y"
  112. ewarn "in /usr/src/linux/.config or"
  113. ewarn " Device Drivers --->"
  114. ewarn " USB support --->"
  115. ewarn " [*] USB Printer support"
  116. ewarn "Alternatively, enable the usb useflag for cups and use the libusb code."
  117. fi
  118. fi
  119. fi
  120. fi
  121. }
  122. src_prepare() {
  123. if ! use kerberos ; then
  124. PATCHES+=(
  125. "${FILESDIR}/${PN}-2.2.2-no_kerberos_config.patch"
  126. )
  127. fi
  128. default
  129. # Remove ".SILENT" rule for verbose output (bug 524338).
  130. sed 's#^.SILENT:##g' -i "${S}"/Makedefs.in || die "sed failed"
  131. # Fix install-sh, posix sh does not have 'function'.
  132. sed 's#function gzipcp#gzipcp()#g' -i "${S}/install-sh"
  133. AT_M4DIR=config-scripts eaclocal
  134. eautoconf
  135. # custom Makefiles
  136. multilib_copy_sources
  137. }
  138. multilib_src_configure() {
  139. export DSOFLAGS="${LDFLAGS}"
  140. einfo LANGS=\"${LANGS}\"
  141. einfo LINGUAS=\"${LINGUAS}\"
  142. local myconf=()
  143. if tc-is-static-only; then
  144. myconf+=(
  145. --disable-shared
  146. )
  147. fi
  148. # explicitly specify compiler wrt bug 524340
  149. #
  150. # need to override KRB5CONFIG for proper flags
  151. # https://www.cups.org/str.php?L4423
  152. econf \
  153. CC="$(tc-getCC)" \
  154. CXX="$(tc-getCXX)" \
  155. KRB5CONFIG="${EPREFIX}"/usr/bin/${CHOST}-krb5-config \
  156. --libdir="${EPREFIX}"/usr/$(get_libdir) \
  157. --localstatedir="${EPREFIX}"/var \
  158. --with-rundir="${EPREFIX}"/run/cups \
  159. --with-cups-user=lp \
  160. --with-cups-group=lp \
  161. --with-docdir="${EPREFIX}"/usr/share/cups/html \
  162. --with-languages="${LINGUAS}" \
  163. --with-system-groups=lpadmin \
  164. --with-xinetd=/etc/xinetd.d \
  165. $(multilib_native_use_enable acl) \
  166. $(use_enable dbus) \
  167. $(use_enable debug) \
  168. $(use_enable debug debug-guards) \
  169. $(use_enable debug debug-printfs) \
  170. $(multilib_native_use_with java) \
  171. $(use_enable kerberos gssapi) \
  172. $(multilib_native_use_enable pam) \
  173. $(multilib_native_use_with python python "${PYTHON}") \
  174. $(use_enable static-libs static) \
  175. $(use_enable threads) \
  176. $(use_enable ssl gnutls) \
  177. $(use_enable systemd) \
  178. $(multilib_native_use_enable usb libusb) \
  179. $(use_enable zeroconf avahi) \
  180. --disable-dnssd \
  181. --without-perl \
  182. --without-php \
  183. $(multilib_is_native_abi && echo --enable-libpaper || echo --disable-libpaper) \
  184. "${myconf[@]}"
  185. # install in /usr/libexec always, instead of using /usr/lib/cups, as that
  186. # makes more sense when facing multilib support.
  187. sed -i -e "s:SERVERBIN.*:SERVERBIN = \"\$\(BUILDROOT\)${EPREFIX}/usr/libexec/cups\":" Makedefs || die
  188. sed -i -e "s:#define CUPS_SERVERBIN.*:#define CUPS_SERVERBIN \"${EPREFIX}/usr/libexec/cups\":" config.h || die
  189. sed -i -e "s:cups_serverbin=.*:cups_serverbin=\"${EPREFIX}/usr/libexec/cups\":" cups-config || die
  190. }
  191. multilib_src_compile() {
  192. if multilib_is_native_abi; then
  193. default
  194. else
  195. emake libs
  196. fi
  197. }
  198. multilib_src_test() {
  199. multilib_is_native_abi && default
  200. }
  201. multilib_src_install() {
  202. if multilib_is_native_abi; then
  203. emake BUILDROOT="${D}" install
  204. else
  205. emake BUILDROOT="${D}" install-libs install-headers
  206. dobin cups-config
  207. fi
  208. }
  209. multilib_src_install_all() {
  210. dodoc {CHANGES,CREDITS,README}.txt
  211. # move the default config file to docs
  212. dodoc "${ED}"/etc/cups/cupsd.conf.default
  213. rm -f "${ED}"/etc/cups/cupsd.conf.default
  214. # clean out cups init scripts
  215. rm -rf "${ED}"/etc/{init.d/cups,rc*,pam.d/cups}
  216. # install our init script
  217. local neededservices
  218. use zeroconf && neededservices+=" avahi-daemon"
  219. use dbus && neededservices+=" dbus"
  220. [[ -n ${neededservices} ]] && neededservices="need${neededservices}"
  221. cp "${FILESDIR}"/cupsd.init.d-r2 "${T}"/cupsd || die
  222. sed -i \
  223. -e "s/@neededservices@/$neededservices/" \
  224. "${T}"/cupsd || die
  225. doinitd "${T}"/cupsd
  226. # install our pam script
  227. pamd_mimic_system cups auth account
  228. if use xinetd ; then
  229. # correct path
  230. sed -i \
  231. -e "s:server = .*:server = /usr/libexec/cups/daemon/cups-lpd:" \
  232. "${ED}"/etc/xinetd.d/cups-lpd || die
  233. # it is safer to disable this by default, bug #137130
  234. grep -w 'disable' "${ED}"/etc/xinetd.d/cups-lpd || \
  235. { sed -i -e "s:}:\tdisable = yes\n}:" "${ED}"/etc/xinetd.d/cups-lpd || die ; }
  236. # write permission for file owner (root), bug #296221
  237. fperms u+w /etc/xinetd.d/cups-lpd || die "fperms failed"
  238. else
  239. # always configure with --with-xinetd= and clean up later,
  240. # bug #525604
  241. rm -rf "${ED}"/etc/xinetd.d
  242. fi
  243. keepdir /usr/libexec/cups/driver /usr/share/cups/{model,profiles} \
  244. /var/log/cups /var/spool/cups/tmp
  245. keepdir /etc/cups/{interfaces,ppd,ssl}
  246. use X || rm -r "${ED}"/usr/share/applications
  247. # create /etc/cups/client.conf, bug #196967 and #266678
  248. echo "ServerName ${EPREFIX}/run/cups/cups.sock" >> "${ED}"/etc/cups/client.conf
  249. # the following file is now provided by cups-filters:
  250. rm -r "${ED}"/usr/share/cups/banners || die
  251. # the following are created by the init script
  252. rm -r "${ED}"/var/cache/cups || die
  253. rm -r "${ED}"/run || die
  254. # for the special case of running lprng and cups together, bug 467226
  255. if use lprng-compat ; then
  256. rm -fv "${ED}"/usr/bin/{lp*,cancel}
  257. rm -fv "${ED}"/usr/sbin/lp*
  258. rm -fv "${ED}"/usr/share/man/man1/{lp*,cancel*}
  259. rm -fv "${ED}"/usr/share/man/man8/lp*
  260. ewarn "Not installing lp... binaries, since the lprng-compat useflag is set."
  261. ewarn "Unless you plan to install an exotic server setup, you most likely"
  262. ewarn "do not want this. Disable the useflag then and all will be fine."
  263. fi
  264. }
  265. pkg_preinst() {
  266. gnome2_icon_savelist
  267. }
  268. pkg_postinst() {
  269. # Update desktop file database and gtk icon cache (bug 370059)
  270. gnome2_icon_cache_update
  271. fdo-mime_desktop_database_update
  272. # not slotted - at most one value
  273. if ! [[ "${REPLACING_VERSIONS}" ]]; then
  274. echo
  275. elog "For information about installing a printer and general cups setup"
  276. elog "take a look at: https://wiki.gentoo.org/wiki/Printing"
  277. echo
  278. fi
  279. if [[ "${REPLACING_VERSIONS}" ]] && [[ "${REPLACING_VERSIONS}" < "1.6" ]]; then
  280. echo
  281. elog "CUPS-1.6 no longer supports automatic remote printers or implicit classes"
  282. elog "via the CUPS, LDAP, or SLP protocols, i.e. \"network browsing\"."
  283. elog "You will have to find printers using zeroconf/avahi instead, enter"
  284. elog "the location manually, or run cups-browsed from net-print/cups-filters"
  285. elog "which re-adds that functionality as a separate daemon."
  286. echo
  287. fi
  288. if [[ "${REPLACING_VERSIONS}" == "1.6.2-r4" ]]; then
  289. ewarn
  290. ewarn "You are upgrading from the broken version net-print/cups-1.6.2-r4."
  291. ewarn "Please rebuild net-print/cups-filters now to make sure everything is OK."
  292. ewarn
  293. fi
  294. }
  295. pkg_postrm() {
  296. # Update desktop file database and gtk icon cache (bug 370059)
  297. gnome2_icon_cache_update
  298. fdo-mime_desktop_database_update
  299. }