from portage import os
from portage import dispatch_conf
from portage import _unicode_decode
- from portage.dispatch_conf import diffstatusoutput_len
+ from portage.dispatch_conf import diffstatusoutput
from portage.process import find_binary
+from portage.const import EPREFIX
FIND_EXTANT_CONFIGS = "find '%s' %s -name '._cfg????_%s' ! -name '.*~' ! -iname '.*.bak' -print"
DIFF_CONTENTS = "diff -Nu '%s' '%s'"
-#!/bin/bash
+#!@PORTAGE_BASH@
- # Copyright 1999-2011 Gentoo Foundation
+ # Copyright 1999-2012 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 [[ $# -ne 2 ]] ; then
helpers_die "${0##*/}: two arguments needed"
-#!/bin/bash
+#!@PORTAGE_BASH@
- # Copyright 1999-2011 Gentoo Foundation
+ # Copyright 1999-2012 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
- # END PREFIX LOCAL
[[ " ${FEATURES} " == *" force-prefix "* ]] || \
- case "$EAPI" in 0|1|2) ED=${D} ;; esac
+ case "$EAPI" in 0|1|2) EPREFIX= ED=${D} ;; esac
# we can't prefix all arguments because
# chown takes random options
eecho "could not find 'portageq'; aborting"
exit 1
fi
- eval $(portageq envvar -v FEATURES FETCHCOMMAND GENTOO_MIRRORS \
+ eval $("${portageq}" envvar -v FEATURES FETCHCOMMAND GENTOO_MIRRORS \
PORTAGE_BIN_PATH PORTAGE_GPG_DIR \
PORTAGE_NICENESS PORTAGE_RSYNC_EXTRA_OPTS PORTAGE_TMPDIR PORTDIR \
- SYNC http_proxy ftp_proxy)
+ SYNC http_proxy ftp_proxy \
+ EPREFIX PORTAGE_USER PORTAGE_GROUP)
DISTDIR="${PORTAGE_TMPDIR}/emerge-webrsync"
export http_proxy ftp_proxy
-#!/bin/bash
+#!@PORTAGE_BASH@
- # Copyright 1999-2011 Gentoo Foundation
+ # Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# Author Brandon Low <lostlogic@gentoo.org>
-#!/usr/bin/python -O
+#!@PREFIX_PORTAGE_PYTHON@ -O
- # Copyright 1999-2011 Gentoo Foundation
+ # Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# Next to do: dep syntax checking in mask files
'portage.news:count_unread_news,display_news_notifications',
)
+ from portage.localization import _
from portage import os
from portage import shutil
- from portage import subprocess_getstatusoutput
from portage import _unicode_decode
from portage.cache.cache_errors import CacheError
-from portage.const import GLOBAL_CONFIG_PATH
+from portage.const import GLOBAL_CONFIG_PATH, EPREFIX
from portage.const import _ENABLE_DYN_LINK_MAP, _ENABLE_SET_CONFIG
from portage.dbapi.dep_expand import dep_expand
from portage.dbapi._expand_new_virt import expand_new_virt
raise
del e
processed_count += 1
- try:
- proc = subprocess.Popen(
- ['/usr/bin/install-info',
- '--dir-file=%s' % os.path.join(inforoot, "dir"),
- os.path.join(inforoot, x)],
- env=dict(os.environ, LANG="C", LANGUAGE="C"),
- stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- except OSError:
- myso = None
- else:
- myso = _unicode_decode(
- proc.communicate()[0]).rstrip("\n")
- proc.wait()
+ myso = portage.subprocess_getstatusoutput(
+ "LANG=C LANGUAGE=C %s/usr/bin/install-info " \
+ "--dir-file=%s/dir %s/%s" % (EPREFIX, inforoot, inforoot, x))[1]
existsstr="already exists, for file `"
- if myso!="":
+ if myso:
if re.search(existsstr,myso):
# Already exists... Don't increment the count for this.
pass
DIFF3_MERGE = "diff3 -mE '%s' '%s' '%s' > '%s'"
- def diffstatusoutput_len(cmd):
+ def diffstatusoutput(cmd, file1, file2):
"""
Execute the string cmd in a shell with getstatusoutput() and return a
- 2-tuple (status, output_length). If getstatusoutput() raises
- UnicodeDecodeError (known to happen with python3.1), return a
- 2-tuple (1, 1). This provides a simple way to check for non-zero
- output length of diff commands, while providing simple handling of
- UnicodeDecodeError when necessary.
+ 2-tuple (status, output).
"""
- try:
- status, output = portage.subprocess_getstatusoutput(cmd)
- return (status, len(output))
- except UnicodeDecodeError:
- return (1, 1)
+ # Use Popen to emulate getstatusoutput(), since getstatusoutput() may
+ # raise a UnicodeDecodeError which makes the output inaccessible.
+ proc = subprocess.Popen(portage._unicode_encode(cmd % (file1, file2)),
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
+ output = portage._unicode_decode(proc.communicate()[0])
+ if output and output[-1] == "\n":
+ # getstatusoutput strips one newline
+ output = output[:-1]
+ return (proc.wait(), output)
def read_config(mandatory_opts):
- eprefix = portage.const.EPREFIX
+ eprefix = EPREFIX
config_path = os.path.join(eprefix or os.sep, "etc/dispatch-conf.conf")
loader = KeyValuePairFileLoader(config_path, None)
opts, errors = loader.load()