From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 8FF9D138334 for ; Thu, 5 Sep 2019 11:37:23 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EE9D6E07F6; Thu, 5 Sep 2019 11:37:18 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 35E6AE07A7 for ; Thu, 5 Sep 2019 11:37:17 +0000 (UTC) Received: from localhost.localdomain (c134-66.icpnet.pl [85.221.134.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id D701634AC18; Thu, 5 Sep 2019 11:37:15 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-dev@lists.gentoo.org Cc: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-dev] [PATCH v2] sgml-catalog-r1.eclass: New eclass to handle SGML catalogs Date: Thu, 5 Sep 2019 13:37:12 +0200 Message-Id: <20190905113712.4479-1-mgorny@gentoo.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190904123837.502335-1-mgorny@gentoo.org> References: <20190904123837.502335-1-mgorny@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: 66764cbc-cc75-482a-a611-26cec1e4669a X-Archives-Hash: 09162efe5d219685a288120001040901 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 --- 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 +# @AUTHOR: +# Michał Górny +# @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