public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 1/2] texlive-module.eclass: only invoke etexmf-update in postinst if not replacing versions
@ 2024-04-02 14:07 Florian Schmaus
  2024-04-02 14:07 ` [gentoo-dev] [PATCH 2/2] texlive-module.eclass: add texlive-module_update_tlpdb Florian Schmaus
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Schmaus @ 2024-04-02 14:07 UTC (permalink / raw)
  To: gentoo-dev; +Cc: Paul Zander, tex, Florian Schmaus

Signed-off-by: Florian Schmaus <flow@gentoo.org>
---
 eclass/texlive-module.eclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eclass/texlive-module.eclass b/eclass/texlive-module.eclass
index 9fc4e619ff9b..d19e02f02647 100644
--- a/eclass/texlive-module.eclass
+++ b/eclass/texlive-module.eclass
@@ -438,7 +438,7 @@ texlive-module_pkg_postinst() {
 # installed texmf trees.
 
 texlive-module_pkg_postrm() {
-	etexmf-update
+	[[ -z ${REPLACING_VERSIONS} ]] && etexmf-update
 }
 
 fi
-- 
2.43.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-dev] [PATCH 2/2] texlive-module.eclass: add texlive-module_update_tlpdb
  2024-04-02 14:07 [gentoo-dev] [PATCH 1/2] texlive-module.eclass: only invoke etexmf-update in postinst if not replacing versions Florian Schmaus
@ 2024-04-02 14:07 ` Florian Schmaus
  2024-04-02 14:57   ` Ulrich Mueller
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Schmaus @ 2024-04-02 14:07 UTC (permalink / raw)
  To: gentoo-dev; +Cc: Paul Zander, tex, Florian Schmaus

Update (or create) the tlpdb based on the contents of
/usr/share/tlpkg/tlpobj.

Closes: https://bugs.gentoo.org/928162
Signed-off-by: Florian Schmaus <flow@gentoo.org>
---
 eclass/texlive-module.eclass | 57 ++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/eclass/texlive-module.eclass b/eclass/texlive-module.eclass
index d19e02f02647..15346a3535eb 100644
--- a/eclass/texlive-module.eclass
+++ b/eclass/texlive-module.eclass
@@ -420,6 +420,61 @@ texlive-module_src_install() {
 	texlive-common_handle_config_files
 }
 
+# @FUNCTION: texlive-module_update_tlpdb
+# @DESCRIPTION:
+# Update the TexLive package database at /usr/share/tlpkg/texlive.tlpdb.
+
+texlive-module_update_tlpdb() {
+	[[ ${TL_PV} -lt 2023 ]] && return
+
+	# If we are updating this package, then there is no need to update
+	# the tlpdb in postrm, as it will be again updated in postinst.
+	[[ -n ${REPLACING_VERSIONS} && ${EBUILD_PHASE} == postrm ]] && return
+
+	local tlpkg="${EROOT}"/usr/share/tlpkg
+	local tlpobj="${tlpkg}"/tlpobj
+	local tlpdb="${tlpkg}"/texlive.tlpdb
+
+	ebegin "Regenerating TexLive package database (${tlpdb}, ${EBUILD_PHASE})"
+
+	local new_tlpdb="${T}"/texlive.tlpdb
+
+	touch "${new_tlpdb}" || die
+
+	find "${tlpobj}" -maxdepth 1 -type f -name "*.tlpobj" -print0 |
+		sort -z |
+		xargs -0 --no-run-if-empty cat >> "${new_tlpdb}"
+	assert "generating tlpdb failed"
+
+	if [[ -f ${tlpdb} ]]; then
+		cmp -s "${new_tlpdb}" "${tlpdb}"
+		local ret=$?
+		case ${ret} in
+			# content equal
+			0)
+				# Nothing to do, return.
+				eend 0
+				return
+				;;
+			# content differs
+			1)
+				;;
+			# cmp failed with an error
+			*)
+				eend ${ret} "comparing new and existing tlpdb failed (exit status: ${ret})"
+				die
+				;;
+		esac
+	fi
+
+	mv "${new_tlpdb}" "${tlpdb}"
+	eend $? "moving tlpdb into position failed (exit status: ${?})" || die
+
+	if [[ ! -s ${tlpdb} ]]; then
+		rm "${tlpdb}" || die
+	fi
+}
+
 # @FUNCTION: texlive-module_pkg_postinst
 # @DESCRIPTION:
 # exported function:
@@ -428,6 +483,7 @@ texlive-module_src_install() {
 
 texlive-module_pkg_postinst() {
 	etexmf-update
+	texlive-module_update_tlpdb
 	[[ -n ${TL_MODULE_INFORMATION} ]] && elog "${TL_MODULE_INFORMATION}"
 }
 
@@ -439,6 +495,7 @@ texlive-module_pkg_postinst() {
 
 texlive-module_pkg_postrm() {
 	[[ -z ${REPLACING_VERSIONS} ]] && etexmf-update
+	texlive-module_update_tlpdb
 }
 
 fi
-- 
2.43.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [gentoo-dev] [PATCH 2/2] texlive-module.eclass: add texlive-module_update_tlpdb
  2024-04-02 14:07 ` [gentoo-dev] [PATCH 2/2] texlive-module.eclass: add texlive-module_update_tlpdb Florian Schmaus
@ 2024-04-02 14:57   ` Ulrich Mueller
  0 siblings, 0 replies; 3+ messages in thread
From: Ulrich Mueller @ 2024-04-02 14:57 UTC (permalink / raw)
  To: Florian Schmaus; +Cc: gentoo-dev, Paul Zander, tex

[-- Attachment #1: Type: text/plain, Size: 588 bytes --]

>>>>> On Tue, 02 Apr 2024, Florian Schmaus wrote:

> +	# If we are updating this package, then there is no need to update
> +	# the tlpdb in postrm, as it will be again updated in postinst.
> +	[[ -n ${REPLACING_VERSIONS} && ${EBUILD_PHASE} == postrm ]] && return

Sorry for having missed this before. REPLACING_VERSIONS isn't defined
in pkg_postrm, so the test should be for REPLACED_BY_VERSION.

Also it would be cleaner to test for the phase first, to make sure that
the variable is valid in this phase:

	[[ ${EBUILD_PHASE} == postrm && -n ${REPLACED_BY_VERSION} ]] && return

Ulrich

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 507 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-02 14:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-02 14:07 [gentoo-dev] [PATCH 1/2] texlive-module.eclass: only invoke etexmf-update in postinst if not replacing versions Florian Schmaus
2024-04-02 14:07 ` [gentoo-dev] [PATCH 2/2] texlive-module.eclass: add texlive-module_update_tlpdb Florian Schmaus
2024-04-02 14:57   ` Ulrich Mueller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox