When installing the `app-text/docbook-xml-dtd` into a `ROOT=` path, the generated catalog file is invalid. ``` $ cat /build/amd64-host/etc/sgml/catalog CATALOG "/build/amd64-host/etc/sgml/sgml-docbook.cat" CATALOG "/build/amd64-host/etc/sgml/sgml-ent.cat" CATALOG "/build/amd64-host/etc/sgml/xml-docbook-4.1.2.cat" CATALOG "/build/amd64-host/etc/sgml/xml-docbook-4.2.cat" CATALOG "/build/amd64-host/etc/sgml/xml-docbook-4.3.cat" CATALOG "/build/amd64-host/etc/sgml/xml-docbook-4.4.cat" CATALOG "/build/amd64-host/etc/sgml/xml-docbook-4.5.cat" ``` Here is the code that generates the catalog: ``` 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 } ``` We write the raw GLOB paths to the catalog, we need to strip off the ROOT otherwise we write an invalid path. Reproducible: Always Steps to Reproduce: 1. ROOT=/build/amd64-host emerge app-text/docbook-xml-dtd:4.5 2. Check the catalog Actual Results: ``` $ cat /build/amd64-host/etc/sgml/catalog CATALOG "/build/amd64-host/etc/sgml/sgml-docbook.cat" CATALOG "/build/amd64-host/etc/sgml/sgml-ent.cat" CATALOG "/build/amd64-host/etc/sgml/xml-docbook-4.1.2.cat" CATALOG "/build/amd64-host/etc/sgml/xml-docbook-4.2.cat" CATALOG "/build/amd64-host/etc/sgml/xml-docbook-4.3.cat" CATALOG "/build/amd64-host/etc/sgml/xml-docbook-4.4.cat" CATALOG "/build/amd64-host/etc/sgml/xml-docbook-4.5.cat" ``` Expected Results: ``` $ cat /build/amd64-host/etc/sgml/catalog CATALOG "/etc/sgml/sgml-docbook.cat" CATALOG "/etc/sgml/sgml-ent.cat" CATALOG "/etc/sgml/xml-docbook-4.1.2.cat" CATALOG "/etc/sgml/xml-docbook-4.2.cat" CATALOG "/etc/sgml/xml-docbook-4.3.cat" CATALOG "/etc/sgml/xml-docbook-4.4.cat" ```
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=65a031f4c9d702c4fc8b6ce6b0541453a6db8c08 commit 65a031f4c9d702c4fc8b6ce6b0541453a6db8c08 Author: Raul E Rangel <rrangel@chromium.org> AuthorDate: 2023-04-03 17:28:49 +0000 Commit: Michał Górny <mgorny@gentoo.org> CommitDate: 2023-04-04 04:48:47 +0000 sgml-catalog-r1.eclass: Strip ROOT when generating catalog When cross compiling by setting the ROOT variable, the eclass was writing the full EROOT path into the catalog file. This results in an invalid path at runtime. i.e., $ cat /build/amd64-host/etc/sgml/catalog CATALOG "/build/amd64-host/etc/sgml/sgml-docbook.cat" CATALOG "/build/amd64-host/etc/sgml/sgml-ent.cat" CATALOG "/build/amd64-host/etc/sgml/xml-docbook-4.1.2.cat" Instead we should be stripping off the ROOT so we get a valid path: $ cat /build/amd64-host/etc/sgml/catalog CATALOG "/etc/sgml/sgml-docbook.cat" CATALOG "/etc/sgml/sgml-ent.cat" CATALOG "/etc/sgml/xml-docbook-4.1.2.cat" We don't strip EROOT because we want to keep the prefix if it's present. Closes: https://bugs.gentoo.org/903747 Signed-off-by: Raul E Rangel <rrangel@chromium.org> Closes: https://github.com/gentoo/gentoo/pull/30462 Signed-off-by: Michał Górny <mgorny@gentoo.org> eclass/sgml-catalog-r1.eclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)