1 # Copyright 2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: sgml-catalog-r1.eclass
6 # Michał Górny <mgorny@gentoo.org>
8 # Michał Górny <mgorny@gentoo.org>
10 # @BLURB: Functions for installing SGML catalogs
12 # This eclass regenerates /etc/sgml/catalog, /etc/sgml.{,c}env
13 # and /etc/env.d/93sgmltools-lite as necessary for the DocBook tooling.
14 # This is done via exported pkg_postinst and pkg_postrm phases.
18 *) die "Unsupported EAPI=${EAPI} for ${ECLASS}";;
21 EXPORT_FUNCTIONS pkg_postinst pkg_postrm
23 if [[ ! ${_SGML_CATALOG_R1} ]]; then
25 if [[ ${CATEGORY}/${PN} != app-text/sgml-common ]]; then
26 RDEPEND=">=app-text/sgml-common-0.6.3-r7"
29 # @FUNCTION: sgml-catalog-r1_update_catalog
31 # Regenerate /etc/sgml/catalog to include all installed catalogs.
32 sgml-catalog-r1_update_catalog() {
33 local shopt_save=$(shopt -p nullglob)
35 local cats=( "${EROOT}"/etc/sgml/*.cat )
38 if [[ ${#cats[@]} -gt 0 ]]; then
39 ebegin "Updating ${EROOT}/etc/sgml/catalog"
40 printf 'CATALOG "%s"\n' "${cats[@]}" > "${T}"/catalog &&
41 mv "${T}"/catalog "${EROOT}"/etc/sgml/catalog
44 ebegin "Removing ${EROOT}/etc/sgml/catalog"
45 rm "${EROOT}"/etc/sgml/catalog &&
46 { rmdir "${EROOT}"/etc/sgml &>/dev/null || :; }
51 # @FUNCTION: sgml-catalog-r1_update_env
53 # Regenerate environment variables and copy them to env.d.
54 sgml-catalog-r1_update_env() {
55 # gensgmlenv doesn't support overriding root
56 if [[ -z ${ROOT} && -x "${EPREFIX}/usr/bin/gensgmlenv" ]]; then
57 ebegin "Regenerating SGML environment variables"
59 grep -v export "${EPREFIX}/etc/sgml/sgml.env" > "${T}"/93sgmltools-lite &&
60 mv "${T}"/93sgmltools-lite "${EPREFIX}/etc/env.d/93sgmltools-lite"
65 sgml-catalog-r1_pkg_postinst() {
66 sgml-catalog-r1_update_catalog
67 sgml-catalog-r1_update_env
70 sgml-catalog-r1_pkg_postrm() {
71 sgml-catalog-r1_update_catalog
72 sgml-catalog-r1_update_env