commit:     244a93bf8e0df991b6c9690920fc2573b7637410
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Dec  4 07:49:59 2025 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Dec  4 07:49:59 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=244a93bf

autoconf: drop handling of user/group

This is Prefix branch, and thus install as the calling user.  Let setup
of user/group/uid/gid be dealt with by user config.  The
bootstrap-prefix script will setup this for once and forever.  This
brings Prefix closer to main, and simplifies considerably.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 bin/Makefile.in                     | 12 +++---------
 cnf/Makefile.in                     | 13 +++----------
 cnf/make.globals                    | 14 +++-----------
 configure.ac                        | 38 -------------------------------------
 lib/Makefile.in                     |  7 +------
 lib/portage/const_autotool.py       |  4 +---
 lib/portage/package/ebuild/fetch.py |  5 +----
 subst-install.in                    | 14 --------------
 8 files changed, 12 insertions(+), 95 deletions(-)

diff --git a/bin/Makefile.in b/bin/Makefile.in
index e6dc6724ff..14516fc94a 100644
--- a/bin/Makefile.in
+++ b/bin/Makefile.in
@@ -8,9 +8,6 @@ libdir = @libdir@
 srcdir = @srcdir@
 top_builddir = @top_builddir@
 
-portageuser = @portageuser@
-portagegroup = @portagegroup@
-
 PORTAGE_BIN = @PORTAGE_BASE@/bin
 LN_S = @LN_S@
 INSTALL = @INSTALL@
@@ -40,7 +37,7 @@ hprefixify_progs = \
 all:
 
 install:
-       $(INSTALL) -d -m 755 -o "$(portageuser)" -g "$(portagegroup)" 
$(DESTDIR)$(PORTAGE_BIN)
+       $(INSTALL) -d -m 755 $(DESTDIR)$(PORTAGE_BIN)
        ( cd "$(srcdir)" && find . -type d ) | while read f ; do \
                files=( ) ; \
                shopt -s nullglob ; \
@@ -50,21 +47,18 @@ install:
                        files=( "$${files[@]}" "$${t}" ) ; \
                done ; \
                $(INSTALL) -d -m 755 \
-                       -o "$(portageuser)" -g "$(portagegroup)" \
                        "$(DESTDIR)$(PORTAGE_BIN)/$${f}" && \
                [[ $${files[0]} ]] || continue ; \
                $(INSTALL_subst) -m 755 \
-                       -o "$(portageuser)" -g "$(portagegroup)" \
                        -t "$(DESTDIR)$(PORTAGE_BIN)/$${f}" \
                        "$${files[@]}" ; \
        done ; \
        for f in $(hprefixify_progs) ; do \
                $(INSTALL_subst) --hprefixify -m 755 \
-                       -o "$(portageuser)" -g "$(portagegroup)" \
                        -t "$(DESTDIR)$(PORTAGE_BIN)" \
                        "$(srcdir)/$${f}" ; \
        done
-       $(INSTALL) -d -m 755 -o "$(portageuser)" -g "$(portagegroup)" 
$(DESTDIR)$(prefix)/bin
+       $(INSTALL) -d -m 755 $(DESTDIR)$(prefix)/bin
        cd $(DESTDIR)$(prefix)/bin \
        ; for p in $(usr_binprogs) \
        ; do test -f $(DESTDIR)$(PORTAGE_BIN)/$${p} \
@@ -72,7 +66,7 @@ install:
           ; rm -f $(DESTDIR)$(prefix)/bin/$${p} \
           ; $(LN_S) ../lib/portage/bin/$${p} $${p} || exit 1 \
        ; done
-       $(INSTALL) -d -m 755 -o "$(portageuser)" -g "$(portagegroup)" 
$(DESTDIR)$(prefix)/sbin
+       $(INSTALL) -d -m 755 $(DESTDIR)$(prefix)/sbin
        cd $(DESTDIR)$(prefix)/sbin \
        ; for p in $(usr_sbinprogs) \
        ; do test -f $(DESTDIR)$(PORTAGE_BIN)/$${p} \

