Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Wed, 11 Sep 2019 17:58:11
Message-Id: 1568224634.2f6f27593eb7d580b2383ef25cef7d1cfea10085.mgorny@gentoo
1 commit: 2f6f27593eb7d580b2383ef25cef7d1cfea10085
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Tue Sep 3 18:20:04 2019 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Wed Sep 11 17:57:14 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2f6f2759
7
8 sgml-catalog-r1.eclass: New eclass to handle SGML catalogs
9
10 Create a new, simpler eclass to handle SGML catalog installation.
11 Rather than relying on external tool to add/remove catalogs
12 in postinst/postrm, let ebuilds install interim catalogs and just
13 register all installed catalogs.
14
15 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
16
17 eclass/sgml-catalog-r1.eclass | 73 +++++++++++++++++++++++++++++++++++++++++++
18 1 file changed, 73 insertions(+)
19
20 diff --git a/eclass/sgml-catalog-r1.eclass b/eclass/sgml-catalog-r1.eclass
21 new file mode 100644
22 index 00000000000..6dc870af629
23 --- /dev/null
24 +++ b/eclass/sgml-catalog-r1.eclass
25 @@ -0,0 +1,73 @@
26 +# Copyright 2019 Gentoo Authors
27 +# Distributed under the terms of the GNU General Public License v2
28 +
29 +# @ECLASS: sgml-catalog-r1.eclass
30 +# @MAINTAINER:
31 +# Michał Górny <mgorny@g.o>
32 +# @AUTHOR:
33 +# Michał Górny <mgorny@g.o>
34 +# @BLURB: Functions for installing SGML catalogs
35 +# @DESCRIPTION:
36 +# This eclass regenerates /etc/sgml/catalog, /etc/sgml.{,c}env
37 +# and /etc/env.d/93sgmltools-lite as necessary for the DocBook tooling.
38 +# This is done via exported pkg_postinst and pkg_postrm phases.
39 +
40 +case ${EAPI:-0} in
41 + 7) ;;
42 + *) die "Unsupported EAPI=${EAPI} for ${ECLASS}";;
43 +esac
44 +
45 +EXPORT_FUNCTIONS pkg_postinst pkg_postrm
46 +
47 +if [[ ! ${_SGML_CATALOG_R1} ]]; then
48 +
49 +RDEPEND=">=app-text/sgml-common-0.6.3-r7"
50 +
51 +# @FUNCTION: sgml-catalog-r1_update_catalog
52 +# @DESCRIPTION:
53 +# Regenerate /etc/sgml/catalog to include all installed catalogs.
54 +sgml-catalog-r1_update_catalog() {
55 + local shopt_save=$(shopt -p nullglob)
56 + shopt -s nullglob
57 + local cats=( "${EROOT}"/etc/sgml/*.cat )
58 + ${shopt_save}
59 +
60 + if [[ ${#cats[@]} -gt 0 ]]; then
61 + ebegin "Updating ${EROOT}/etc/sgml/catalog"
62 + printf 'CATALOG "%s"\n' "${cats[@]}" > "${T}"/catalog &&
63 + mv "${T}"/catalog "${EROOT}"/etc/sgml/catalog
64 + eend "${?}"
65 + else
66 + ebegin "Removing ${EROOT}/etc/sgml/catalog"
67 + rm "${EROOT}"/etc/sgml/catalog &&
68 + { rmdir "${EROOT}"/etc/sgml &>/dev/null || :; }
69 + eend "${?}"
70 + fi
71 +}
72 +
73 +# @FUNCTION: sgml-catalog-r1_update_env
74 +# @DESCRIPTION:
75 +# Regenerate environment variables and copy them to env.d.
76 +sgml-catalog-r1_update_env() {
77 + # gensgmlenv doesn't support overriding root
78 + if [[ -z ${ROOT} && -x "${EPREFIX}/usr/bin/gensgmlenv" ]]; then
79 + ebegin "Regenerating SGML environment variables"
80 + gensgmlenv &&
81 + grep -v export "${EPREFIX}/etc/sgml/sgml.env" > "${T}"/93sgmltools-lite &&
82 + mv "${T}"/93sgmltools-lite "${EPREFIX}/etc/env.d/93sgmltools-lite"
83 + eend "${?}"
84 + fi
85 +}
86 +
87 +sgml-catalog-r1_pkg_postinst() {
88 + sgml-catalog-r1_update_catalog
89 + sgml-catalog-r1_update_env
90 +}
91 +
92 +sgml-catalog-r1_pkg_postrm() {
93 + sgml-catalog-r1_update_catalog
94 + sgml-catalog-r1_update_env
95 +}
96 +
97 +_SGML_CATALOG_R1=1
98 +fi