Patch to apply against HEAD of sys-app/portage project. I did git clone git://git.overlays.gentoo.org/proj/portage.git on 2014-07-04 13:47:53.442947599 +0000. diff -ru old_portage/pym/portage/const.py portage/pym/portage/const.py --- old_portage/pym/portage/const.py 2014-07-04 16:35:37.462942289 +0200 +++ portage/pym/portage/const.py 2014-07-04 17:03:00.347420753 +0200 @@ -119,6 +119,7 @@ "other", ) SUPPORTED_FEATURES = frozenset([ + "uncooperative-root", "assume-digests", "binpkg-logs", "buildpkg", diff -ru old_portage/cnf/make.conf.example portage/cnf/make.conf.example --- old_portage/cnf/make.conf.example 2014-07-04 16:52:24.438859863 +0200 +++ portage/cnf/make.conf.example 2014-07-04 17:08:10.658545393 +0200 @@ -362,3 +362,29 @@ # ${PACKAGE} - see description of PORTAGE_ELOG_COMMAND # ${HOST} - FQDN of the host portage is running on #PORTAGE_ELOG_MAILSUBJECT="[portage] ebuild log for \${PACKAGE} on \${HOST}" +# +# Variant for Prefix installations +# ================================ +# +#MAKEOPTS="-j2 TMPDIR=${EPREFIX}/tmp CONFIG_SHELL=${EPREFIX}/bin/sh SHELL=${EPREFIX}/bin/bash" +#PORTAGE_PYTHON=$EPREFIX/usr/bin/python # e.g. for portage/bin/misc-functions.sh +#PREFIX_DISABLE_GEN_USR_LDSCRIPT=set # e.g. for net-libs/libtirpc-0.2.2-r1.ebuild +#FEATURES="uncooperative-root" +#USE="uncooperative-root" +# +# has uncooperative-root ${FEATURES} +# is a condition meaning that /tmp, /bin/bash, +# /bin/sh, /dev, /usr/bin/{env,find,file} may not be available at buiding time +# and despite being in various standards (FHS, ...) root administrator will not +# cooperate or will break compatibility without notice. They are to be used now +# in .eclass and in sys-app/portage (typical example: Android; needed for +# gentooandroid.sourceforge.net). +# It will likely be used in any *.ebuild file whose EAPI officially contains +# SUPPORTED_FEATURES=uncooperative-root. +# +# use uncooperative-root +# is the equivalent condition to use in files *.ebuild whose EAPI doesn't +# officially contain SUPPORTED_FEATURES=uncooperative-root. To enable that +# condition, a file *.ebuild not inherite-ing anything should contain +# IUSE=-uncooperative-root for that (otherwise, prefix.eclass will have +# IUSE_IMPLICIT=uncooperative-root even if not directly inherited). diff -ru old_portage/bin/ebuild-helpers/emake portage/bin/ebuild-helpers/emake --- old_portage/bin/ebuild-helpers/emake 2014-07-04 16:17:50.847841909 +0200 +++ portage/bin/ebuild-helpers/emake 2014-07-04 16:30:26.020612108 +0200 @@ -11,6 +11,14 @@ source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh +#${MAKEOPTS} is not transmitted to things called by make +has uncooperative-root ${FEATURES} && { + export TMPDIR="${EPREFIX}"/tmp + export BASH="${EPREFIX}"/bin/bash + export CONFIG_SHELL="${EPREFIX}"/bin/sh +} + + if [[ $PORTAGE_QUIET != 1 ]] ; then ( for arg in ${MAKE:-make} $MAKEOPTS $EXTRA_EMAKE "$@" ; do diff -ru old_portage/bin/ebuild.sh portage/bin/ebuild.sh --- old_portage/bin/ebuild.sh 2014-07-04 15:59:24.022279274 +0200 +++ portage/bin/ebuild.sh 2014-07-04 16:01:08.613886159 +0200 @@ -90,8 +90,13 @@ __qa_call() { local shopts=$(shopt) OLDIFS="$IFS" local retval - "$@" - retval=$? + if has uncooperative-root ${FEATURES} ; then + uncooperative-root-wrapper "$@" # from prefix.eclass + retval=$? + else + "$@" + retval=$? + fi set +e [[ $shopts != $(shopt) ]] && eqawarn "QA Notice: Global shell options changed and were not restored while calling '$*'" diff -ru old_portage/bin/misc-functions.sh portage/bin/misc-functions.sh --- old_portage/bin/misc-functions.sh 2014-07-04 16:03:59.416144645 +0200 +++ portage/bin/misc-functions.sh 2014-07-04 16:57:13.327124754 +0200 @@ -820,7 +820,7 @@ rm -f "${ED}"/usr/share/info/dir{,.gz,.bz2} || die "rm failed!" if has multilib-strict ${FEATURES} && \ - [[ -x /usr/bin/file && -x /usr/bin/find ]] && \ + [[ -x "`has uncooperative-root ${FEATURES} && echo ${EPREFIX}`/usr/bin/file" && -x "`has uncooperative-root ${FEATURES} && echo ${EPREFIX}`/usr/bin/find" ]] && \ [[ -n ${MULTILIB_STRICT_DIRS} && -n ${MULTILIB_STRICT_DENY} ]] then rm -f "${T}/multilib-strict.log" @@ -1193,6 +1193,10 @@ fi [ -n "${md5_hash}" ] && \ echo ${md5_hash} > "${PORTAGE_BUILDDIR}"/build-info/BINPKGMD5 + # inform about trial patching done by uncooperative-root + has uncooperative-root ${FEATURES} && bzip2 -c \ + < "${PORTAGE_BUILDDIR}"/temp/build.log \ + > "${PORTAGE_BUILDDIR}"/build-info/build.log.bz2 __vecho ">>> Done." # cleanup our temp tree diff -ru old_portage/bin/phase-helpers.sh portage/bin/phase-helpers.sh --- old_portage/bin/phase-helpers.sh 2014-07-04 16:27:01.655594020 +0200 +++ portage/bin/phase-helpers.sh 2014-07-04 16:27:22.888250815 +0200 @@ -471,6 +471,10 @@ local x local pid=${BASHPID:-$(__bashpid)} + has uncooperative-root ${FEATURES} && { + export TMPDIR="${EPREFIX}"/tmp + export CONFIG_SHELL="${EPREFIX}"/bin/sh + } if ! ___eapi_has_prefix_variables; then local EPREFIX= fi @@ -592,6 +596,7 @@ einstall() { # CONF_PREFIX is only set if they didn't pass in libdir above. + has uncooperative-root ${FEATURES} && export TMPDIR="${EPREFIX}"/tmp local LOCAL_EXTRA_EINSTALL="${EXTRA_EINSTALL}" if ! ___eapi_has_prefix_variables; then local ED=${D}