1 |
>>>>> On Wed, 04 Sep 2019, Michał Górny wrote: |
2 |
|
3 |
> +# Copyright 2019 Gentoo Authors |
4 |
> +# Distributed under the terms of the GNU General Public License v2 |
5 |
> + |
6 |
> +# @ECLASS: sgml-catalog-r1.eclass |
7 |
> +# @MAINTAINER: |
8 |
> +# Michał Górny <mgorny@g.o> |
9 |
> +# @AUTHOR: |
10 |
> +# Michał Górny <mgorny@g.o> |
11 |
> +# @BLURB: Functions for installing SGML catalogs |
12 |
> +# @DESCRIPTION: |
13 |
> +# sgml-catalog-r1 provides postinst/postrm for regenerating |
14 |
> +# /etc/sgml/catalog to include all installed catalogs. |
15 |
|
16 |
catalog...catalog...catalog... |
17 |
|
18 |
Certainly the style could be improved? How about: "This eclass |
19 |
regenerates /etc/sgml/catalog in pkg_postinst and pkg_postrm."? |
20 |
|
21 |
> + |
22 |
> +case "${EAPI:-0}" in |
23 |
|
24 |
Quotes aren't necessary here. |
25 |
|
26 |
> + 7) |
27 |
> + ;; |
28 |
> + *) |
29 |
> + die "Unsupported EAPI=${EAPI} for ${ECLASS}" |
30 |
> + ;; |
31 |
> +esac |
32 |
|
33 |
This case statement could be more compact (which would be better |
34 |
readable, IMHO). |
35 |
|
36 |
> + |
37 |
> +EXPORT_FUNCTIONS pkg_postinst pkg_postrm |
38 |
> + |
39 |
> +if [[ ! ${_SGML_CATALOG_R1} ]]; then |
40 |
> + |
41 |
> +RDEPEND=">=app-text/sgml-common-0.6.3-r7" |
42 |
> + |
43 |
> +# @FUNCTION: sgml-catalog-r1_update_catalog |
44 |
> +# @DESCRIPTION: |
45 |
> +# Regenerate /etc/sgml/catalog to include all installed catalogs. |
46 |
> +sgml-catalog-r1_update_catalog() { |
47 |
> + local shopt_save=$(shopt -p nullglob) |
48 |
> + shopt -s nullglob |
49 |
> + local cats=( "${EROOT}"/etc/sgml/*.cat ) |
50 |
> + ${shopt_save} |
51 |
> + |
52 |
> + if [[ ${#cats[@]} -gt 0 ]]; then |
53 |
> + ebegin "Updating ${EROOT}/etc/sgml/catalog" |
54 |
> + printf 'CATALOG "%s"\n' "${cats[@]}" > "${T}"/catalog && |
55 |
> + mv "${T}"/catalog "${EROOT}"/etc/sgml/catalog |
56 |
> + else |
57 |
> + ebegin "Removing ${EROOT}/etc/sgml/catalog" |
58 |
> + rm "${EROOT}"/etc/sgml/catalog && |
59 |
> + { rmdir "${EROOT}"/etc/sgml &>/dev/null || :; } |
60 |
> + fi |
61 |
> + eend "${?}" |
62 |
|
63 |
Using one eend for each ebegin would improve readability. Also, quotes |
64 |
around $? aren't necessary. |
65 |
|
66 |
> +} |
67 |
> + |
68 |
> +# @FUNCTION: sgml-catalog-r1_update_env |
69 |
> +# @DESCRIPTION: |
70 |
> +# Regenerate environment variables and copy them to env.d. |
71 |
> +sgml-catalog-r1_update_env() { |
72 |
> + # gensgmlenv doesn't support overriding root |
73 |
> + if [[ -z ${ROOT} && -x "${EPREFIX}/usr/bin/gensgmlenv" ]]; then |
74 |
> + ebegin "Regenerating SGML environment variables" |
75 |
> + gensgmlenv && |
76 |
> + grep -v export "${EPREFIX}/etc/sgml/sgml.env" > "${T}"/93sgmltools-lite && |
77 |
> + mv "${T}"/93sgmltools-lite "${EPREFIX}/etc/env.d/93sgmltools-lite" |
78 |
> + eend "${?}" |
79 |
> + fi |
80 |
> +} |
81 |
> + |
82 |
> +# @FUNCTION: sgml-catalog-r1_pkg_postinst |
83 |
> +# @DESCRIPTION: |
84 |
> +# Perform catalog post installation tasks. |
85 |
|
86 |
Sure, what else would postinst do? :) |
87 |
|
88 |
> +sgml-catalog-r1_pkg_postinst() { |
89 |
> + sgml-catalog-r1_update_catalog |
90 |
> + sgml-catalog-r1_update_env |
91 |
> +} |
92 |
> + |
93 |
> +# @FUNCTION: sgml-catalog-r1_pkg_postrm |
94 |
> +# @DESCRIPTION: |
95 |
> +# Perform catalog post removal tasks. |
96 |
> +sgml-catalog-r1_pkg_postrm() { |
97 |
> + sgml-catalog-r1_update_catalog |
98 |
> + sgml-catalog-r1_update_env |
99 |
> +} |
100 |
> + |
101 |
> +_SGML_CATALOG_R1=1 |
102 |
> +fi |