diff --git a/cnf/Makefile.in b/cnf/Makefile.in
index 64d2fa7a78..6c0ebdf1b9 100644
--- a/cnf/Makefile.in
+++ b/cnf/Makefile.in
@@ -8,9 +8,6 @@ srcdir = @srcdir@
 top_builddir = @top_builddir@
 PORTAGE_CONF = $(datadir)/portage/config
 
-portageuser = @portageuser@
-portagegroup = @portagegroup@
-
 INSTALL = @INSTALL@
 INSTALL_subst = ${top_builddir}/subst-install --hprefixify
 LN_S = @LN_S@
@@ -18,22 +15,18 @@ LN_S = @LN_S@
 all:
 
 install:
-       $(INSTALL) -d -m 755 -o "$(portageuser)" -g "$(portagegroup)" 
$(DESTDIR)$(PORTAGE_CONF)
+       $(INSTALL) -d -m 755 $(DESTDIR)$(PORTAGE_CONF)
        $(INSTALL_subst) \
-               -o "$(portageuser)" -g "$(portagegroup)" \
                -t "$(DESTDIR)$(PORTAGE_CONF)" \
                "$(srcdir)"/make.globals "$(srcdir)"/repos.conf
-       $(INSTALL) -d -m 755 -o "$(portageuser)" -g "$(portagegroup)" 
$(DESTDIR)$(PORTAGE_CONF)/sets
+       $(INSTALL) -d -m 755 $(DESTDIR)$(PORTAGE_CONF)/sets
        $(INSTALL_subst) \
-               -o "$(portageuser)" -g "$(portagegroup)" \
                -t "$(DESTDIR)$(PORTAGE_CONF)/sets" \
                "$(srcdir)"/sets/portage.conf
        $(INSTALL_subst) \
-               -o "$(portageuser)" -g "$(portagegroup)" \
                "$(srcdir)"/make.conf.example 
"$(DESTDIR)$(PORTAGE_CONF)"/make.conf.example
-       $(INSTALL) -d -m 755 -o "$(portageuser)" -g "$(portagegroup)" 
$(DESTDIR)$(sysconfdir)
+       $(INSTALL) -d -m 755 $(DESTDIR)$(sysconfdir)
        $(INSTALL_subst) \
-               -o "$(portageuser)" -g "$(portagegroup)" \
                -t "$(DESTDIR)$(sysconfdir)" \
                "$(srcdir)"/dispatch-conf.conf \
                "$(srcdir)"/etc-update.conf

diff --git a/cnf/make.globals b/cnf/make.globals
index 50ced14c38..b4c072042d 100644
--- a/cnf/make.globals
+++ b/cnf/make.globals
@@ -140,15 +140,6 @@ CONFIG_PROTECT_MASK="/etc/env.d"
 # Disable auto-use
 USE_ORDER="env:pkg:conf:defaults:pkginternal:features:repo:env.d"
 
-# PREFIX LOCAL: additional vars set during install
-# Default portage user/group
-PORTAGE_USERNAME='@portageuser@'
-PORTAGE_GRPNAME='@portagegroup@'
-
-# Default ownership of installed files.
-PORTAGE_INST_UID="@rootuid@"
-PORTAGE_INST_GID="@rootgid@"
-
 # Mode bits for ${WORKDIR} (see ebuild.5).
 PORTAGE_WORKDIR_MODE="0700"
 
@@ -156,9 +147,10 @@ PORTAGE_WORKDIR_MODE="0700"
 PORTAGE_ELOG_CLASSES="log warn error"
 PORTAGE_ELOG_SYSTEM="save_summary:log,warn,error,qa echo"
 
-PORTAGE_ELOG_MAILURI="@portageuser@"
+# PREFIX LOCAL: don't use hardwired root/portage
+PORTAGE_ELOG_MAILURI="\${PORTAGE_USERNAME:-root}"
 PORTAGE_ELOG_MAILSUBJECT="[portage] ebuild log for \${PACKAGE} on \${HOST}"
