commit:     90e6e999c8f63d02a471308fa16932859201aaf7
Author:     Nicolas PARLANT <nicolas.parlant <AT> parhuet <DOT> fr>
AuthorDate: Fri Mar 13 09:51:34 2026 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Sun Mar 15 20:17:44 2026 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=90e6e999

fowners: add compat to resolve_owner for older EAPIs

Bug: https://bugs.gentoo.org/971120
Signed-off-by: Nicolas PARLANT <nicolas.parlant <AT> parhuet.fr>
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>

 bin/ebuild-helpers/fowners | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/bin/ebuild-helpers/fowners b/bin/ebuild-helpers/fowners
index a1589d1b2d..d954d16932 100755
--- a/bin/ebuild-helpers/fowners
+++ b/bin/ebuild-helpers/fowners
@@ -12,12 +12,18 @@ __resolve_owner() {
        local owner="${1}"
        local user group uid gid pgid pwdb_path
 
-       if [[ ${EBUILD_PHASE_FUNC} == pkg_* ]]; then
-               # for pkg_preinst
-               pwdb_path="${EROOT}"/etc
+       if [[ ${EBUILD_PHASE} == preinst ]]; then
+               if ___eapi_has_prefix_variables; then
+                       pwdb_path="${EROOT%/}"/etc
+               else
+                       pwdb_path="${ROOT%/}"/etc
+               fi
        else
-               # for src_install
-               pwdb_path="${ESYSROOT}"/etc
+               if ___eapi_has_SYSROOT; then
+                       pwdb_path="${ESYSROOT}"/etc
+               else
+                       pwdb_path="${ROOT%/}"/etc
+               fi
        fi
 
        IFS=':' read -r user group <<< "${owner}"
@@ -60,7 +66,7 @@ for arg; do
                # the first non-option is the owner and must not be prefixed
                got_owner=1
                # use numeric-uid-gid from the custom target root
-               if ___eapi_has_SYSROOT && [[ -n "${SYSROOT}" || -n "${ROOT}" 
]]; then
+               if [[ -n "${SYSROOT%/}" || -n "${ROOT%/}" ]]; then
                        args+=( "$(__resolve_owner "${arg}")" )
                else
                        args+=( "${arg}" )

Reply via email to