* [gentoo-dev] [PATCH] sgml-catalog-r1.eclass: New eclass to handle SGML catalogs
@ 2019-09-04 12:38 Michał Górny
2019-09-04 15:20 ` Ulrich Mueller
2019-09-05 11:37 ` [gentoo-dev] [PATCH v2] " Michał Górny
0 siblings, 2 replies; 4+ messages in thread
From: Michał Górny @ 2019-09-04 12:38 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
Create a new, simpler eclass to handle SGML catalog installation.
Rather than relying on external tool to add/remove catalogs
in postinst/postrm, let ebuilds install interim catalogs and just
register all installed catalogs.
Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
eclass/sgml-catalog-r1.eclass | 80 +++++++++++++++++++++++++++++++++++
1 file changed, 80 insertions(+)
create mode 100644 eclass/sgml-catalog-r1.eclass
Port of all sgml ebuilds to the new eclass:
https://github.com/gentoo/gentoo/pull/12858
diff --git a/eclass/sgml-catalog-r1.eclass b/eclass/sgml-catalog-r1.eclass
new file mode 100644
index 000000000000..a7105d570795
--- /dev/null
+++ b/eclass/sgml-catalog-r1.eclass
@@ -0,0 +1,80 @@
+# Copyright 2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: sgml-catalog-r1.eclass
+# @MAINTAINER:
+# Michał Górny <mgorny@gentoo.org>
+# @AUTHOR:
+# Michał Górny <mgorny@gentoo.org>
+# @BLURB: Functions for installing SGML catalogs
+# @DESCRIPTION:
+# sgml-catalog-r1 provides postinst/postrm for regenerating
+# /etc/sgml/catalog to include all installed catalogs.
+
+case "${EAPI:-0}" in
+ 7)
+ ;;
+ *)
+ die "Unsupported EAPI=${EAPI} for ${ECLASS}"
+ ;;
+esac
+
+EXPORT_FUNCTIONS pkg_postinst pkg_postrm
+
+if [[ ! ${_SGML_CATALOG_R1} ]]; then
+
+RDEPEND=">=app-text/sgml-common-0.6.3-r7"
+
+# @FUNCTION: sgml-catalog-r1_update_catalog
+# @DESCRIPTION:
+# Regenerate /etc/sgml/catalog to include all installed catalogs.
+sgml-catalog-r1_update_catalog() {
+ local shopt_save=$(shopt -p nullglob)
+ shopt -s nullglob
+ local cats=( "${EROOT}"/etc/sgml/*.cat )
+ ${shopt_save}
+
+ if [[ ${#cats[@]} -gt 0 ]]; then
+ ebegin "Updating ${EROOT}/etc/sgml/catalog"
+ printf 'CATALOG "%s"\n' "${cats[@]}" > "${T}"/catalog &&
+ mv "${T}"/catalog "${EROOT}"/etc/sgml/catalog
+ else
+ ebegin "Removing ${EROOT}/etc/sgml/catalog"
+ rm "${EROOT}"/etc/sgml/catalog &&
+ { rmdir "${EROOT}"/etc/sgml &>/dev/null || :; }
+ fi
+ eend "${?}"
+}
+
+# @FUNCTION: sgml-catalog-r1_update_env
+# @DESCRIPTION:
+# Regenerate environment variables and copy them to env.d.
+sgml-catalog-r1_update_env() {
+ # gensgmlenv doesn't support overriding root
+ if [[ -z ${ROOT} && -x "${EPREFIX}/usr/bin/gensgmlenv" ]]; then
+ ebegin "Regenerating SGML environment variables"
+ gensgmlenv &&
+ grep -v export "${EPREFIX}/etc/sgml/sgml.env" > "${T}"/93sgmltools-lite &&
+ mv "${T}"/93sgmltools-lite "${EPREFIX}/etc/env.d/93sgmltools-lite"
+ eend "${?}"
+ fi
+}
+
+# @FUNCTION: sgml-catalog-r1_pkg_postinst
+# @DESCRIPTION:
+# Perform catalog post installation tasks.
+sgml-catalog-r1_pkg_postinst() {
+ sgml-catalog-r1_update_catalog
+ sgml-catalog-r1_update_env
+}
+
+# @FUNCTION: sgml-catalog-r1_pkg_postrm
+# @DESCRIPTION:
+# Perform catalog post removal tasks.
+sgml-catalog-r1_pkg_postrm() {
+ sgml-catalog-r1_update_catalog
+ sgml-catalog-r1_update_env
+}
+
+_SGML_CATALOG_R1=1
+fi
--
2.23.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [gentoo-dev] [PATCH] sgml-catalog-r1.eclass: New eclass to handle SGML catalogs
2019-09-04 12:38 [gentoo-dev] [PATCH] sgml-catalog-r1.eclass: New eclass to handle SGML catalogs Michał Górny
@ 2019-09-04 15:20 ` Ulrich Mueller
2019-09-04 16:54 ` Michał Górny
2019-09-05 11:37 ` [gentoo-dev] [PATCH v2] " Michał Górny
1 sibling, 1 reply; 4+ messages in thread
From: Ulrich Mueller @ 2019-09-04 15:20 UTC (permalink / raw
To: Michał Górny; +Cc: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 2960 bytes --]
>>>>> On Wed, 04 Sep 2019, Michał Górny wrote:
> +# Copyright 2019 Gentoo Authors
> +# Distributed under the terms of the GNU General Public License v2
> +
> +# @ECLASS: sgml-catalog-r1.eclass
> +# @MAINTAINER:
> +# Michał Górny <mgorny@gentoo.org>
> +# @AUTHOR:
> +# Michał Górny <mgorny@gentoo.org>
> +# @BLURB: Functions for installing SGML catalogs
> +# @DESCRIPTION:
> +# sgml-catalog-r1 provides postinst/postrm for regenerating
> +# /etc/sgml/catalog to include all installed catalogs.
catalog...catalog...catalog...
Certainly the style could be improved? How about: "This eclass
regenerates /etc/sgml/catalog in pkg_postinst and pkg_postrm."?
> +
> +case "${EAPI:-0}" in
Quotes aren't necessary here.
> + 7)
> + ;;
> + *)
> + die "Unsupported EAPI=${EAPI} for ${ECLASS}"
> + ;;
> +esac
This case statement could be more compact (which would be better
readable, IMHO).
> +
> +EXPORT_FUNCTIONS pkg_postinst pkg_postrm
> +
> +if [[ ! ${_SGML_CATALOG_R1} ]]; then
> +
> +RDEPEND=">=app-text/sgml-common-0.6.3-r7"
> +
> +# @FUNCTION: sgml-catalog-r1_update_catalog
> +# @DESCRIPTION:
> +# Regenerate /etc/sgml/catalog to include all installed catalogs.
> +sgml-catalog-r1_update_catalog() {
> + local shopt_save=$(shopt -p nullglob)
> + shopt -s nullglob
> + local cats=( "${EROOT}"/etc/sgml/*.cat )
> + ${shopt_save}
> +
> + if [[ ${#cats[@]} -gt 0 ]]; then
> + ebegin "Updating ${EROOT}/etc/sgml/catalog"
> + printf 'CATALOG "%s"\n' "${cats[@]}" > "${T}"/catalog &&
> + mv "${T}"/catalog "${EROOT}"/etc/sgml/catalog
> + else
> + ebegin "Removing ${EROOT}/etc/sgml/catalog"
> + rm "${EROOT}"/etc/sgml/catalog &&
> + { rmdir "${EROOT}"/etc/sgml &>/dev/null || :; }
> + fi
> + eend "${?}"
Using one eend for each ebegin would improve readability. Also, quotes
around $? aren't necessary.
> +}
> +
> +# @FUNCTION: sgml-catalog-r1_update_env
> +# @DESCRIPTION:
> +# Regenerate environment variables and copy them to env.d.
> +sgml-catalog-r1_update_env() {
> + # gensgmlenv doesn't support overriding root
> + if [[ -z ${ROOT} && -x "${EPREFIX}/usr/bin/gensgmlenv" ]]; then
> + ebegin "Regenerating SGML environment variables"
> + gensgmlenv &&
> + grep -v export "${EPREFIX}/etc/sgml/sgml.env" > "${T}"/93sgmltools-lite &&
> + mv "${T}"/93sgmltools-lite "${EPREFIX}/etc/env.d/93sgmltools-lite"
> + eend "${?}"
> + fi
> +}
> +
> +# @FUNCTION: sgml-catalog-r1_pkg_postinst
> +# @DESCRIPTION:
> +# Perform catalog post installation tasks.
Sure, what else would postinst do? :)
> +sgml-catalog-r1_pkg_postinst() {
> + sgml-catalog-r1_update_catalog
> + sgml-catalog-r1_update_env
> +}
> +
> +# @FUNCTION: sgml-catalog-r1_pkg_postrm
> +# @DESCRIPTION:
> +# Perform catalog post removal tasks.
> +sgml-catalog-r1_pkg_postrm() {
> + sgml-catalog-r1_update_catalog
> + sgml-catalog-r1_update_env
> +}
> +
> +_SGML_CATALOG_R1=1
> +fi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-dev] [PATCH] sgml-catalog-r1.eclass: New eclass to handle SGML catalogs
2019-09-04 15:20 ` Ulrich Mueller
@ 2019-09-04 16:54 ` Michał Górny
0 siblings, 0 replies; 4+ messages in thread
From: Michał Górny @ 2019-09-04 16:54 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 3351 bytes --]
On Wed, 2019-09-04 at 17:20 +0200, Ulrich Mueller wrote:
> > > > > > On Wed, 04 Sep 2019, Michał Górny wrote:
> > +# Copyright 2019 Gentoo Authors
> > +# Distributed under the terms of the GNU General Public License v2
> > +
> > +# @ECLASS: sgml-catalog-r1.eclass
> > +# @MAINTAINER:
> > +# Michał Górny <mgorny@gentoo.org>
> > +# @AUTHOR:
> > +# Michał Górny <mgorny@gentoo.org>
> > +# @BLURB: Functions for installing SGML catalogs
> > +# @DESCRIPTION:
> > +# sgml-catalog-r1 provides postinst/postrm for regenerating
> > +# /etc/sgml/catalog to include all installed catalogs.
>
> catalog...catalog...catalog...
>
> Certainly the style could be improved? How about: "This eclass
> regenerates /etc/sgml/catalog in pkg_postinst and pkg_postrm."?
>
> > +
> > +case "${EAPI:-0}" in
>
> Quotes aren't necessary here.
>
> > + 7)
> > + ;;
> > + *)
> > + die "Unsupported EAPI=${EAPI} for ${ECLASS}"
> > + ;;
> > +esac
>
> This case statement could be more compact (which would be better
> readable, IMHO).
>
> > +
> > +EXPORT_FUNCTIONS pkg_postinst pkg_postrm
> > +
> > +if [[ ! ${_SGML_CATALOG_R1} ]]; then
> > +
> > +RDEPEND=">=app-text/sgml-common-0.6.3-r7"
> > +
> > +# @FUNCTION: sgml-catalog-r1_update_catalog
> > +# @DESCRIPTION:
> > +# Regenerate /etc/sgml/catalog to include all installed catalogs.
> > +sgml-catalog-r1_update_catalog() {
> > + local shopt_save=$(shopt -p nullglob)
> > + shopt -s nullglob
> > + local cats=( "${EROOT}"/etc/sgml/*.cat )
> > + ${shopt_save}
> > +
> > + if [[ ${#cats[@]} -gt 0 ]]; then
> > + ebegin "Updating ${EROOT}/etc/sgml/catalog"
> > + printf 'CATALOG "%s"\n' "${cats[@]}" > "${T}"/catalog &&
> > + mv "${T}"/catalog "${EROOT}"/etc/sgml/catalog
> > + else
> > + ebegin "Removing ${EROOT}/etc/sgml/catalog"
> > + rm "${EROOT}"/etc/sgml/catalog &&
> > + { rmdir "${EROOT}"/etc/sgml &>/dev/null || :; }
> > + fi
> > + eend "${?}"
>
> Using one eend for each ebegin would improve readability. Also, quotes
> around $? aren't necessary.
>
> > +}
> > +
> > +# @FUNCTION: sgml-catalog-r1_update_env
> > +# @DESCRIPTION:
> > +# Regenerate environment variables and copy them to env.d.
> > +sgml-catalog-r1_update_env() {
> > + # gensgmlenv doesn't support overriding root
> > + if [[ -z ${ROOT} && -x "${EPREFIX}/usr/bin/gensgmlenv" ]]; then
> > + ebegin "Regenerating SGML environment variables"
> > + gensgmlenv &&
> > + grep -v export "${EPREFIX}/etc/sgml/sgml.env" > "${T}"/93sgmltools-lite &&
> > + mv "${T}"/93sgmltools-lite "${EPREFIX}/etc/env.d/93sgmltools-lite"
> > + eend "${?}"
> > + fi
> > +}
> > +
> > +# @FUNCTION: sgml-catalog-r1_pkg_postinst
> > +# @DESCRIPTION:
> > +# Perform catalog post installation tasks.
>
> Sure, what else would postinst do? :)
Exactly. I was wondering if it would be good style to just skip
documenting this.
>
> > +sgml-catalog-r1_pkg_postinst() {
> > + sgml-catalog-r1_update_catalog
> > + sgml-catalog-r1_update_env
> > +}
> > +
> > +# @FUNCTION: sgml-catalog-r1_pkg_postrm
> > +# @DESCRIPTION:
> > +# Perform catalog post removal tasks.
> > +sgml-catalog-r1_pkg_postrm() {
> > + sgml-catalog-r1_update_catalog
> > + sgml-catalog-r1_update_env
> > +}
> > +
> > +_SGML_CATALOG_R1=1
> > +fi
--
Best regards,
Michał Górny
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 618 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* [gentoo-dev] [PATCH v2] sgml-catalog-r1.eclass: New eclass to handle SGML catalogs
2019-09-04 12:38 [gentoo-dev] [PATCH] sgml-catalog-r1.eclass: New eclass to handle SGML catalogs Michał Górny
2019-09-04 15:20 ` Ulrich Mueller
@ 2019-09-05 11:37 ` Michał Górny
1 sibling, 0 replies; 4+ messages in thread
From: Michał Górny @ 2019-09-05 11:37 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
Create a new, simpler eclass to handle SGML catalog installation.
Rather than relying on external tool to add/remove catalogs
in postinst/postrm, let ebuilds install interim catalogs and just
register all installed catalogs.
Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
eclass/sgml-catalog-r1.eclass | 73 +++++++++++++++++++++++++++++++++++
1 file changed, 73 insertions(+)
create mode 100644 eclass/sgml-catalog-r1.eclass
diff --git a/eclass/sgml-catalog-r1.eclass b/eclass/sgml-catalog-r1.eclass
new file mode 100644
index 000000000000..6dc870af629a
--- /dev/null
+++ b/eclass/sgml-catalog-r1.eclass
@@ -0,0 +1,73 @@
+# Copyright 2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: sgml-catalog-r1.eclass
+# @MAINTAINER:
+# Michał Górny <mgorny@gentoo.org>
+# @AUTHOR:
+# Michał Górny <mgorny@gentoo.org>
+# @BLURB: Functions for installing SGML catalogs
+# @DESCRIPTION:
+# This eclass regenerates /etc/sgml/catalog, /etc/sgml.{,c}env
+# and /etc/env.d/93sgmltools-lite as necessary for the DocBook tooling.
+# This is done via exported pkg_postinst and pkg_postrm phases.
+
+case ${EAPI:-0} in
+ 7) ;;
+ *) die "Unsupported EAPI=${EAPI} for ${ECLASS}";;
+esac
+
+EXPORT_FUNCTIONS pkg_postinst pkg_postrm
+
+if [[ ! ${_SGML_CATALOG_R1} ]]; then
+
+RDEPEND=">=app-text/sgml-common-0.6.3-r7"
+
+# @FUNCTION: sgml-catalog-r1_update_catalog
+# @DESCRIPTION:
+# Regenerate /etc/sgml/catalog to include all installed catalogs.
+sgml-catalog-r1_update_catalog() {
+ local shopt_save=$(shopt -p nullglob)
+ shopt -s nullglob
+ local cats=( "${EROOT}"/etc/sgml/*.cat )
+ ${shopt_save}
+
+ if [[ ${#cats[@]} -gt 0 ]]; then
+ ebegin "Updating ${EROOT}/etc/sgml/catalog"
+ printf 'CATALOG "%s"\n' "${cats[@]}" > "${T}"/catalog &&
+ mv "${T}"/catalog "${EROOT}"/etc/sgml/catalog
+ eend "${?}"
+ else
+ ebegin "Removing ${EROOT}/etc/sgml/catalog"
+ rm "${EROOT}"/etc/sgml/catalog &&
+ { rmdir "${EROOT}"/etc/sgml &>/dev/null || :; }
+ eend "${?}"
+ fi
+}
+
+# @FUNCTION: sgml-catalog-r1_update_env
+# @DESCRIPTION:
+# Regenerate environment variables and copy them to env.d.
+sgml-catalog-r1_update_env() {
+ # gensgmlenv doesn't support overriding root
+ if [[ -z ${ROOT} && -x "${EPREFIX}/usr/bin/gensgmlenv" ]]; then
+ ebegin "Regenerating SGML environment variables"
+ gensgmlenv &&
+ grep -v export "${EPREFIX}/etc/sgml/sgml.env" > "${T}"/93sgmltools-lite &&
+ mv "${T}"/93sgmltools-lite "${EPREFIX}/etc/env.d/93sgmltools-lite"
+ eend "${?}"
+ fi
+}
+
+sgml-catalog-r1_pkg_postinst() {
+ sgml-catalog-r1_update_catalog
+ sgml-catalog-r1_update_env
+}
+
+sgml-catalog-r1_pkg_postrm() {
+ sgml-catalog-r1_update_catalog
+ sgml-catalog-r1_update_env
+}
+
+_SGML_CATALOG_R1=1
+fi
--
2.23.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-09-05 11:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-04 12:38 [gentoo-dev] [PATCH] sgml-catalog-r1.eclass: New eclass to handle SGML catalogs Michał Górny
2019-09-04 15:20 ` Ulrich Mueller
2019-09-04 16:54 ` Michał Górny
2019-09-05 11:37 ` [gentoo-dev] [PATCH v2] " Michał Górny
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox