hplip-3.16.3.ebuild 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. PYTHON_COMPAT=( python2_7 )
  5. PYTHON_REQ_USE="threads,xml"
  6. inherit eutils fdo-mime linux-info python-single-r1 udev autotools toolchain-funcs
  7. DESCRIPTION="HP Linux Imaging and Printing - Print, scan, fax drivers and service tools"
  8. HOMEPAGE="http://hplipopensource.com/hplip-web/index.html"
  9. SRC_URI="mirror://sourceforge/hplip/${P}.tar.gz
  10. https://dev.gentoo.org/~billie/distfiles/${PN}-3.16.2-patches-1.tar.xz"
  11. LICENSE="GPL-2"
  12. SLOT="0"
  13. KEYWORDS="amd64 arm ppc ppc64 x86"
  14. IUSE="doc fax +hpcups hpijs kde libnotify -libusb0 minimal parport policykit qt4 scanner snmp static-ppds X"
  15. COMMON_DEPEND="
  16. virtual/jpeg:0
  17. hpijs? ( >=net-print/cups-filters-1.0.43-r1[foomatic] )
  18. !minimal? (
  19. ${PYTHON_DEPS}
  20. >=net-print/cups-1.4.0
  21. !libusb0? ( virtual/libusb:1 )
  22. libusb0? ( virtual/libusb:0 )
  23. scanner? ( >=media-gfx/sane-backends-1.0.19-r1 )
  24. fax? ( >=sys-apps/dbus-1.6.8-r1 )
  25. snmp? (
  26. net-analyzer/net-snmp
  27. dev-libs/openssl:0
  28. )
  29. )"
  30. DEPEND="${COMMON_DEPEND}
  31. virtual/pkgconfig"
  32. RDEPEND="${COMMON_DEPEND}
  33. >=app-text/ghostscript-gpl-8.71-r3
  34. policykit? (
  35. sys-auth/polkit
  36. )
  37. !minimal? (
  38. >=dev-python/dbus-python-1.1.1-r1[${PYTHON_USEDEP}]
  39. >=dev-python/pygobject-2.28.6-r53:2[${PYTHON_USEDEP}]
  40. kernel_linux? ( virtual/udev )
  41. scanner? (
  42. >=dev-python/reportlab-2.6[${PYTHON_USEDEP}]
  43. >=dev-python/pillow-1[${PYTHON_USEDEP}]
  44. X? ( || (
  45. kde? ( kde-misc/skanlite )
  46. media-gfx/xsane
  47. media-gfx/sane-frontends
  48. ) )
  49. )
  50. fax? (
  51. >=dev-python/reportlab-2.6[${PYTHON_USEDEP}]
  52. )
  53. qt4? (
  54. >=dev-python/PyQt4-4.9.6-r2[dbus,X,${PYTHON_USEDEP}]
  55. libnotify? (
  56. >=dev-python/notify-python-0.1.1-r3[${PYTHON_USEDEP}]
  57. )
  58. )
  59. )"
  60. REQUIRED_USE="!minimal? ( ${PYTHON_REQUIRED_USE} )"
  61. CONFIG_CHECK="~PARPORT ~PPDEV"
  62. ERROR_PARPORT="Please make sure kernel parallel port support is enabled (PARPORT and PPDEV)."
  63. pkg_setup() {
  64. use !minimal && python-single-r1_pkg_setup
  65. ! use qt4 && ewarn "You need USE=qt4 for the hplip GUI."
  66. use scanner && ! use X && ewarn "You need USE=X for the scanner GUI."
  67. if ! use hpcups && ! use hpijs ; then
  68. ewarn "Installing neither hpcups (USE=-hpcups) nor hpijs (USE=-hpijs) driver,"
  69. ewarn "which is probably not what you want."
  70. ewarn "You will almost certainly not be able to print."
  71. fi
  72. if use minimal ; then
  73. ewarn "Installing driver portions only, make sure you know what you are doing."
  74. ewarn "Depending on the USE flags set for hpcups or hpijs the appropiate driver"
  75. ewarn "is installed. If both USE flags are set hpijs overrides hpcups."
  76. else
  77. use parport && linux-info_pkg_setup
  78. fi
  79. }
  80. src_prepare() {
  81. if use !minimal ; then
  82. python_export EPYTHON PYTHON
  83. python_fix_shebang .
  84. fi
  85. EPATCH_SUFFIX="patch" \
  86. EPATCH_FORCE="yes" \
  87. epatch "${WORKDIR}"
  88. # Make desktop files follow the specification
  89. # Gentoo bug: https://bugs.gentoo.org/show_bug.cgi?id=443680
  90. # Upstream bug: https://bugs.launchpad.net/hplip/+bug/1080324
  91. sed -i -e '/^Categories=/s/Application;//' \
  92. -e '/^Encoding=.*/d' hplip.desktop.in || die
  93. sed -i -e '/^Categories=/s/Application;//' \
  94. -e '/^Version=.*/d' \
  95. -e '/^Comment=.*/d' hplip-systray.desktop.in || die
  96. # Fix for Gentoo bug https://bugs.gentoo.org/show_bug.cgi?id=345725
  97. # Upstream bug: https://bugs.launchpad.net/hplip/+bug/880847,
  98. # https://bugs.launchpad.net/hplip/+bug/500086
  99. local udevdir=$(get_udevdir)
  100. sed -i -e "s|/etc/udev|${udevdir}|g" \
  101. $(find . -type f -exec grep -l /etc/udev {} +) || die
  102. # Force recognition of Gentoo distro by hp-check
  103. sed -i \
  104. -e "s:file('/etc/issue', 'r').read():'Gentoo':" \
  105. installer/core_install.py || die
  106. # Use system foomatic-rip for hpijs driver instead of foomatic-rip-hplip
  107. # The hpcups driver does not use foomatic-rip
  108. local i
  109. for i in ppd/hpijs/*.ppd.gz ; do
  110. rm -f ${i}.temp || die
  111. gunzip -c ${i} | sed 's/foomatic-rip-hplip/foomatic-rip/g' | \
  112. gzip > ${i}.temp || die
  113. mv ${i}.temp ${i} || die
  114. done
  115. eautoreconf
  116. }
  117. src_configure() {
  118. local myconf drv_build minimal_build
  119. if use fax || use qt4 ; then
  120. myconf="${myconf} --enable-dbus-build"
  121. else
  122. myconf="${myconf} --disable-dbus-build"
  123. fi
  124. if use libusb0 ; then
  125. myconf="${myconf} --enable-libusb01_build"
  126. else
  127. myconf="${myconf} --disable-libusb01_build"
  128. fi
  129. if use hpcups ; then
  130. drv_build="$(use_enable hpcups hpcups-install)"
  131. if use static-ppds ; then
  132. drv_build="${drv_build} --enable-cups-ppd-install"
  133. drv_build="${drv_build} --disable-cups-drv-install"
  134. else
  135. drv_build="${drv_build} --enable-cups-drv-install"
  136. drv_build="${drv_build} --disable-cups-ppd-install"
  137. fi
  138. else
  139. drv_build="--disable-hpcups-install"
  140. drv_build="${drv_build} --disable-cups-drv-install"
  141. drv_build="${drv_build} --disable-cups-ppd-install"
  142. fi
  143. if use hpijs ; then
  144. drv_build="${drv_build} $(use_enable hpijs hpijs-install)"
  145. if use static-ppds ; then
  146. drv_build="${drv_build} --enable-foomatic-ppd-install"
  147. drv_build="${drv_build} --disable-foomatic-drv-install"
  148. else
  149. drv_build="${drv_build} --enable-foomatic-drv-install"
  150. drv_build="${drv_build} --disable-foomatic-ppd-install"
  151. fi
  152. else
  153. drv_build="${drv_build} --disable-hpijs-install"
  154. drv_build="${drv_build} --disable-foomatic-drv-install"
  155. drv_build="${drv_build} --disable-foomatic-ppd-install"
  156. fi
  157. if use minimal ; then
  158. if use hpijs ; then
  159. minimal_build="--enable-hpijs-only-build"
  160. else
  161. minimal_build="--disable-hpijs-only-build"
  162. fi
  163. if use hpcups ; then
  164. minimal_build="${minimal_build} --enable-hpcups-only-build"
  165. else
  166. minimal_build="${minimal_build} --disable-hpcups-only-build"
  167. fi
  168. fi
  169. econf \
  170. --disable-cups11-build \
  171. --disable-lite-build \
  172. --disable-foomatic-rip-hplip-install \
  173. --disable-shadow-build \
  174. --disable-qt3 \
  175. --disable-udev_sysfs_rules \
  176. --with-cupsbackenddir=$(cups-config --serverbin)/backend \
  177. --with-cupsfilterdir=$(cups-config --serverbin)/filter \
  178. --with-docdir=/usr/share/doc/${PF} \
  179. --with-htmldir=/usr/share/doc/${PF}/html \
  180. ${myconf} \
  181. ${drv_build} \
  182. ${minimal_build} \
  183. $(use_enable doc doc-build) \
  184. $(use_enable fax fax-build) \
  185. $(use_enable parport pp-build) \
  186. $(use_enable scanner scan-build) \
  187. $(use_enable snmp network-build) \
  188. $(use_enable qt4 gui-build) \
  189. $(use_enable qt4) \
  190. $(use_enable policykit)
  191. }
  192. src_install() {
  193. default
  194. # Installed by sane-backends
  195. # Gentoo Bug: https://bugs.gentoo.org/show_bug.cgi?id=201023
  196. rm -f "${D}"/etc/sane.d/dll.conf || die
  197. rm -f "${D}"/usr/share/doc/${PF}/{copyright,README_LIBJPG,COPYING} || die
  198. rmdir --ignore-fail-on-non-empty "${D}"/usr/share/doc/${PF}/ || die
  199. # Remove hal fdi files
  200. rm -rf "${D}"/usr/share/hal || die
  201. prune_libtool_files --all
  202. if use !minimal ; then
  203. python_export EPYTHON PYTHON
  204. python_optimize "${D}"/usr/share/hplip
  205. fi
  206. }
  207. pkg_postinst() {
  208. if [[ -z "${REPLACING_VERSIONS}" ]]; then
  209. elog "For more information on setting up your printer please take"
  210. elog "a look at the hplip section of the gentoo printing guide:"
  211. elog "https://wiki.gentoo.org/wiki/Printing"
  212. elog
  213. elog "Any user who wants to print must be in the lp group."
  214. elog
  215. elog "Please note: Printers requiring a binary plugin are currently"
  216. elog "not supported. All bugs regarding the plugin are most likely"
  217. elog "closed. A bug about including the plugin package to gentoo is"
  218. elog "available here: https://bugs.gentoo.org/352439"
  219. fi
  220. }