From: Fabian Groffen Date: Fri, 18 Dec 2009 08:32:44 +0000 (-0000) Subject: Merged from trunk -r15057:15110 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=162c609f62098bbc4d917d7a2661ea47d78fb291;p=portage.git Merged from trunk -r15057:15110 | 15058 | Bug #296554 - Add decompression support to ecompress | | zmedico | (similar to ecompressdir behavior) since dodoc can call | | | ecompress with stuff that's already compressed in some way. | | 15059 | Combine 2 shift calls into one. | | zmedico | | | 15096 | Bug #296870 - Allow locale related LANG and LC_* variables | | zmedico | to persist between ebuild phases, and only filter them for | | | binary and installed packages. | | 15097 | Warn if /proc is not mounted. | | zmedico | | | 15098 | Bug #296710 - Add equery to QA_INTERCEPTORS since it can | | zmedico | trigger a fork bomb. | | 15099 | Fix typo. | | arfrever | | | 15100 | Bug #286497 - Make setexec() warn/nonfatal in permissive | | zmedico | mode. Thanks to Chris PeBenito for | | | this patch. | | 15106 | Convert bytes to unicode for exception messages. | | zmedico | | | 15108 | Use portage.writemsg for lazy portage.util import. | | zmedico | | svn path=/main/branches/prefix/; revision=15118 --- diff --git a/bin/ebuild-helpers/ecompress b/bin/ebuild-helpers/ecompress index 396fc5664..d6e3519d0 100755 --- a/bin/ebuild-helpers/ecompress +++ b/bin/ebuild-helpers/ecompress @@ -20,6 +20,53 @@ if [[ ${PORTAGE_COMPRESS_FLAGS+set} != "set" ]] ; then 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 @@ -63,6 +110,15 @@ case $1 in 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 diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 97fb2e20d..80392d57a 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -1641,6 +1641,12 @@ PORTAGE_MUTABLE_FILTERED_VARS="AA HOSTNAME" # 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}. # @@ -1669,6 +1675,11 @@ filter_readonly_variables() { 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} @@ -1694,7 +1705,7 @@ preprocess_ebuild_env() { # 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 $? @@ -1752,7 +1763,7 @@ unset E_IUSE E_DEPEND E_RDEPEND E_PDEPEND 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 diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh index 79b81074d..841fa5c96 100755 --- a/bin/isolated-functions.sh +++ b/bin/isolated-functions.sh @@ -514,11 +514,6 @@ save_ebuild_env() { 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_*} diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py index 055ce4d37..a6820589a 100644 --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@ -1131,6 +1131,16 @@ def profile_check(trees, myaction): 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() @@ -1194,6 +1204,7 @@ def emerge_main(): repo_name_check(trees) repo_name_duplicate_check(trees) config_protect_check(trees) + check_procfs() for mytrees in trees.values(): mydb = mytrees["porttree"].dbapi diff --git a/pym/portage/_selinux.py b/pym/portage/_selinux.py index d013fa969..594e47ad5 100644 --- a/pym/portage/_selinux.py +++ b/pym/portage/_selinux.py @@ -7,7 +7,9 @@ import os import shutil +import portage from portage import _encodings +from portage import _unicode_decode from portage import _unicode_encode from portage.localization import _ @@ -19,6 +21,7 @@ def copyfile(src, dest): 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) @@ -39,6 +42,8 @@ def mkdir(target, refdir): 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) @@ -54,6 +59,7 @@ def rename(src, dest): 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) @@ -70,12 +76,21 @@ def settype(newtype): 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) @@ -100,6 +115,8 @@ def symlink(target, link, reflnk): 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)