# are no longer needed after src_install(). Don't cleanse from
# the global environment though, in case the user wants to repeat
# this phase (like with FEATURES=noauto and the ebuild command).
- unset S
-
- save_ebuild_env > environment
+ unset S _E_DOCDESTTREE_ _E_EXEDESTTREE_
+ save_ebuild_env | filter_readonly_variables --filter-sandbox > environment
)
bzip2 -f9 environment
PORTAGE_BIN_PATH PORTAGE_PYM_PATH PORTAGE_TMPDIR T WORKDIR"
# @FUNCTION: filter_readonly_variables
-# @DESCRIPTION:
+# @DESCRIPTION: [--filter-sandbox]
# Read an environment from stdin and echo to stdout while filtering readonly
# variables.
#
+# --filter-sandbox causes all SANDBOX_* variables to be filtered, which
+# is only desired in certain cases, such as during preprocessing or when
+# saving environment.bz2 for a binary or installed package.
+#
# In bash-3.2_p20+ an attempt to assign BASH_*, FUNCNAME, GROUPS or any
# readonly variable cause the shell to exit while executing the "source"
# builtin command. To avoid this problem, this function filters those
# variables out and discards them. See bug #190128.
filter_readonly_variables() {
- local x var_grep=""
- for x in BASH SANDBOX ; do
- var_grep="${var_grep}|(^|^declare[[:space:]]+-[^[:space:]]+[[:space:]]+)${x}_[_[:alnum:]]*=.*"
- done
+ local x filtered_vars var_grep
local readonly_bash_vars="DIRSTACK EUID FUNCNAME GROUPS
PIPESTATUS PPID SHELLOPTS UID"
- for x in ${readonly_bash_vars} ${READONLY_PORTAGE_VARS} ; do
- var_grep="${var_grep}|(^|^declare[[:space:]]+-[^[:space:]]+[[:space:]]+)${x}=.*"
+ local filtered_sandbox_vars="SANDBOX_ACTIVE SANDBOX_BASHRC
+ SANDBOX_DEBUG_LOG SANDBOX_DISABLED SANDBOX_LIB
+ SANDBOX_LOG"
+ filtered_vars="${readonly_bash_vars} ${READONLY_PORTAGE_VARS}
+ BASH_[_[:alnum:]]*"
+ if hasq --filter-sandbox $* ; then
+ filtered_vars="${filtered_vars} SANDBOX_[_[:alnum:]]*"
+ else
+ filtered_vars="${filtered_vars} ${filtered_sandbox_vars}"
+ fi
+ set -f
+ for x in ${filtered_vars} ; do
+ var_grep="${var_grep}|${x}"
done
+ set +f
var_grep=${var_grep:1} # strip the first |
+ var_grep="(^|^declare[[:space:]]+-[^[:space:]]+[[:space:]]+)(${var_grep})=.*"
# The sed is to remove the readonly attribute from variables such as those
# listed in READONLY_EBUILD_METADATA, since having any readonly attributes
# persisting in the saved environment can be inconvenient when it
# interfering with the current environment. This is useful when an existing
# environment needs to be loaded from a binary or installed package.
preprocess_ebuild_env() {
- filter_readonly_variables < "${T}"/environment > "${T}"/environment.filtered
+ filter_readonly_variables --filter-sandbox < "${T}"/environment \
+ > "${T}"/environment.filtered
mv "${T}"/environment.filtered "${T}"/environment
(
source "${T}"/environment
# Rely on save_ebuild_env() to filter out any remaining variables
# and functions that could interfere with the current environment.
- save_ebuild_env > "${T}"/environment
+ save_ebuild_env | filter_readonly_variables > "${T}"/environment
)
}
set
export
- ) | filter_readonly_variables
+ )
}
# === === === === === === === === === === === === === === === === === ===
# always preprocess the environment when ${PN} == portage.
preprocess_ebuild_env
fi
+ # Colon separated SANDBOX_* variables need to be cumulative.
+ for x in SANDBOX_DENY SANDBOX_READ SANDBOX_PREDICT SANDBOX_WRITE ; do
+ eval PORTAGE_${x}=\${!x}
+ done
source "${T}"/environment
+ for x in SANDBOX_DENY SANDBOX_PREDICT SANDBOX_READ SANDBOX_WRITE ; do
+ eval y=\${PORTAGE_${x}}
+ if [ "${y}" != "${!x}" ] ; then
+ eval export ${x}=\"$(echo -n "${y}:${!x}" | tr ":" "\0" | \
+ sort -z -u | tr "\0" ":")\"
+ fi
+ unset PORTAGE_${x}
+ done
+ unset x y
source_all_bashrcs
else
! hasq ${EBUILD_SH_ARGS} clean help info; then
# Save current environment and touch a success file. (echo for success)
umask 002
- save_ebuild_env > "${T}/environment"
+ save_ebuild_env | filter_readonly_variables > "${T}/environment"
chown ${PORTAGE_USER:-portage}:${PORTAGE_GROUP:-portage} "${T}/environment" &>/dev/null
chmod g+w "${T}/environment" &>/dev/null
fi
mypkg = myfile[:-5]
if not mycat or not mypf or not slot:
#old-style or corrupt package
- writemsg("!!! Invalid binary package: '%s'\n" % full_path,
- noiselevel=-1)
- writemsg("!!! This binary package is not " + \
- "recoverable and should be deleted.\n",
+ writemsg("\n!!! Invalid binary package: '%s'\n" % full_path,
noiselevel=-1)
+ missing_keys = []
+ if not mycat:
+ missing_keys.append("CATEGORY")
+ if not mypf:
+ missing_keys.append("PF")
+ if not slot:
+ missing_keys.append("SLOT")
+ msg = []
+ if missing_keys:
+ missing_keys.sort()
+ msg.append("Missing metadata key(s): %s." % \
+ ", ".join(missing_keys))
+ msg.append(" This binary package is not " + \
+ "recoverable and should be deleted.")
+ from textwrap import wrap
+ for line in wrap("".join(msg), 72):
+ writemsg("!!! %s\n" % line, noiselevel=-1)
self.invalids.append(mypkg)
continue
mycat = mycat.strip()