summaryrefslogtreecommitdiffstats
path: root/bin/ebuild-helpers/unprivileged/chown
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2012-09-30 01:18:45 -0700
committerZac Medico <zmedico@gentoo.org>2012-09-30 01:18:45 -0700
commit45bedf9cdc10fafd94858f67d62b36d35dd99544 (patch)
tree5b79afe471a0b98221726f00a5af1b731e28e5eb /bin/ebuild-helpers/unprivileged/chown
parent2377357f4e0164d338c1249c79f479229aa7c0e4 (diff)
downloadportage-45bedf9cdc10fafd94858f67d62b36d35dd99544.tar.gz
portage-45bedf9cdc10fafd94858f67d62b36d35dd99544.tar.bz2
portage-45bedf9cdc10fafd94858f67d62b36d35dd99544.zip
Add chown and chgrp wrappers for prefix.
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.
Diffstat (limited to 'bin/ebuild-helpers/unprivileged/chown')
-rwxr-xr-xbin/ebuild-helpers/unprivileged/chown33
1 files changed, 33 insertions, 0 deletions
diff --git a/bin/ebuild-helpers/unprivileged/chown b/bin/ebuild-helpers/unprivileged/chown
new file mode 100755
index 000000000..cad34d947
--- /dev/null
+++ b/bin/ebuild-helpers/unprivileged/chown
@@ -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