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