Add chown and chgrp wrappers for prefix.
authorZac Medico <zmedico@gentoo.org>
Sun, 30 Sep 2012 08:18:45 +0000 (01:18 -0700)
committerZac Medico <zmedico@gentoo.org>
Sun, 30 Sep 2012 08:18:45 +0000 (01:18 -0700)
For prefix, there is typically only a single unprivileged user who owns
everthing that is built and installed, and in this case it's desirable
to ignore chown and chrgrp failures. So, move the logic from fowners
into chown and chgrp wrappers, as discussed in bug #433453.

bin/ebuild-helpers/fowners
bin/ebuild-helpers/unprivileged/chgrp [new symlink]
bin/ebuild-helpers/unprivileged/chown [new file with mode: 0755]
pym/portage/package/ebuild/doebuild.py

index b664ec7667677f9f73aa49408f3b5f4e534ada73..cee4108ce0f28cf6741a5a6ced88bd7851e647b1 100755 (executable)
@@ -14,10 +14,5 @@ slash="/"
 chown "${@/#${slash}/${ED}${slash}}"
 ret=$?
 
-if [[ ${ret} != 0 && -n ${EPREFIX} && ${EUID} != 0 ]] ; then
-       ewarn "fowners failure ignored in Prefix with non-privileged user"
-       exit 0
-fi
-
 [[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
 exit $ret
diff --git a/bin/ebuild-helpers/unprivileged/chgrp b/bin/ebuild-helpers/unprivileged/chgrp
new file mode 120000 (symlink)
index 0000000..6fb0fcd
--- /dev/null
@@ -0,0 +1 @@
+chown
\ No newline at end of file
diff --git a/bin/ebuild-helpers/unprivileged/chown b/bin/ebuild-helpers/unprivileged/chown
new file mode 100755 (executable)
index 0000000..cad34d9
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/bash
+# Copyright 2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+scriptpath=${BASH_SOURCE[0]}
+scriptname=${scriptpath##*/}
+
+IFS=':'
+
+for path in ${PATH}; do
+       [[ -x ${path}/${scriptname} ]] || continue
+       [[ ${path}/${scriptname} -ef ${scriptpath} ]] && continue
+       IFS=$' \t\n'
+       output=$("${path}/${scriptname}" "$@" 2>&1)
+       if [[ $? -ne 0 ]] ; then
+               source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
+
+               if ! ___eapi_has_prefix_variables; then
+                       EPREFIX=
+               fi
+               msg="${scriptname} failure ignored with unprivileged user:\n    ${scriptname} $*\n    ${output}"
+               # Reverse expansion of ${D} and ${EPREFIX}, for readability.
+               msg=${msg//${D}/'${D}'}
+               if [[ -n ${EPREFIX} ]] ; then
+                       msg=${msg//${EPREFIX}/'${EPREFIX}'}
+                       msg=${msg//${EPREFIX#/}/'${EPREFIX}'}
+               fi
+               ewarn "${msg}"
+       fi
+       exit 0
+done
+
+exit 1
index 04d0808ae543f1a1a58561f82259ed3c81f42391..9deed98d79fa3f68b7bcf6b87828a9a76c2d0b08 100644 (file)
@@ -158,6 +158,10 @@ def _doebuild_path(settings, eapi=None):
 
        path = []
 
+       if eprefix and uid != 0 and "fakeroot" not in settings.features:
+               path.append(os.path.join(portage_bin_path,
+                       "ebuild-helpers", "unprivileged"))
+
        if settings.get("USERLAND", "GNU") != "GNU":
                path.append(os.path.join(portage_bin_path, "ebuild-helpers", "bsd"))