cups-2.2.2-r3.ebuild 10.0 KB

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