esac
fi
+# decompress_args(suffix, binary)
+# - suffix: the compression suffix to work with
+# - binary: the program to execute that'll compress/decompress
+# new_args: global array used to return revised arguments
+decompress_args() {
+ local suffix=$1 binary=$2
+ shift 2
+
+ # Initialize the global new_args array.
+ new_args=()
+ declare -a decompress_args=()
+ local x i=0 decompress_count=0
+ for x in "$@" ; do
+ if [[ ${x%$suffix} = $x ]] ; then
+ new_args[$i]=$x
+ else
+ new_args[$i]=${x%$suffix}
+ decompress_args[$decompress_count]=$x
+ ((decompress_count++))
+ fi
+ ((i++))
+ done
+
+ if [ $decompress_count -gt 0 ] ; then
+ ${binary} "${decompress_args[@]}"
+ if [ $? -ne 0 ] ; then
+ # Apparently decompression failed for one or more files, so
+ # drop those since we don't want to compress them twice.
+ new_args=()
+ local x i=0
+ for x in "$@" ; do
+ if [[ ${x%$suffix} = $x ]] ; then
+ new_args[$i]=$x
+ ((i++))
+ elif [[ -f ${x%$suffix} ]] ; then
+ new_args[$i]=${x%$suffix}
+ ((i++))
+ else
+ # Apparently decompression failed for this one, so drop
+ # it since we don't want to compress it twice.
+ true
+ fi
+ done
+ fi
+ fi
+}
+
case $1 in
--suffix)
[[ -n $2 ]] && vecho "${0##*/}: --suffix takes no additional arguments" 1>&2
exit 1
;;
*)
+ # Since dodoc calls ecompress on files that are already compressed,
+ # perform decompression here (similar to ecompressdir behavior).
+ decompress_args ".Z" "gunzip -f" "$@"
+ set -- "${new_args[@]}"
+ decompress_args ".gz" "gunzip -f" "$@"
+ set -- "${new_args[@]}"
+ decompress_args ".bz2" "bunzip2 -f" "$@"
+ set -- "${new_args[@]}"
+
mask_ext_re=""
set -f
for x in $PORTAGE_COMPRESS_EXCLUDE_SUFFIXES ; do
# phase. However, if FEATURES exist inside environment.bz2 then they
# should be overridden by current settings.
#
+# --filter-locale causes locale related variables such as LANG and LC_*
+# variables to be filtered. These variables should persist between phases,
+# in case they are modified by the ebuild. However, the current user
+# settings should be used when loading the environment from a binary or
+# installed package.
+#
# ---allow-extra-vars causes some extra vars to be allowd through, such
# as ${PORTAGE_SAVED_READONLY_VARS} and ${PORTAGE_MUTABLE_FILTERED_VARS}.
#
if hasq --filter-features $* ; then
filtered_vars="${filtered_vars} FEATURES"
fi
+ if hasq --filter-locale $* ; then
+ filtered_vars+=" LANG LC_ALL LC_COLLATE
+ LC_CTYPE LC_MESSAGES LC_MONETARY
+ LC_NUMERIC LC_PAPER LC_TIME"
+ fi
if ! hasq --allow-extra-vars $* ; then
filtered_vars="
${filtered_vars}
# environment may contain stale SANDBOX_{DENY,PREDICT,READ,WRITE}
# and FEATURES variables that should be filtered out. Between
# phases, these variables are normally preserved.
- filter_opts="--filter-sandbox --filter-features ${filter_opts}"
+ filter_opts+=" --filter-sandbox --filter-features --filter-locale"
fi
filter_readonly_variables ${filter_opts} < "${T}"/environment \
> "${T}"/environment.filtered || return $?
shopt -u extglob
if [[ ${EBUILD_PHASE} == depend ]] ; then
- QA_INTERCEPTORS="awk bash cc egrep fgrep g++
+ QA_INTERCEPTORS="awk bash cc egrep equery fgrep g++
gawk gcc grep javac java-config nawk perl
pkg-config python python-config sed"
elif [[ ${EBUILD_PHASE} == clean* ]] ; then
unset ECHANGELOG_USER GPG_AGENT_INFO \
SSH_AGENT_PID SSH_AUTH_SOCK STY WINDOW XAUTHORITY
- # localization settings
- unset LANG LC_COLLATE LC_CTYPE LC_MESSAGES \
- LC_MONETARY LC_NUMERIC LC_TIME LC_PAPER \
- LC_ALL
-
# CCACHE and DISTCC config
unset ${!CCACHE_*} ${!DISTCC_*}
return 1
return os.EX_OK
+def check_procfs():
+ procfs_path = '/proc'
+ if platform.system() not in ("Linux",) or \
+ os.path.ismount(procfs_path):
+ return os.EX_OK
+ msg = "It seems that %s is not mounted. You have been warned." % procfs_path
+ writemsg_level("".join("!!! %s\n" % l for l in textwrap.wrap(msg, 70)),
+ level=logging.ERROR, noiselevel=-1)
+ return 1
+
def emerge_main():
global portage # NFC why this is necessary now - genone
portage._disable_legacy_globals()
repo_name_check(trees)
repo_name_duplicate_check(trees)
config_protect_check(trees)
+ check_procfs()
for mytrees in trees.values():
mydb = mytrees["porttree"].dbapi
import os
import shutil
+import portage
from portage import _encodings
+from portage import _unicode_decode
from portage import _unicode_encode
from portage.localization import _
dest = _unicode_encode(dest, encoding=_encodings['fs'], errors='strict')
(rc, ctx) = selinux.lgetfilecon(src)
if rc < 0:
+ src = _unicode_decode(src, encoding=_encodings['fs'], errors='replace')
raise OSError(_("copyfile: Failed getting context of \"%s\".") % src)
setfscreate(ctx)
refdir = _unicode_encode(refdir, encoding=_encodings['fs'], errors='strict')
(rc, ctx) = selinux.getfilecon(refdir)
if rc < 0:
+ refdir = _unicode_decode(refdir, encoding=_encodings['fs'],
+ errors='replace')
raise OSError(
_("mkdir: Failed getting context of reference directory \"%s\".") \
% refdir)
dest = _unicode_encode(dest, encoding=_encodings['fs'], errors='strict')
(rc, ctx) = selinux.lgetfilecon(src)
if rc < 0:
+ src = _unicode_decode(src, encoding=_encodings['fs'], errors='replace')
raise OSError(_("rename: Failed getting context of \"%s\".") % src)
setfscreate(ctx)
def setexec(ctx="\n"):
ctx = _unicode_encode(ctx, encoding=_encodings['content'], errors='strict')
if selinux.setexeccon(ctx) < 0:
- raise OSError(_("setexec: Failed setting exec() context \"%s\".") % ctx)
+ ctx = _unicode_decode(ctx, encoding=_encodings['content'],
+ errors='replace')
+ if selinux.security_getenforce() == 1:
+ raise OSError(_("Failed setting exec() context \"%s\".") % ctx)
+ else:
+ portage.writemsg("!!! " + \
+ _("Failed setting exec() context \"%s\".") % ctx, \
+ noiselevel=-1)
def setfscreate(ctx="\n"):
ctx = _unicode_encode(ctx,
encoding=_encodings['content'], errors='strict')
if selinux.setfscreatecon(ctx) < 0:
+ ctx = _unicode_decode(ctx,
+ encoding=_encodings['content'], errors='replace')
raise OSError(
_("setfscreate: Failed setting fs create context \"%s\".") % ctx)
reflnk = _unicode_encode(reflnk, encoding=_encodings['fs'], errors='strict')
(rc, ctx) = selinux.lgetfilecon(reflnk)
if rc < 0:
+ reflnk = _unicode_decode(reflnk, encoding=_encodings['fs'],
+ errors='replace')
raise OSError(
_("symlink: Failed getting context of reference symlink \"%s\".") \
% reflnk)