-PORTAGE_ELOG_MAILFROM="@portageuser@@localhost"
+PORTAGE_ELOG_MAILFROM="\${PORTAGE_USERNAME:-portage}@localhost"
 # END PREFIX LOCAL
 
 # Signing command used by egencache

diff --git a/configure.ac b/configure.ac
index 3442bbd7bc..50abd6e164 100644
--- a/configure.ac
+++ b/configure.ac
@@ -45,40 +45,6 @@ GENTOO_PATH_GNUPROG(PORTAGE_FIND, [find])
 GENTOO_PATH_GNUPROG(PORTAGE_XARGS, [xargs])
 GENTOO_PATH_GNUPROG(PORTAGE_GREP, [grep])
 
-AC_ARG_WITH(portage-user,
-AS_HELP_STRING([--with-portage-user=myuser],[use user 'myuser' as portage 
owner (default portage)]),
-[case "${withval}" in
-  ""|yes) AC_MSG_ERROR(bad value ${withval} for --with-portage-user);;
-  *) portageuser="${withval}";;
-esac],
-[portageuser="portage"])
-
-AC_ARG_WITH(portage-group,
-AS_HELP_STRING([--with-portage-group=mygroup],[use group 'mygroup' as portage 
users group (default portage)]),
-[case "${withval}" in
-  ""|yes) AC_MSG_ERROR(bad value ${withval} for --with-portage-group);;
-  *) portagegroup="${withval}";;
-esac],
-[portagegroup="portage"])
-
-AC_MSG_CHECKING([for user id of ${portageuser}])
-dnl grab uid of portageuser
-rootuid=`${XCU_ID} -u "${portageuser}"`
-if test "x`echo ${rootuid} | ${EGREP} '^[[0-9]]+$'`" != "x"
-then
-       AC_MSG_RESULT([${rootuid}])
-else
-       AC_MSG_ERROR([error finding the user id of ${portageuser}])
-fi
-AC_MSG_CHECKING([for group id of ${portagegroup}])
-rootgid=`${PREFIX_PORTAGE_PYTHON} -c "import grp; 
print(grp.getgrnam('${portagegroup}').gr_gid)"`
-if test "x`echo ${rootgid} | ${EGREP} '^[[0-9]]+$'`" != "x"
-then
-       AC_MSG_RESULT([${rootgid}])
-else
-       AC_MSG_ERROR([error finding the group id of ${portagegroup}])
-fi
-
 AC_ARG_WITH(offset-prefix, 
 AS_HELP_STRING([--with-offset-prefix],[specify the installation prefix for all 
packages, defaults to an empty string]),
                           [PORTAGE_EPREFIX=$withval],
@@ -89,10 +55,6 @@ then
        PORTAGE_EPREFIX=`${PREFIX_PORTAGE_PYTHON} -c "import os; 
print(os.path.normpath('$PORTAGE_EPREFIX'))"`
 fi
 
-AC_SUBST(portageuser)
-AC_SUBST(portagegroup)
-AC_SUBST(rootuid)
-AC_SUBST(rootgid)
 AC_SUBST(PORTAGE_EPREFIX)
 AC_SUBST(PORTAGE_BASE,['${exec_prefix}/lib/portage'])
 

diff --git a/lib/Makefile.in b/lib/Makefile.in
index 7d4193cc99..4f4437f471 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -9,9 +9,6 @@ PYTHON = @PREFIX_PORTAGE_PYTHON@
 srcdir=@srcdir@
 top_builddir=@top_builddir@
 
-portageuser = @portageuser@
-portagegroup = @portagegroup@
-
 PORTAGE_PYM = @PORTAGE_BASE@/lib
 INSTALL = @INSTALL@
 INSTALL_subst = ${top_builddir}/subst-install
@@ -19,7 +16,7 @@ INSTALL_subst = ${top_builddir}/subst-install
 all:
 
 install:
-       $(INSTALL) -d -m 755 -o "$(portageuser)" -g "$(portagegroup)" 
$(DESTDIR)$(PORTAGE_PYM)
+       $(INSTALL) -d -m 755 $(DESTDIR)$(PORTAGE_PYM)
        ( cd "$(srcdir)" && find * -type d ) | while read f ; do \
                files=( ) ; \
                shopt -s nullglob ; \
@@ -29,11 +26,9 @@ install:
                        files=( "$${files[@]}" "$${t}" ) ; \
                done ; \
                $(INSTALL) -d -m 755 \
-                       -o "$(portageuser)" -g "$(portagegroup)" \
                        "$(DESTDIR)$(PORTAGE_PYM)/$${f}" && \
                [[ $${files[0]} ]] || continue ; \
                $(INSTALL_subst) \
-                       -o "$(portageuser)" -g "$(portagegroup)" \
                        -t "$(DESTDIR)$(PORTAGE_PYM)/$${f}" \
                        "$${files[@]}" \
        ; done

diff --git a/lib/portage/const_autotool.py b/lib/portage/const_autotool.py
index 2e11e27870..45a1d00b2f 100644
--- a/lib/portage/const_autotool.py
+++ b/lib/portage/const_autotool.py
@@ -3,8 +3,6 @@
 
 # all vars that are to wind up in portage_const must have their name listed in 
__all__
 
-__all__ = ["EPREFIX", "rootgid"]
+__all__ = ["EPREFIX"]
 
 EPREFIX      = "@PORTAGE_EPREFIX@"
-
-rootgid      = @rootgid@

diff --git a/lib/portage/package/ebuild/fetch.py 
b/lib/portage/package/ebuild/fetch.py
index e902bcdb43..bee2e10893 100644
--- a/lib/portage/package/ebuild/fetch.py
+++ b/lib/portage/package/ebuild/fetch.py
@@ -52,8 +52,6 @@ from portage.checksum import (
     checksum_str,
 )
 from portage.const import BASH_BINARY, CUSTOM_MIRRORS_FILE, GLOBAL_CONFIG_PATH
-# PREFIX LOCAL
-from portage.const import rootgid
 from portage.data import portage_gid, portage_uid, userpriv_groups
 from portage.exception import (
     FileNotFound,
@@ -270,8 +268,7 @@ async def _ensure_distdir(settings, distdir):
         # to have root's gid. Therefore, use root's gid instead of
         # portage's gid to avoid spurious permissions adjustments
         # when inside fakeroot.
-        # PREFIX LOCAL: do not assume root to be 0
-        dir_gid = rootgid
+        dir_gid = 0
 
     userfetch = portage.data.secpass >= 2 and "userfetch" in settings.features
     userpriv = portage.data.secpass >= 2 and "userpriv" in settings.features

diff --git a/subst-install.in b/subst-install.in
index 1bad6165f1..9734e3be13 100644
--- a/subst-install.in
+++ b/subst-install.in
@@ -4,16 +4,6 @@
 prefix="@prefix@"
 exec_prefix="@exec_prefix@"
 
-# For bug #279550 we have to do some nasty trick to make sure that sed
-# doesn't strip the backslash in the replacement value (because it can
-# be a backreference) and hence escape those.  Eventually in strings we
-# need to escape the backslash too, such that the single backslash
-# doesn't get lost when considered an invalid escape
-portagegroup='@portagegroup@'
-portageuser='@portageuser@'
-portagegroup=${portagegroup//\\/\\\\\\\\}
-portageuser=${portageuser//\\/\\\\\\\\}
-
 # there are many ways to do this all dynamic, but we only care for raw
 # speed here, so let configure fill in this list and be done with it
 at='@'
@@ -29,10 +19,6 @@ sedexp=(
        -e "s,${at}EPREFIX${at},@PORTAGE_EPREFIX@,g"
        -e "s,${at}INSTALL_TYPE${at},SYSTEM,g"
        -e "s,${at}datadir${at},@datadir@,g"
-       -e "s,${at}portagegroup${at},${portagegroup},g"
-       -e "s,${at}portageuser${at},${portageuser},g"
-       -e "s,${at}rootgid${at},@rootgid@,g"
-       -e "s,${at}rootuid${at},@rootuid@,g"
        -e "s,${at}sysconfdir${at},@sysconfdir@,g"
 )
 

Reply via email to