sgml-catalog.eclass 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. # Copyright 1999-2012 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. # @ECLASS: sgml-catalog.eclass
  4. # @MAINTAINER:
  5. # SGML Herd <sgml@gentoo.org>
  6. # @AUTHOR:
  7. # Author Matthew Turk <satai@gentoo.org>
  8. # @BLURB: Functions for installing SGML catalogs
  9. inherit base
  10. DEPEND=">=app-text/sgml-common-0.6.3-r2"
  11. # @ECLASS-VARIABLE: SGML_TOINSTALL
  12. # @DESCRIPTION:
  13. # An array of catalogs, arranged in pairs.
  14. # Each pair consists of a centralized catalog followed by an ordinary catalog.
  15. SGML_TOINSTALL=()
  16. # @FUNCTION: sgml-catalog_cat_include
  17. # @USAGE: <centralized catalog> <ordinary catalog>
  18. # @DESCRIPTION:
  19. # Appends a catalog pair to the SGML_TOINSTALL array.
  20. sgml-catalog_cat_include() {
  21. debug-print function $FUNCNAME $*
  22. SGML_TOINSTALL+=("$1" "$2")
  23. }
  24. # @FUNCTION: sgml-catalog_cat_doinstall
  25. # @USAGE: <centralized catalog> <ordinary catalog>
  26. # @DESCRIPTION:
  27. # Adds an ordinary catalog to a centralized catalog.
  28. sgml-catalog_cat_doinstall() {
  29. debug-print function $FUNCNAME $*
  30. has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
  31. "${EPREFIX}"/usr/bin/install-catalog --add "${EPREFIX}$1" "${EPREFIX}$2" &>/dev/null
  32. }
  33. # @FUNCTION: sgml-catalog_cat_doremove
  34. # @USAGE: <centralized catalog> <ordinary catalog>
  35. # @DESCRIPTION:
  36. # Removes an ordinary catalog from a centralized catalog.
  37. sgml-catalog_cat_doremove() {
  38. debug-print function $FUNCNAME $*
  39. has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
  40. "${EPREFIX}"/usr/bin/install-catalog --remove "${EPREFIX}$1" "${EPREFIX}$2" &>/dev/null
  41. }
  42. sgml-catalog_pkg_postinst() {
  43. debug-print function $FUNCNAME $*
  44. has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
  45. set -- "${SGML_TOINSTALL[@]}"
  46. while (( $# )); do
  47. if [[ ! -e "${EPREFIX}$2" ]]; then
  48. ewarn "${EPREFIX}$2 doesn't appear to exist, although it ought to!"
  49. shift 2
  50. continue
  51. fi
  52. einfo "Now adding ${EPREFIX}$2 to ${EPREFIX}$1 and ${EPREFIX}/etc/sgml/catalog"
  53. sgml-catalog_cat_doinstall "$1" "$2"
  54. shift 2
  55. done
  56. sgml-catalog_cleanup
  57. }
  58. sgml-catalog_pkg_prerm() {
  59. sgml-catalog_cleanup
  60. }
  61. sgml-catalog_pkg_postrm() {
  62. debug-print function $FUNCNAME $*
  63. has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
  64. set -- "${SGML_TOINSTALL[@]}"
  65. while (( $# )); do
  66. einfo "Now removing ${EPREFIX}$2 from ${EPREFIX}$1 and ${EPREFIX}/etc/sgml/catalog"
  67. sgml-catalog_cat_doremove "$1" "$2"
  68. shift 2
  69. done
  70. }
  71. sgml-catalog_cleanup() {
  72. has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
  73. if [ -e "${EPREFIX}/usr/bin/gensgmlenv" ]
  74. then
  75. einfo Regenerating SGML environment variables ...
  76. gensgmlenv
  77. grep -v export "${EPREFIX}/etc/sgml/sgml.env" > "${EPREFIX}/etc/env.d/93sgmltools-lite"
  78. fi
  79. }
  80. sgml-catalog_src_compile() {
  81. return
  82. }
  83. EXPORT_FUNCTIONS pkg_postrm pkg_postinst src_compile pkg_prerm