Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH] sgml-catalog-r1.eclass: New eclass to handle SGML catalogs
Date: Wed, 04 Sep 2019 16:55:10
Message-Id: bd277f39f411b4fc91f937199663771b5df33ebb.camel@gentoo.org
In Reply to: Re: [gentoo-dev] [PATCH] sgml-catalog-r1.eclass: New eclass to handle SGML catalogs by Ulrich Mueller
1 On Wed, 2019-09-04 at 17:20 +0200, Ulrich Mueller wrote:
2 > > > > > > On Wed, 04 Sep 2019, Michał Górny wrote:
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 Exactly. I was wondering if it would be good style to just skip
89 documenting this.
90
91 >
92 > > +sgml-catalog-r1_pkg_postinst() {
93 > > + sgml-catalog-r1_update_catalog
94 > > + sgml-catalog-r1_update_env
95 > > +}
96 > > +
97 > > +# @FUNCTION: sgml-catalog-r1_pkg_postrm
98 > > +# @DESCRIPTION:
99 > > +# Perform catalog post removal tasks.
100 > > +sgml-catalog-r1_pkg_postrm() {
101 > > + sgml-catalog-r1_update_catalog
102 > > + sgml-catalog-r1_update_env
103 > > +}
104 > > +
105 > > +_SGML_CATALOG_R1=1
106 > > +fi
107
108 --
109 Best regards,
110 Michał Górny

Attachments

File name MIME type
signature.asc application/pgp-signature