cups-2.2.2-r2.ebuild 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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=/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. }
  190. multilib_src_compile() {
  191. if multilib_is_native_abi; then
  192. default
  193. else
  194. emake libs
  195. fi
  196. }
  197. multilib_src_test() {
  198. multilib_is_native_abi && default
  199. }
  200. multilib_src_install() {
  201. if multilib_is_native_abi; then
  202. emake BUILDROOT="${D}" install
  203. else
  204. emake BUILDROOT="${D}" install-libs install-headers
  205. dobin cups-config
  206. fi
  207. }
  208. multilib_src_install_all() {
  209. dodoc {CHANGES,CREDITS,README}.txt
  210. # move the default config file to docs
  211. dodoc "${ED}"/etc/cups/cupsd.conf.default
  212. rm -f "${ED}"/etc/cups/cupsd.conf.default
  213. # clean out cups init scripts
  214. rm -rf "${ED}"/etc/{init.d/cups,rc*,pam.d/cups}
  215. # install our init script
  216. local neededservices
  217. use zeroconf && neededservices+=" avahi-daemon"
  218. use dbus && neededservices+=" dbus"
  219. [[ -n ${neededservices} ]] && neededservices="need${neededservices}"
  220. cp "${FILESDIR}"/cupsd.init.d-r3 "${T}"/cupsd || die
  221. sed -i \
  222. -e "s/@neededservices@/$neededservices/" \
  223. "${T}"/cupsd || die
  224. doinitd "${T}"/cupsd
  225. # install our pam script
  226. pamd_mimic_system cups auth account
  227. if use xinetd ; then
  228. # correct path
  229. sed -i \
  230. -e "s:server = .*:server = /usr/libexec/cups/daemon/cups-lpd:" \
  231. "${ED}"/etc/xinetd.d/cups-lpd || die
  232. # it is safer to disable this by default, bug #137130
  233. grep -w 'disable' "${ED}"/etc/xinetd.d/cups-lpd || \
  234. { sed -i -e "s:}:\tdisable = yes\n}:" "${ED}"/etc/xinetd.d/cups-lpd || die ; }
  235. # write permission for file owner (root), bug #296221
  236. fperms u+w /etc/xinetd.d/cups-lpd || die "fperms failed"
  237. else
  238. # always configure with --with-xinetd= and clean up later,
  239. # bug #525604
  240. rm -rf "${ED}"/etc/xinetd.d
  241. fi
  242. keepdir /usr/libexec/cups/driver /usr/share/cups/{model,profiles} \
  243. /var/log/cups /var/spool/cups/tmp
  244. keepdir /etc/cups/{interfaces,ppd,ssl}
  245. use X || rm -r "${ED}"/usr/share/applications
  246. # create /etc/cups/client.conf, bug #196967 and #266678
  247. echo "ServerName ${EPREFIX}/run/cups/cups.sock" >> "${ED}"/etc/cups/client.conf
  248. # the following file is now provided by cups-filters:
  249. rm -r "${ED}"/usr/share/cups/banners || die
  250. # the following are created by the init script
  251. rm -r "${ED}"/var/cache/cups || die
  252. rm -r "${ED}"/run || die
  253. # for the special case of running lprng and cups together, bug 467226
  254. if use lprng-compat ; then
  255. rm -fv "${ED}"/usr/bin/{lp*,cancel}
  256. rm -fv "${ED}"/usr/sbin/lp*
  257. rm -fv "${ED}"/usr/share/man/man1/{lp*,cancel*}
  258. rm -fv "${ED}"/usr/share/man/man8/lp*
  259. ewarn "Not installing lp... binaries, since the lprng-compat useflag is set."
  260. ewarn "Unless you plan to install an exotic server setup, you most likely"
  261. ewarn "do not want this. Disable the useflag then and all will be fine."
  262. fi
  263. }
  264. pkg_preinst() {
  265. gnome2_icon_savelist
  266. }
  267. pkg_postinst() {
  268. # Update desktop file database and gtk icon cache (bug 370059)
  269. gnome2_icon_cache_update
  270. fdo-mime_desktop_database_update
  271. local v
  272. for v in ${REPLACING_VERSIONS}; do
  273. if ! version_is_at_least 2.2.2-r2 ${v}; then
  274. echo
  275. ewarn "The cupsd init script switched to using pidfiles. Shutting down"
  276. ewarn "cupsd will fail the next time. To fix this, please run once as root"
  277. ewarn " killall cupsd ; /etc/init.d/cupsd zap ; /etc/init.d/cupsd start"
  278. echo
  279. break
  280. fi
  281. done
  282. for v in ${REPLACING_VERSIONS}; do
  283. echo
  284. elog "For information about installing a printer and general cups setup"
  285. elog "take a look at: https://wiki.gentoo.org/wiki/Printing"
  286. echo
  287. break
  288. done
  289. }
  290. pkg_postrm() {
  291. # Update desktop file database and gtk icon cache (bug 370059)
  292. gnome2_icon_cache_update
  293. fdo-mime_desktop_database_update
  294. }