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:
-#!/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"
# 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=$?
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)
# 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="/"
# 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="/"
# 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.
# 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
# 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"
# 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"
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
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 ]] && \
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
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
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})"
# 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' \
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
}
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)
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
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
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
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"
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.
# 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
"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",
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')
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'
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.
"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