gnome2.eclass 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. # Copyright 1999-2015 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. # @ECLASS: gnome2.eclass
  4. # @MAINTAINER:
  5. # gnome@gentoo.org
  6. # @BLURB: Provides phases for Gnome/Gtk+ based packages.
  7. # @DESCRIPTION:
  8. # Exports portage base functions used by ebuilds written for packages using the
  9. # GNOME framework. For additional functions, see gnome2-utils.eclass.
  10. # @ECLASS-VARIABLE: GNOME2_EAUTORECONF
  11. # @DEFAULT_UNSET
  12. # @DESCRIPTION:
  13. # Run eautoreconf instead of only elibtoolize
  14. GNOME2_EAUTORECONF=${GNOME2_EAUTORECONF:-""}
  15. [[ ${GNOME2_EAUTORECONF} == 'yes' ]] && inherit autotools
  16. inherit eutils libtool gnome.org gnome2-utils xdg
  17. case "${EAPI:-0}" in
  18. 4|5)
  19. EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_postrm
  20. ;;
  21. 6)
  22. EXPORT_FUNCTIONS src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_postrm
  23. ;;
  24. *) die "EAPI=${EAPI} is not supported" ;;
  25. esac
  26. # @ECLASS-VARIABLE: DOCS
  27. # @DEFAULT_UNSET
  28. # @DESCRIPTION:
  29. # String containing documents passed to dodoc command for eapi4.
  30. # In eapi5 we rely on einstalldocs (from eutils.eclass) and for newer EAPIs we
  31. # follow PMS spec.
  32. # @ECLASS-VARIABLE: ELTCONF
  33. # @DEFAULT_UNSET
  34. # @DESCRIPTION:
  35. # Extra options passed to elibtoolize
  36. ELTCONF=${ELTCONF:-""}
  37. # @ECLASS-VARIABLE: G2CONF
  38. # @DEFAULT_UNSET
  39. # @DESCRIPTION:
  40. # Extra configure opts passed to econf.
  41. # Deprecated, pass extra arguments to gnome2_src_configure.
  42. # Banned in eapi6 and newer.
  43. if has ${EAPI:-0} 4 5; then
  44. G2CONF=${G2CONF:-""}
  45. fi
  46. # @ECLASS-VARIABLE: GCONF_DEBUG
  47. # @DEFAULT_UNSET
  48. # @DESCRIPTION:
  49. # Whether to handle debug or not.
  50. # Some gnome applications support various levels of debugging (yes, no, minimum,
  51. # etc), but using --disable-debug also removes g_assert which makes debugging
  52. # harder. This variable should be set to yes for such packages for the eclass
  53. # to handle it properly. It will enable minimal debug with USE=-debug.
  54. # Note that this is most commonly found in configure.ac as GNOME_DEBUG_CHECK.
  55. #
  56. # Banned since eapi6 as upstream is moving away from this obsolete macro in favor
  57. # of autoconf-archive macros, that do not expose this issue (bug #270919)
  58. if has ${EAPI:-0} 4 5; then
  59. if [[ ${GCONF_DEBUG} != "no" ]]; then
  60. IUSE="debug"
  61. fi
  62. fi
  63. # @ECLASS-VARIABLE: GNOME2_ECLASS_GIO_MODULES
  64. # @INTERNAL
  65. # @DESCRIPTION:
  66. # Array containing glib GIO modules
  67. # @ECLASS-VARIABLE: GNOME2_LA_PUNT
  68. # @DESCRIPTION:
  69. # For eapi4 it sets if we should delete ALL or none of the .la files
  70. # For eapi5 and newer it relies on prune_libtool_files (from eutils.eclass)
  71. # for this. Available values for GNOME2_LA_PUNT:
  72. # - "no": will not clean any .la files
  73. # - "yes": will run prune_libtool_files --modules
  74. # - If it is not set, it will run prune_libtool_files
  75. if has ${EAPI:-0} 4; then
  76. GNOME2_LA_PUNT=${GNOME2_LA_PUNT:-"no"}
  77. else
  78. GNOME2_LA_PUNT=${GNOME2_LA_PUNT:-""}
  79. fi
  80. # @FUNCTION: gnome2_src_unpack
  81. # @DESCRIPTION:
  82. # Stub function for old EAPI.
  83. gnome2_src_unpack() {
  84. if has ${EAPI:-0} 4 5; then
  85. unpack ${A}
  86. cd "${S}"
  87. else
  88. die "gnome2_src_unpack is banned from eapi6"
  89. fi
  90. }
  91. # @FUNCTION: gnome2_src_prepare
  92. # @DESCRIPTION:
  93. # Prepare environment for build, fix build of scrollkeeper documentation,
  94. # run elibtoolize.
  95. gnome2_src_prepare() {
  96. xdg_src_prepare
  97. # Prevent assorted access violations and test failures
  98. gnome2_environment_reset
  99. # Prevent scrollkeeper access violations
  100. # We stop to run it from eapi6 as scrollkeeper helpers from
  101. # rarian are not running anything and, then, access violations
  102. # shouldn't occur.
  103. has ${EAPI:-0} 4 5 && gnome2_omf_fix
  104. # Disable all deprecation warnings
  105. gnome2_disable_deprecation_warning
  106. # Run libtoolize or eautoreconf, bug #591584
  107. # https://bugzilla.gnome.org/show_bug.cgi?id=655517
  108. if [[ ${GNOME2_EAUTORECONF} == 'yes' ]]; then
  109. eautoreconf
  110. else
  111. elibtoolize ${ELTCONF}
  112. fi
  113. }
  114. # @FUNCTION: gnome2_src_configure
  115. # @DESCRIPTION:
  116. # Gnome specific configure handling
  117. gnome2_src_configure() {
  118. # Deprecated for a long time now and banned since eapi6, see Gnome team policies
  119. if [[ -n ${G2CONF} ]] ; then
  120. if has ${EAPI:-0} 4 5; then
  121. eqawarn "G2CONF set, please review documentation at https://wiki.gentoo.org/wiki/Project:GNOME/Gnome_Team_Ebuild_Policies#G2CONF_and_src_configure"
  122. else
  123. die "G2CONF set, please review documentation at https://wiki.gentoo.org/wiki/Project:GNOME/Gnome_Team_Ebuild_Policies#G2CONF_and_src_configure"
  124. fi
  125. fi
  126. local g2conf=()
  127. if has ${EAPI:-0} 4 5; then
  128. if [[ ${GCONF_DEBUG} != 'no' ]] ; then
  129. if use debug ; then
  130. g2conf+=( --enable-debug=yes )
  131. fi
  132. fi
  133. else
  134. if [[ -n ${GCONF_DEBUG} ]] ; then
  135. die "GCONF_DEBUG is banned since eapi6 in favor of each ebuild taking care of the proper handling of debug configure option"
  136. fi
  137. fi
  138. # Starting with EAPI=5, we consider packages installing gtk-doc to be
  139. # handled by adding DEPEND="dev-util/gtk-doc-am" which provides tools to
  140. # relink URLs in documentation to already installed documentation.
  141. # This decision also greatly helps with constantly broken doc generation.
  142. # Remember to drop 'doc' USE flag from your package if it was only used to
  143. # rebuild docs.
  144. # Preserve old behavior for older EAPI.
  145. if grep -q "enable-gtk-doc" "${ECONF_SOURCE:-.}"/configure ; then
  146. if has ${EAPI:-0} 4 && in_iuse doc ; then
  147. g2conf+=( $(use_enable doc gtk-doc) )
  148. else
  149. g2conf+=( --disable-gtk-doc )
  150. fi
  151. fi
  152. # Pass --disable-maintainer-mode when needed
  153. if grep -q "^[[:space:]]*AM_MAINTAINER_MODE(\[enable\])" \
  154. "${ECONF_SOURCE:-.}"/configure.*; then
  155. g2conf+=( --disable-maintainer-mode )
  156. fi
  157. # Pass --disable-scrollkeeper when possible
  158. if grep -q "disable-scrollkeeper" "${ECONF_SOURCE:-.}"/configure; then
  159. g2conf+=( --disable-scrollkeeper )
  160. fi
  161. # Pass --disable-silent-rules when possible (not needed since eapi5), bug #429308
  162. if has ${EAPI:-0} 4; then
  163. if grep -q "disable-silent-rules" "${ECONF_SOURCE:-.}"/configure; then
  164. g2conf+=( --disable-silent-rules )
  165. fi
  166. fi
  167. # Pass --disable-schemas-install when possible
  168. if grep -q "disable-schemas-install" "${ECONF_SOURCE:-.}"/configure; then
  169. g2conf+=( --disable-schemas-install )
  170. fi
  171. # Pass --disable-schemas-compile when possible
  172. if grep -q "disable-schemas-compile" "${ECONF_SOURCE:-.}"/configure; then
  173. g2conf+=( --disable-schemas-compile )
  174. fi
  175. # Pass --disable-update-mimedb when possible
  176. if grep -q "disable-update-mimedb" "${ECONF_SOURCE:-.}"/configure; then
  177. g2conf+=( --disable-update-mimedb )
  178. fi
  179. # Pass --enable-compile-warnings=minimum as we don't want -Werror* flags, bug #471336
  180. if grep -q "enable-compile-warnings" "${ECONF_SOURCE:-.}"/configure; then
  181. g2conf+=( --enable-compile-warnings=minimum )
  182. fi
  183. # Pass --docdir with proper directory, bug #482646 (not needed since eapi6)
  184. if has ${EAPI:-0} 4 5; then
  185. if grep -q "^ *--docdir=" "${ECONF_SOURCE:-.}"/configure; then
  186. g2conf+=( --docdir="${EPREFIX}"/usr/share/doc/${PF} )
  187. fi
  188. fi
  189. # Avoid sandbox violations caused by gnome-vfs (bug #128289 and #345659)
  190. if has ${EAPI:-0} 4 5; then
  191. addwrite "$(unset HOME; echo ~)/.gnome2"
  192. else
  193. addpredict "$(unset HOME; echo ~)/.gnome2"
  194. fi
  195. if has ${EAPI:-0} 4 5; then
  196. econf ${g2conf[@]} ${G2CONF} "$@"
  197. else
  198. econf ${g2conf[@]} "$@"
  199. fi
  200. }
  201. # @FUNCTION: gnome2_src_compile
  202. # @DESCRIPTION:
  203. # Only default src_compile for now
  204. gnome2_src_compile() {
  205. if has ${EAPI:-0} 4 5; then
  206. emake
  207. else
  208. default
  209. fi
  210. }
  211. # @FUNCTION: gnome2_src_install
  212. # @DESCRIPTION:
  213. # Gnome specific install. Handles typical GConf and scrollkeeper setup
  214. # in packages and removal of .la files if requested
  215. gnome2_src_install() {
  216. # we must delay gconf schema installation due to sandbox
  217. export GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL="1"
  218. local sk_tmp_dir="/var/lib/scrollkeeper"
  219. # scrollkeeper-update from rarian doesn't do anything. Then, since eapi6
  220. # we stop taking care of it
  221. #
  222. # if this is not present, scrollkeeper-update may segfault and
  223. # create bogus directories in /var/lib/
  224. if has ${EAPI:-0} 4 5; then
  225. dodir "${sk_tmp_dir}" || die "dodir failed"
  226. emake DESTDIR="${D}" "scrollkeeper_localstate_dir=${ED}${sk_tmp_dir} " "$@" install || die "install failed"
  227. else
  228. default
  229. fi
  230. unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
  231. # Handle documentation as 'default' for eapi5, bug #373131
  232. # Since eapi6 this is handled by default on its own plus MAINTAINERS and HACKING
  233. # files that are really common in gnome packages (bug #573390)
  234. if has ${EAPI:-0} 4; then
  235. # Manual document installation
  236. if [[ -n "${DOCS}" ]]; then
  237. dodoc ${DOCS} || die "dodoc failed"
  238. fi
  239. elif has ${EAPI:-0} 5; then
  240. einstalldocs
  241. else
  242. local d
  243. for d in HACKING MAINTAINERS; do
  244. [[ -s "${d}" ]] && dodoc "${d}"
  245. done
  246. fi
  247. # Do not keep /var/lib/scrollkeeper because:
  248. # 1. The scrollkeeper database is regenerated at pkg_postinst()
  249. # 2. ${ED}/var/lib/scrollkeeper contains only indexes for the current pkg
  250. # thus it makes no sense if pkg_postinst ISN'T run for some reason.
  251. rm -rf "${ED}${sk_tmp_dir}"
  252. rmdir "${ED}/var/lib" 2>/dev/null
  253. rmdir "${ED}/var" 2>/dev/null
  254. # Make sure this one doesn't get in the portage db
  255. rm -fr "${ED}/usr/share/applications/mimeinfo.cache"
  256. # Delete all .la files
  257. if has ${EAPI:-0} 4; then
  258. if [[ "${GNOME2_LA_PUNT}" != "no" ]]; then
  259. ebegin "Removing .la files"
  260. if ! use_if_iuse static-libs ; then
  261. find "${D}" -name '*.la' -exec rm -f {} + || die "la file removal failed"
  262. fi
  263. eend
  264. fi
  265. else
  266. case "${GNOME2_LA_PUNT}" in
  267. yes) prune_libtool_files --modules;;
  268. no) ;;
  269. *) prune_libtool_files;;
  270. esac
  271. fi
  272. }
  273. # @FUNCTION: gnome2_pkg_preinst
  274. # @DESCRIPTION:
  275. # Finds Icons, GConf and GSettings schemas for later handling in pkg_postinst
  276. gnome2_pkg_preinst() {
  277. xdg_pkg_preinst
  278. gnome2_gconf_savelist
  279. gnome2_icon_savelist
  280. gnome2_schemas_savelist
  281. gnome2_scrollkeeper_savelist
  282. gnome2_gdk_pixbuf_savelist
  283. local f
  284. GNOME2_ECLASS_GIO_MODULES=()
  285. while IFS= read -r -d '' f; do
  286. GNOME2_ECLASS_GIO_MODULES+=( ${f} )
  287. done < <(cd "${D}" && find usr/$(get_libdir)/gio/modules -type f -print0 2>/dev/null)
  288. export GNOME2_ECLASS_GIO_MODULES
  289. }
  290. # @FUNCTION: gnome2_pkg_postinst
  291. # @DESCRIPTION:
  292. # Handle scrollkeeper, GConf, GSettings, Icons, desktop and mime
  293. # database updates.
  294. gnome2_pkg_postinst() {
  295. xdg_pkg_postinst
  296. gnome2_gconf_install
  297. gnome2_icon_cache_update
  298. gnome2_schemas_update
  299. gnome2_scrollkeeper_update
  300. gnome2_gdk_pixbuf_update
  301. if [[ ${#GNOME2_ECLASS_GIO_MODULES[@]} -gt 0 ]]; then
  302. gnome2_giomodule_cache_update
  303. fi
  304. }
  305. # # FIXME Handle GConf schemas removal
  306. #gnome2_pkg_prerm() {
  307. # gnome2_gconf_uninstall
  308. #}
  309. # @FUNCTION: gnome2_pkg_postrm
  310. # @DESCRIPTION:
  311. # Handle scrollkeeper, GSettings, Icons, desktop and mime database updates.
  312. gnome2_pkg_postrm() {
  313. xdg_pkg_postrm
  314. gnome2_icon_cache_update
  315. gnome2_schemas_update
  316. gnome2_scrollkeeper_update
  317. if [[ ${#GNOME2_ECLASS_GIO_MODULES[@]} -gt 0 ]]; then
  318. gnome2_giomodule_cache_update
  319. fi
  320. }