From: Fabian Groffen Date: Fri, 9 Dec 2011 20:32:39 +0000 (+0100) Subject: Merge remote-tracking branch 'overlays-gentoo-org/master' into prefix X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=868bcc349966d957d51b302b530f3299dd8fb5c8;p=portage.git Merge remote-tracking branch 'overlays-gentoo-org/master' into prefix Conflicts: bin/dispatch-conf bin/ebuild-helpers/dobin bin/ebuild-helpers/dodir bin/ebuild-helpers/dodoc bin/ebuild-helpers/doexe bin/ebuild-helpers/dohard bin/ebuild-helpers/doinfo bin/ebuild-helpers/doins bin/ebuild-helpers/dolib bin/ebuild-helpers/domo bin/ebuild-helpers/dosbin bin/ebuild-helpers/dosed bin/ebuild-helpers/dosym bin/ebuild-helpers/ecompressdir bin/ebuild-helpers/fowners bin/ebuild-helpers/fperms bin/ebuild-helpers/prepalldocs bin/ebuild-helpers/prepallinfo bin/ebuild-helpers/prepallman bin/ebuild-helpers/prepallstrip bin/ebuild-helpers/prepinfo bin/ebuild-helpers/preplib bin/ebuild-helpers/prepstrip bin/emerge-webrsync bin/etc-update bin/misc-functions.sh bin/phase-functions.sh bin/phase-helpers.sh cnf/dispatch-conf.conf cnf/make.conf cnf/make.globals pym/portage/data.py pym/portage/dispatch_conf.py pym/portage/package/ebuild/_config/special_env_vars.py pym/portage/package/ebuild/config.py --- 868bcc349966d957d51b302b530f3299dd8fb5c8 diff --cc bin/dispatch-conf index 6a77f7bce,1cad9e011..e639b66d8 --- a/bin/dispatch-conf +++ b/bin/dispatch-conf @@@ -92,7 -85,7 +92,7 @@@ class dispatch confs = [] count = 0 - config_root = EPREFIX - config_root = os.environ.get("__PORTAGE_TEST_EPREFIX", "/") ++ config_root = os.environ.get("__PORTAGE_TEST_EPREFIX", EPREFIX) self.options = portage.dispatch_conf.read_config(MANDATORY_OPTS) if "log-file" in self.options: diff --cc bin/ebuild-helpers/dobin index 8adc65d48,f90d8933c..922e600c7 --- a/bin/ebuild-helpers/dobin +++ b/bin/ebuild-helpers/dobin @@@ -1,8 -1,8 +1,8 @@@ -#!/bin/bash +#!@PORTAGE_BASH@ - # Copyright 1999-2010 Gentoo Foundation + # Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh +source "${PORTAGE_BIN_PATH:-@PORTAGE_BASE@/bin}"/isolated-functions.sh if [[ $# -lt 1 ]] ; then helpers_die "${0##*/}: at least one argument needed" diff --cc bin/ebuild-helpers/dodir index 06dd2fe72,90a3efed4..f7a9c395f --- a/bin/ebuild-helpers/dodir +++ b/bin/ebuild-helpers/dodir @@@ -2,11 -2,10 +2,10 @@@ # Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh +source "${PORTAGE_BIN_PATH:-@PORTAGE_BASE@/bin}"/isolated-functions.sh - # PREFIX LOCAL: always support ED - #case "$EAPI" in 0|1|2) ED=${D} ;; esac - # END PREFIX LOCAL + [[ " ${FEATURES} " == *" force-prefix "* ]] || \ + case "$EAPI" in 0|1|2) ED=${D} ;; esac install -d ${DIROPTIONS} "${@/#/${ED}/}" ret=$? diff --cc bin/ebuild-helpers/doins index 0eafced99,443bfdb21..b9c95ed0f --- a/bin/ebuild-helpers/doins +++ b/bin/ebuild-helpers/doins @@@ -39,13 -38,6 +38,15 @@@ if [[ ${INSDESTTREE#${ED}} != "${INSDES helpers_die "${0##*/} used with \${D} or \${ED}" exit 1 fi ++# PREFIX LOCAL: check for usage with EPREFIX +if [[ ${INSDESTTREE#${EPREFIX}} != "${INSDESTTREE}" ]]; then + vecho "-------------------------------------------------------" 1>&2 + vecho "You should not use \${EPREFIX} with helpers." 1>&2 + vecho " --> ${INSDESTTREE}" 1>&2 + vecho "-------------------------------------------------------" 1>&2 + exit 1 +fi ++# END PREFIX LOCAL case "$EAPI" in 0|1|2|3|3_pre2) diff --cc bin/ebuild-helpers/fowners index 5c1ecac8b,a5a28f2fb..9815d2ea6 --- a/bin/ebuild-helpers/fowners +++ b/bin/ebuild-helpers/fowners @@@ -2,17 -2,11 +2,18 @@@ # Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh +source "${PORTAGE_BIN_PATH:-@PORTAGE_BASE@/bin}"/isolated-functions.sh + ++# PREFIX LOCAL: ignore otherwise failing call +if hasq prefix ${USE} && [[ $EUID != 0 ]] ; then + ewarn "fowners ignored in Prefix with non-privileged user" + exit 0 +fi - - # PREFIX LOCAL: always support ED - #case "$EAPI" in 0|1|2) ED=${D} ;; esac +# END PREFIX LOCAL + [[ " ${FEATURES} " == *" force-prefix "* ]] || \ + case "$EAPI" in 0|1|2) ED=${D} ;; esac + # we can't prefix all arguments because # chown takes random options slash="/" diff --cc bin/ebuild-helpers/fperms index 25f77a9b7,a2f77ea00..23b536173 --- a/bin/ebuild-helpers/fperms +++ b/bin/ebuild-helpers/fperms @@@ -2,11 -2,11 +2,11 @@@ # Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh +source "${PORTAGE_BIN_PATH:-@PORTAGE_BASE@/bin}"/isolated-functions.sh - # PREFIX LOCAL: always support ED - #case "$EAPI" in 0|1|2) ED=${D} ;; esac - # END PREFIX LOCAL + [[ " ${FEATURES} " == *" force-prefix "* ]] || \ + case "$EAPI" in 0|1|2) ED=${D} ;; esac + # we can't prefix all arguments because # chmod takes random options slash="/" diff --cc bin/ebuild-helpers/prepall index c4e9ffccd,49e646cd2..3aacb7f2a --- a/bin/ebuild-helpers/prepall +++ b/bin/ebuild-helpers/prepall @@@ -2,11 -2,10 +2,12 @@@ # Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh +source "${PORTAGE_BIN_PATH:-@PORTAGE_BASE@/bin}"/isolated-functions.sh + +[[ -d ${ED} ]] || exit 0 - case "$EAPI" in 0|1|2) ED=${D} ;; esac + [[ " ${FEATURES} " == *" force-prefix "* ]] || \ + case "$EAPI" in 0|1|2) ED=${D} ;; esac if has chflags $FEATURES ; then # Save all the file flags for restoration at the end of prepall. diff --cc bin/ebuild-helpers/prepallinfo index de52098bd,db9bbfacb..00e1fc41c --- a/bin/ebuild-helpers/prepallinfo +++ b/bin/ebuild-helpers/prepallinfo @@@ -2,11 -2,10 +2,10 @@@ # Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh +source "${PORTAGE_BIN_PATH:-@PORTAGE_BASE@/bin}"/isolated-functions.sh - # PREFIX LOCAL: always support ED - #case "$EAPI" in 0|1|2) ED=${D} ;; esac - # END PREFIX LOCAL + [[ " ${FEATURES} " == *" force-prefix "* ]] || \ + case "$EAPI" in 0|1|2) ED=${D} ;; esac [[ -d ${ED}usr/share/info ]] || exit 0 diff --cc bin/ebuild-helpers/prepinfo index c0ab9c9fb,ffe2ecec3..ffd504949 --- a/bin/ebuild-helpers/prepinfo +++ b/bin/ebuild-helpers/prepinfo @@@ -2,11 -2,10 +2,10 @@@ # Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh +source "${PORTAGE_BIN_PATH:-@PORTAGE_BASE@/bin}"/isolated-functions.sh - # PREFIX LOCAL: always support ED - #case "$EAPI" in 0|1|2) ED=${D} ;; esac - # END PREFIX LOCAL + [[ " ${FEATURES} " == *" force-prefix "* ]] || \ + case "$EAPI" in 0|1|2) ED=${D} ;; esac if [[ -z $1 ]] ; then infodir="/usr/share/info" diff --cc bin/ebuild-helpers/prepman index 2c10b26f9,f96b64147..1411499ab --- a/bin/ebuild-helpers/prepman +++ b/bin/ebuild-helpers/prepman @@@ -2,9 -2,10 +2,10 @@@ # Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh +source "${PORTAGE_BIN_PATH:-@PORTAGE_BASE@/bin}"/isolated-functions.sh - case "$EAPI" in 0|1|2) ED=${D} ;; esac + [[ " ${FEATURES} " == *" force-prefix "* ]] || \ + case "$EAPI" in 0|1|2) ED=${D} ;; esac if [[ -z $1 ]] ; then mandir="${ED}usr/share/man" diff --cc bin/ebuild-helpers/prepstrip index 927078aee,15eed8457..84e2edceb --- a/bin/ebuild-helpers/prepstrip +++ b/bin/ebuild-helpers/prepstrip @@@ -221,15 -216,6 +220,17 @@@ d strip_this=false fi ++ # PREFIX LOCAL: + # In Prefix we are usually an unprivileged user, so we can't strip + # unwritable objects. Make them temporarily writable for the + # stripping. + was_not_writable=false + if [[ ! -w ${x} ]] ; then + was_not_writable=true + chmod u+w "${x}" + fi ++ # END PREFIX LOCAL + # only split debug info for final linked objects # or kernel modules as debuginfo for intermediatary # files (think crt*.o from gcc/glibc) is useless and @@@ -248,10 -234,6 +249,12 @@@ elif [[ ${f} == *"SB relocatable"* ]] ; then process_elf "${x}" ${SAFE_STRIP_FLAGS} fi + ++ # PREFIX LOCAL: see above + if [[ ${was_not_writable} == "true" ]] ; then + chmod u-w "${x}" + fi ++ # END PREFIX LOCAL done if [[ -s ${T}/debug.sources ]] && \ diff --cc bin/ebuild.sh index 2ec34cd96,1f95adb82..751153238 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@@ -669,11 -670,11 +670,13 @@@ els declare -r $PORTAGE_READONLY_METADATA $PORTAGE_READONLY_VARS case "$EAPI" in 0|1|2) + [[ " ${FEATURES} " == *" force-prefix "* ]] && \ + declare -r ED EPREFIX EROOT ;; *) - declare -r ED EPREFIX EROOT + # PREFIX LOCAL: allow prefix vars in any EAPI + #declare -r ED EPREFIX EROOT + # PREFIX LOCAL ;; esac diff --cc bin/emerge-webrsync index c5809cce5,e6749f285..c41eb7935 --- a/bin/emerge-webrsync +++ b/bin/emerge-webrsync @@@ -39,10 -38,6 +39,11 @@@ eval $(portageq envvar -v FEATURES FETC DISTDIR="${PORTAGE_TMPDIR}/emerge-webrsync" export http_proxy ftp_proxy - # PREFIX HACK: use Prefix servers, just because we want this and infra ++# PREFIX LOCAL: use Prefix servers, just because we want this and infra +# just can't support us yet +GENTOO_MIRRORS="http://gentoo-mirror1.prefix.freens.org http://gentoo-mirror2.prefix.freens.org" ++# END PREFIX LOCAL + # If PORTAGE_NICENESS is overriden via the env then it will # still pass through the portageq call and override properly. if [ -n "${PORTAGE_NICENESS}" ]; then @@@ -183,8 -178,8 +184,10 @@@ sync_local() vecho "Syncing local tree ..." if type -P tarsync > /dev/null ; then - local chown_opts="-o portage -g portage" - chown portage:portage portage > /dev/null 2>&1 || chown_opts="" ++ # PREFIX LOCAL: use PORTAGE_USER and PORTAGE_GROUP + local chown_opts="-o ${PORTAGE_USER:-portage} -g ${PORTAGE_GROUP:-portage}" + chown ${PORTAGE_USER:-portage}:${PORTAGE_GROUP:-portage} portage > /dev/null 2>&1 || chown_opts="" ++ # END PREFIX LOCAL if ! tarsync $(vvecho -v) -s 1 ${chown_opts} \ -e /distfiles -e /packages -e /local "${file}" "${PORTDIR}"; then eecho "tarsync failed; tarball is corrupt? (${file})" @@@ -200,8 -195,8 +203,10 @@@ # Free disk space rm -f "${file}" - chown portage:portage portage > /dev/null 2>&1 && \ - chown -R portage:portage portage ++ # PREFIX LOCAL: use PORTAGE_USER and PORTAGE_GROUP + chown ${PORTAGE_USER:-portage}:${PORTAGE_GROUP:-portage} portage > /dev/null 2>&1 && \ + chown -R ${PORTAGE_USER:-portage}:${PORTAGE_GROUP:-portage} portage ++ # END PREFIX LOCAL cd portage rsync -av --progress --stats --delete --delete-after \ --exclude='/distfiles' --exclude='/packages' \ @@@ -216,7 -211,9 +221,9 @@@ vecho "Updating cache ..." emerge --metadata fi - [ -x /etc/portage/bin/post_sync ] && /etc/portage/bin/post_sync + [ -x "${EPREFIX}"/etc/portage/bin/post_sync ] && "${EPREFIX}"/etc/portage/bin/post_sync + # --quiet suppresses output if there are no relevant news items + has news ${FEATURES} && emerge --check-news --quiet return 0 } diff --cc bin/etc-update index c735076d6,731b6484e..b3877fbea --- a/bin/etc-update +++ b/bin/etc-update @@@ -555,16 -555,12 +555,12 @@@ rm -rf "${TMP}" 2> /dev/nul mkdir "${TMP}" || die "failed to create temp dir" 1 # make sure we have a secure directory to work in chmod 0700 "${TMP}" || die "failed to set perms on temp dir" 1 - # GID need not to be available, and group 0 is not cool when not being - # root, hence just rely on mkdir to have created a dir which is owned by - # the user - if [[ -z ${UID} || ${UID} == 0 ]] ; then - chown ${UID:-0}:${GID:-0} "${TMP}" || die "failed to set ownership on temp dir" 1 - fi + chown ${PORTAGE_INST_UID:-0}:${PORTAGE_INST_GID:-0} "${TMP}" || \ + die "failed to set ownership on temp dir" 1 # I need the CONFIG_PROTECT value -#CONFIG_PROTECT=$(/usr/lib/portage/bin/portageq envvar CONFIG_PROTECT) -#CONFIG_PROTECT_MASK=$(/usr/lib/portage/bin/portageq envvar CONFIG_PROTECT_MASK) +#CONFIG_PROTECT=$(@PORTAGE_BASE@/bin/portageq envvar CONFIG_PROTECT) +#CONFIG_PROTECT_MASK=$(@PORTAGE_BASE@/bin/portageq envvar CONFIG_PROTECT_MASK) # load etc-config's configuration CLEAR_TERM=$(get_config clear_term) diff --cc bin/misc-functions.sh index 20d52a79a,358288932..1e3785c54 mode 100644,100755..100644 --- a/bin/misc-functions.sh +++ b/bin/misc-functions.sh @@@ -14,15 -14,11 +14,14 @@@ MISC_FUNCTIONS_ARGS="$@" shift $# -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}/ebuild.sh" +source "${PORTAGE_BIN_PATH:-@PORTAGE_BASE@/bin}/ebuild.sh" install_symlink_html_docs() { - # PREFIX LOCAL: always support ED - #case "$EAPI" in 0|1|2) local ED=${D} ;; esac - # END PREFIX LOCAL - # PREFIX LOCAL: ED need not to exist, whereas D does - [[ ! -d ${ED} ]] && dodir / + [[ " ${FEATURES} " == *" force-prefix "* ]] || \ + case "$EAPI" in 0|1|2) local ED=${D} ;; esac ++ # PREFIX LOCAL: ED needs not to exist, whereas D does ++ [[ ! -d ${ED} && -d ${D} ]] && dodir / + # END PREFIX LOCAL cd "${ED}" || die "cd failed" #symlink the html documentation (if DOC_SYMLINKS_DIR is set in make.conf) if [ -n "${DOC_SYMLINKS_DIR}" ] ; then @@@ -154,13 -149,10 +152,12 @@@ prepcompress() install_qa_check() { local f i x - # PREFIX LOCAL: always support ED - #case "$EAPI" in 0|1|2) local ED=${D} ;; esac - # END PREFIX LOCAL + [[ " ${FEATURES} " == *" force-prefix "* ]] || \ + case "$EAPI" in 0|1|2) local ED=${D} ;; esac - cd "${ED}" || die "cd failed" + # PREFIX LOCAL: ED needs not to exist, whereas D does + cd "${D}" || die "cd failed" + # END PREFIX LOCAL export STRIP_MASK prepall @@@ -192,37 -184,6 +189,39 @@@ sleep 1 fi ++ # PREFIX LOCAL: + # anything outside the prefix should be caught by the Prefix QA + # check, so if there's nothing in ED, we skip searching for QA + # checks there, the specific QA funcs can hence rely on ED existing + if [[ -d ${ED} ]] ; then + case ${CHOST} in + *-darwin*) + # Mach-O platforms (NeXT, Darwin, OSX) + install_qa_check_macho + ;; + *-interix*|*-winnt*) + # PECOFF platforms (Windows/Interix) + install_qa_check_pecoff + ;; + *-aix*) + # XCOFF platforms (AIX) + install_qa_check_xcoff + ;; + *) + # because this is the majority: ELF platforms (Linux, + # Solaris, *BSD, IRIX, etc.) + install_qa_check_elf + ;; + esac + fi + + # this is basically here such that the diff with trunk remains just + # offsetted and not out of order + install_qa_check_misc ++ # END PREFIX LOCAL +} + +install_qa_check_elf() { if type -P scanelf > /dev/null && ! has binchecks ${RESTRICT}; then local qa_var insecure_rpath=0 tmp_quiet=${PORTAGE_QUIET} local x diff --cc bin/phase-functions.sh index 97111f525,482b5b170..75f166473 --- a/bin/phase-functions.sh +++ b/bin/phase-functions.sh @@@ -28,7 -28,7 +28,7 @@@ PORTAGE_READONLY_VARS="D EBUILD EBUILD_ PORTAGE_TMPDIR PORTAGE_UPDATE_ENV PORTAGE_USERNAME \ PORTAGE_VERBOSE PORTAGE_WORKDIR_MODE PORTDIR PORTDIR_OVERLAY \ PROFILE_PATHS REPLACING_VERSIONS REPLACED_BY_VERSION T WORKDIR \ - ED EROOT" - __PORTAGE_TEST_EPREFIX" ++ __PORTAGE_TEST_EPREFIX ED EROOT" PORTAGE_SAVED_READONLY_VARS="A CATEGORY P PF PN PR PV PVR" @@@ -558,7 -559,20 +559,24 @@@ dyn_install() fi echo "${USE}" > USE echo "${EAPI:-0}" > EAPI ++<<<<<<< HEAD + echo "${EPREFIX}" > EPREFIX ++======= + + # Save EPREFIX, since it makes it easy to use chpathtool to + # adjust the content of a binary package so that it will + # work in a different EPREFIX from the one is was built for. + case "${EAPI:-0}" in + 0|1|2) + [[ " ${FEATURES} " == *" force-prefix "* ]] && \ + [ -n "${EPREFIX}" ] && echo "${EPREFIX}" > EPREFIX + ;; + *) + [ -n "${EPREFIX}" ] && echo "${EPREFIX}" > EPREFIX + ;; + esac + ++>>>>>>> overlays-gentoo-org/master set +f # local variables can leak into the saved environment. diff --cc cnf/make.conf index 25488d380,ef570bcb4..5134188e9 --- a/cnf/make.conf +++ b/cnf/make.conf @@@ -138,20 -137,16 +137,16 @@@ # at \${DISTDIR}/\${FILE}. # # Default fetch command (3 tries, passive ftp for firewall compatibility) - #FETCHCOMMAND="@PORTAGE_EPREFIX@/usr/bin/wget -t 3 -T 60 --passive-ftp -O \"\${DISTDIR}/\${FILE}\" \"\${URI}\"" - #RESUMECOMMAND="@PORTAGE_EPREFIX@/usr/bin/wget -c -t 3 -T 60 --passive-ftp -O \"\${DISTDIR}/\${FILE}\" \"\${URI}\"" + #FETCHCOMMAND="wget -t 3 -T 60 --passive-ftp -O \"\${DISTDIR}/\${FILE}\" \"\${URI}\"" + #RESUMECOMMAND="wget -c -t 3 -T 60 --passive-ftp -O \"\${DISTDIR}/\${FILE}\" \"\${URI}\"" # # Using wget, ratelimiting downloads - #FETCHCOMMAND="@PORTAGE_EPREFIX@/usr/bin/wget -t 3 -T 60 --passive-ftp --limit-rate=200k -O \"\${DISTDIR}/\${FILE}\" \"\${URI}\"" - #RESUMECOMMAND="@PORTAGE_EPREFIX@/usr/bin/wget -c -t 3 -T 60 --passive-ftp --limit-rate=200k -O \"\${DISTDIR}/\${FILE}\" \"\${URI}\"" - # - # curl groks urls - #FETCHCOMMAND="@PORTAGE_EPREFIX@/usr/bin/curl -f --connect-timeout 15 -# -o \${DISTDIR}/\${FILE} \${URI}" - #RESUMECOMMAND="@PORTAGE_EPREFIX@/usr/bin/curl -f --connect-timeout 15 -# -C - -o \${DISTDIR}/\${FILE} \${URI}" + #FETCHCOMMAND="wget -t 3 -T 60 --passive-ftp --limit-rate=200k -O \"\${DISTDIR}/\${FILE}\" \"\${URI}\"" + #RESUMECOMMAND="wget -c -t 3 -T 60 --passive-ftp --limit-rate=200k -O \"\${DISTDIR}/\${FILE}\" \"\${URI}\"" # # Lukemftp (BSD ftp): - #FETCHCOMMAND="@PORTAGE_EPREFIX@/usr/bin/lukemftp -s -a -o \"\${DISTDIR}/\${FILE}\" \"\${URI}\"" - #RESUMECOMMAND="@PORTAGE_EPREFIX@/usr/bin/lukemftp -s -a -R -o \"\${DISTDIR}/\${FILE}\" \"\${URI}\"" -#FETCHCOMMAND="/usr/bin/lukemftp -s -a -o \"\${DISTDIR}/\${FILE}\" \"\${URI}\"" -#RESUMECOMMAND="/usr/bin/lukemftp -s -a -R -o \"\${DISTDIR}/\${FILE}\" \"\${URI}\"" ++#FETCHCOMMAND="lukemftp -s -a -o \"\${DISTDIR}/\${FILE}\" \"\${URI}\"" ++#RESUMECOMMAND="lukemftp -s -a -R -o \"\${DISTDIR}/\${FILE}\" \"\${URI}\"" # # Portage uses GENTOO_MIRRORS to specify mirrors to use for source retrieval. # The list is a space separated list which is read left to right. If you use diff --cc pym/portage/const.py index 63e7c67da,5eeebe130..336c005ce --- a/pym/portage/const.py +++ b/pym/portage/const.py @@@ -134,9 -90,8 +134,9 @@@ SUPPORTED_FEATURES = frozenset( "ccache", "chflags", "clean-logs", "collision-protect", "compress-build-logs", "digest", "distcc", "distcc-pump", "distlocks", "ebuild-locks", "fakeroot", - "fail-clean", "force-mirror", "getbinpkg", + "fail-clean", "force-mirror", "force-prefix", "getbinpkg", "installsources", "keeptemp", "keepwork", "fixlafiles", "lmirror", + "macossandbox", "macosprefixsandbox", "macosusersandbox", "metadata-transfer", "mirror", "multilib-strict", "news", "noauto", "noclean", "nodoc", "noinfo", "noman", "nostrip", "notitles", "parallel-fetch", "parallel-install", diff --cc pym/portage/data.py index 354fc9c6e,fa6970c42..e8a0a3ab0 --- a/pym/portage/data.py +++ b/pym/portage/data.py @@@ -77,71 -66,117 +75,131 @@@ try except KeyError: pass - # Allow the overriding of the user used for 'userpriv' and 'userfetch' - _portage_uname = os.environ.get('PORTAGE_USERNAME', PORTAGE_USERNAME) - _portage_grpname = os.environ.get('PORTAGE_GRPNAME', PORTAGE_GROUPNAME) - - #Discover the uid and gid of the portage user/group - try: - portage_gid = grp.getgrnam(_portage_grpname)[2] - except KeyError: - # some sysadmins are insane, bug #344307 - if _portage_grpname.isdigit(): - portage_gid = int(_portage_grpname) + # The portage_uid and portage_gid global constants, and others that + # depend on them are initialized lazily, in order to allow configuration + # via make.conf. Eventually, these constants may be deprecated in favor + # of config attributes, since it's conceivable that multiple + # configurations with different constants could be used simultaneously. + _initialized_globals = set() + + def _get_global(k): + if k in _initialized_globals: + return globals()[k] + + if k in ('portage_gid', 'portage_uid', 'secpass'): + global portage_gid, portage_uid, secpass + secpass = 0 + if uid == 0: + secpass = 2 + elif "__PORTAGE_TEST_EPREFIX" in os.environ: + secpass = 2 + #Discover the uid and gid of the portage user/group + try: - portage_uid = pwd.getpwnam(_get_global('_portage_uname'))[2] + portage_gid = grp.getgrnam(_get_global('_portage_grpname'))[2] ++ except KeyError: ++ # some sysadmins are insane, bug #344307 ++ if _get_global('_portage_grpname').isdigit(): ++ portage_gid = int(_get_global('_portage_grpname')) ++ else: ++ portage_gid = None ++ try: ++ portage_uid = pwd.getpwnam(_get_global('_portage_uname'))[2] + if secpass < 1 and portage_gid in os.getgroups(): + secpass = 1 + except KeyError: ++ portage_uid = None ++ ++ if portage_uid is None or portage_gid is None: + portage_uid = 0 + portage_gid = 0 ++ # PREFIX LOCAL: we need to fix this one day to distinguish prefix vs non-prefix ++ writemsg(colorize("BAD", ++ _("portage: '%s' user or '%s' group missing." % (_get_global('_portage_uname'), _get_global('_portage_grpname')))) + "\n", noiselevel=-1) ++ writemsg(colorize("BAD", ++ _(" In Prefix Portage this is quite dramatic")) + "\n", noiselevel=-1) + writemsg(colorize("BAD", - _("portage: 'portage' user or group missing.")) + "\n", noiselevel=-1) - writemsg(_( - " For the defaults, line 1 goes into passwd, " - "and 2 into group.\n"), noiselevel=-1) - writemsg(colorize("GOOD", - " portage:x:250:250:portage:/var/tmp/portage:/bin/false") \ - + "\n", noiselevel=-1) - writemsg(colorize("GOOD", " portage::250:portage") + "\n", - noiselevel=-1) ++ _(" since it means you have thrown away yourself.")) + "\n", noiselevel=-1) ++ writemsg(colorize("BAD", ++ _(" Re-add yourself or re-bootstrap Gentoo Prefix.")) + "\n", noiselevel=-1) ++ # END PREFIX LOCAL + portage_group_warning() + + _initialized_globals.add('portage_gid') + _initialized_globals.add('portage_uid') + _initialized_globals.add('secpass') + + if k == 'portage_gid': + return portage_gid + elif k == 'portage_uid': + return portage_uid + elif k == 'secpass': + return secpass + else: + raise AssertionError('unknown name: %s' % k) + + elif k == 'userpriv_groups': + v = [portage_gid] + if secpass >= 2: + # Get a list of group IDs for the portage user. Do not use + # grp.getgrall() since it is known to trigger spurious + # SIGPIPE problems with nss_ldap. + mystatus, myoutput = \ + portage.subprocess_getstatusoutput("id -G %s" % _portage_uname) + if mystatus == os.EX_OK: + for x in myoutput.split(): + try: + v.append(int(x)) + except ValueError: + pass + v = sorted(set(v)) + + elif k == '_portage_grpname': + env = getattr(portage, 'settings', os.environ) - v = env.get('PORTAGE_GRPNAME', 'portage') ++ # PREFIX LOCAL: use var iso hardwired 'portage' ++ v = env.get('PORTAGE_GRPNAME', PORTAGE_GROUPNAME) ++ # END PREFIX LOCAL + elif k == '_portage_uname': - env = getattr(portage, 'settings', os.environ) ++ # PREFIX LOCAL: use var iso hardwired 'portage' ++ env = getattr(portage, 'settings', PORTAGE_USERNAME) ++ # END PREFIX LOCAL + v = env.get('PORTAGE_USERNAME', 'portage') else: - portage_gid = None - try: - portage_uid = pwd.getpwnam(_portage_uname)[2] - except KeyError: - portage_uid = None - - if portage_uid is None or portage_gid is None: - portage_uid=0 - portage_gid=0 - userpriv_groups = [portage_gid] - writemsg(colorize("BAD", - "portage: "+_portage_uname+" user or "+_portage_grpname+" group missing.") + "\n", noiselevel=-1) - writemsg(colorize("BAD", - " In Prefix Portage this is quite dramatic") + "\n", noiselevel=-1) - writemsg(colorize("BAD", - " since it means you have thrown away yourself.") + "\n", noiselevel=-1) - writemsg(colorize("BAD", - " Re-add yourself or re-bootstrap Gentoo Prefix.") + "\n", noiselevel=-1) - # we need to fix this one day to distinguish prefix vs non-prefix - # _("portage: 'portage' user or group missing.")) + "\n", noiselevel=-1) - # writemsg(_( - # " For the defaults, line 1 goes into passwd, " - # "and 2 into group.\n"), noiselevel=-1) - # writemsg(colorize("GOOD", - # " portage:x:250:250:portage:/var/tmp/portage:/bin/false") \ - # + "\n", noiselevel=-1) - # writemsg(colorize("GOOD", " portage::250:portage") + "\n", - # noiselevel=-1) - portage_group_warning() - else: - if secpass < 1 and portage_gid in os.getgroups(): - secpass=1 - userpriv_groups = [portage_gid] - if secpass >= 2: - class _LazyUserprivGroups(portage.proxy.objectproxy.ObjectProxy): - def _get_target(self): - global userpriv_groups - if userpriv_groups is not self: - return userpriv_groups - userpriv_groups = _userpriv_groups - # Get a list of group IDs for the portage user. Do not use - # grp.getgrall() since it is known to trigger spurious - # SIGPIPE problems with nss_ldap. - mystatus, myoutput = \ - portage.subprocess_getstatusoutput("id -G %s" % _portage_uname) - if mystatus == os.EX_OK: - for x in myoutput.split(): - try: - userpriv_groups.append(int(x)) - except ValueError: - pass - userpriv_groups[:] = sorted(set(userpriv_groups)) - return userpriv_groups - - _userpriv_groups = userpriv_groups - userpriv_groups = _LazyUserprivGroups() + raise AssertionError('unknown name: %s' % k) + + globals()[k] = v + _initialized_globals.add(k) + return v + + class _GlobalProxy(portage.proxy.objectproxy.ObjectProxy): + + __slots__ = ('_name',) + + def __init__(self, name): + portage.proxy.objectproxy.ObjectProxy.__init__(self) + object.__setattr__(self, '_name', name) + + def _get_target(self): + return _get_global(object.__getattribute__(self, '_name')) + + for k in ('portage_gid', 'portage_uid', 'secpass', 'userpriv_groups', + '_portage_grpname', '_portage_uname'): + globals()[k] = _GlobalProxy(k) + del k + + def _init(settings): + """ + Use config variables like PORTAGE_GRPNAME and PORTAGE_USERNAME to + initialize global variables. This allows settings to come from make.conf + instead of requiring them to be set in the calling environment. + """ + if '_portage_grpname' not in _initialized_globals: + v = settings.get('PORTAGE_GRPNAME') + if v is not None: + globals()['_portage_grpname'] = v + _initialized_globals.add('_portage_grpname') + + if '_portage_uname' not in _initialized_globals: + v = settings.get('PORTAGE_USERNAME') + if v is not None: + globals()['_portage_uname'] = v + _initialized_globals.add('_portage_uname') diff --cc pym/portage/dispatch_conf.py index d35be0a7a,abd3ac141..bfd6517b2 --- a/pym/portage/dispatch_conf.py +++ b/pym/portage/dispatch_conf.py @@@ -13,7 -13,7 +13,8 @@@ import os, sys, shuti import portage from portage.env.loaders import KeyValuePairFileLoader from portage.localization import _ + from portage.util import varexpand +from portage.const import EPREFIX RCS_BRANCH = '1.1.1' RCS_LOCK = 'rcs -ko -M -l' @@@ -39,11 -39,12 +40,12 @@@ def diffstatusoutput_len(cmd) return (1, 1) def read_config(mandatory_opts): - loader = KeyValuePairFileLoader( - EPREFIX + '/etc/dispatch-conf.conf', None) - eprefix = os.environ.get("__PORTAGE_TEST_EPREFIX", "/") ++ eprefix = os.environ.get("__PORTAGE_TEST_EPREFIX", EPREFIX) + config_path = os.path.join(eprefix, "etc/dispatch-conf.conf") + loader = KeyValuePairFileLoader(config_path, None) opts, errors = loader.load() if not opts: - print(_('dispatch-conf: Error reading %s/etc/dispatch-conf.conf; fatal') % (EPREFIX,), file=sys.stderr) - print(_('dispatch-conf: Error reading /etc/dispatch-conf.conf; fatal'), file=sys.stderr) ++ print(_('dispatch-conf: Error reading %s/etc/dispatch-conf.conf; fatal') % (eprefix,), file=sys.stderr) sys.exit(1) # Handle quote removal here, since KeyValuePairFileLoader doesn't do that. diff --cc pym/portage/package/ebuild/_config/special_env_vars.py index b729c6a63,9ac37fb85..d07f68b35 --- a/pym/portage/package/ebuild/_config/special_env_vars.py +++ b/pym/portage/package/ebuild/_config/special_env_vars.py @@@ -66,9 -66,7 +66,9 @@@ environ_whitelist += "REPLACING_VERSIONS", "REPLACED_BY_VERSION", "ROOT", "ROOTPATH", "T", "TMP", "TMPDIR", "USE_EXPAND", "USE_ORDER", "WORKDIR", - "XARGS", + "XARGS", "__PORTAGE_TEST_EPREFIX", + "BPREFIX", "DEFAULT_PATH", "EXTRA_PATH", + "PORTAGE_GROUP", "PORTAGE_USER", ] # user config variables