# it is saved or loaded (any mutations do not persist).
PORTAGE_MUTABLE_FILTERED_VARS="AA HOSTNAME"
-# @FUNCTION: filter_readonly_variables
+# @FUNCTION: __filter_readonly_variables
# @DESCRIPTION: [--filter-sandbox] [--allow-extra-vars]
# Read an environment from stdin and echo to stdout while filtering variables
# with names that are known to cause interference:
# 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() {
+__filter_readonly_variables() {
local x filtered_vars
local readonly_bash_vars="BASHOPTS BASHPID DIRSTACK EUID
FUNCNAME GROUPS PIPESTATUS PPID SHELLOPTS UID"
"${PORTAGE_PYTHON:-/usr/bin/python}" "${PORTAGE_BIN_PATH}"/filter-bash-environment.py "${filtered_vars}" || die "filter-bash-environment.py failed"
}
-# @FUNCTION: preprocess_ebuild_env
+# @FUNCTION: __preprocess_ebuild_env
# @DESCRIPTION:
# Filter any readonly variables from ${T}/environment, source it, and then
# save it via save_ebuild_env(). This process should be sufficient to prevent
# any stale variables or functions from an arbitrary environment from
# 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() {
+__preprocess_ebuild_env() {
local _portage_filter_opts="--filter-features --filter-locale --filter-path --filter-sandbox"
# If environment.raw is present, this is a signal from the python side,
# Otherwise, we don't need to filter the environment.
[ -f "${T}/environment.raw" ] || return 0
- filter_readonly_variables $_portage_filter_opts < "${T}"/environment \
+ __filter_readonly_variables $_portage_filter_opts < "${T}"/environment \
>> "$T/environment.filtered" || return $?
unset _portage_filter_opts
mv "${T}"/environment.filtered "${T}"/environment || return $?
) > "${T}/environment.filtered"
local retval
if [ -e "${T}/environment.success" ] ; then
- filter_readonly_variables --filter-features < \
+ __filter_readonly_variables --filter-features < \
"${T}/environment.filtered" > "${T}/environment"
retval=$?
else
return ${retval}
}
-ebuild_phase() {
+__ebuild_phase() {
declare -F "$1" >/dev/null && qa_call $1
}
-ebuild_phase_with_hooks() {
+__ebuild_phase_with_hooks() {
local x phase_name=${1}
for x in {pre_,,post_}${phase_name} ; do
- ebuild_phase ${x}
+ __ebuild_phase ${x}
done
}
-dyn_pretend() {
+__dyn_pretend() {
if [[ -e $PORTAGE_BUILDDIR/.pretended ]] ; then
__vecho ">>> It appears that '$PF' is already pretended; skipping."
__vecho ">>> Remove '$PORTAGE_BUILDDIR/.pretended' to force pretend."
return 0
fi
- ebuild_phase pre_pkg_pretend
- ebuild_phase pkg_pretend
+ __ebuild_phase pre_pkg_pretend
+ __ebuild_phase pkg_pretend
>> "$PORTAGE_BUILDDIR/.pretended" || \
die "Failed to create $PORTAGE_BUILDDIR/.pretended"
- ebuild_phase post_pkg_pretend
+ __ebuild_phase post_pkg_pretend
}
-dyn_setup() {
+__dyn_setup() {
if [[ -e $PORTAGE_BUILDDIR/.setuped ]] ; then
__vecho ">>> It appears that '$PF' is already setup; skipping."
__vecho ">>> Remove '$PORTAGE_BUILDDIR/.setuped' to force setup."
return 0
fi
- ebuild_phase pre_pkg_setup
- ebuild_phase pkg_setup
+ __ebuild_phase pre_pkg_setup
+ __ebuild_phase pkg_setup
>> "$PORTAGE_BUILDDIR/.setuped" || \
die "Failed to create $PORTAGE_BUILDDIR/.setuped"
- ebuild_phase post_pkg_setup
+ __ebuild_phase post_pkg_setup
}
-dyn_unpack() {
+__dyn_unpack() {
if [[ -f ${PORTAGE_BUILDDIR}/.unpacked ]] ; then
__vecho ">>> WORKDIR is up-to-date, keeping..."
return 0
install -m${PORTAGE_WORKDIR_MODE:-0700} -d "${WORKDIR}" || die "Failed to create dir '${WORKDIR}'"
fi
cd "${WORKDIR}" || die "Directory change failed: \`cd '${WORKDIR}'\`"
- ebuild_phase pre_src_unpack
+ __ebuild_phase pre_src_unpack
__vecho ">>> Unpacking source..."
- ebuild_phase src_unpack
+ __ebuild_phase src_unpack
>> "$PORTAGE_BUILDDIR/.unpacked" || \
die "Failed to create $PORTAGE_BUILDDIR/.unpacked"
__vecho ">>> Source unpacked in ${WORKDIR}"
- ebuild_phase post_src_unpack
+ __ebuild_phase post_src_unpack
}
-dyn_clean() {
+__dyn_clean() {
if [ -z "${PORTAGE_BUILDDIR}" ]; then
echo "Aborting clean phase because PORTAGE_BUILDDIR is unset!"
return 1
true
}
-abort_handler() {
+__abort_handler() {
local msg
if [ "$2" != "fail" ]; then
msg="${EBUILD}: ${1} aborted; exiting."
trap - SIGINT SIGQUIT
}
-abort_prepare() {
- abort_handler src_prepare $1
+__abort_prepare() {
+ __abort_handler src_prepare $1
rm -f "$PORTAGE_BUILDDIR/.prepared"
exit 1
}
-abort_configure() {
- abort_handler src_configure $1
+__abort_configure() {
+ __abort_handler src_configure $1
rm -f "$PORTAGE_BUILDDIR/.configured"
exit 1
}
-abort_compile() {
- abort_handler "src_compile" $1
+__abort_compile() {
+ __abort_handler "src_compile" $1
rm -f "${PORTAGE_BUILDDIR}/.compiled"
exit 1
}
-abort_test() {
- abort_handler "dyn_test" $1
+__abort_test() {
+ __abort_handler "__dyn_test" $1
rm -f "${PORTAGE_BUILDDIR}/.tested"
exit 1
}
-abort_install() {
- abort_handler "src_install" $1
+__abort_install() {
+ __abort_handler "src_install" $1
rm -rf "${PORTAGE_BUILDDIR}/image"
exit 1
}
-has_phase_defined_up_to() {
+__has_phase_defined_up_to() {
local phase
for phase in unpack prepare configure compile install; do
has ${phase} ${DEFINED_PHASES} && return 0
return 1
}
-dyn_prepare() {
+__dyn_prepare() {
if [[ -e $PORTAGE_BUILDDIR/.prepared ]] ; then
__vecho ">>> It appears that '$PF' is already prepared; skipping."
cd "${S}"
elif has $EAPI 0 1 2 3 ; then
cd "${WORKDIR}"
- elif [[ -z ${A} ]] && ! has_phase_defined_up_to prepare; then
+ elif [[ -z ${A} ]] && ! __has_phase_defined_up_to prepare; then
cd "${WORKDIR}"
else
die "The source directory '${S}' doesn't exist"
fi
- trap abort_prepare SIGINT SIGQUIT
+ trap __abort_prepare SIGINT SIGQUIT
- ebuild_phase pre_src_prepare
+ __ebuild_phase pre_src_prepare
__vecho ">>> Preparing source in $PWD ..."
- ebuild_phase src_prepare
+ __ebuild_phase src_prepare
>> "$PORTAGE_BUILDDIR/.prepared" || \
die "Failed to create $PORTAGE_BUILDDIR/.prepared"
__vecho ">>> Source prepared."
- ebuild_phase post_src_prepare
+ __ebuild_phase post_src_prepare
trap - SIGINT SIGQUIT
}
-dyn_configure() {
+__dyn_configure() {
if [[ -e $PORTAGE_BUILDDIR/.configured ]] ; then
__vecho ">>> It appears that '$PF' is already configured; skipping."
cd "${S}"
elif has $EAPI 0 1 2 3 ; then
cd "${WORKDIR}"
- elif [[ -z ${A} ]] && ! has_phase_defined_up_to configure; then
+ elif [[ -z ${A} ]] && ! __has_phase_defined_up_to configure; then
cd "${WORKDIR}"
else
die "The source directory '${S}' doesn't exist"
fi
- trap abort_configure SIGINT SIGQUIT
+ trap __abort_configure SIGINT SIGQUIT
- ebuild_phase pre_src_configure
+ __ebuild_phase pre_src_configure
__vecho ">>> Configuring source in $PWD ..."
- ebuild_phase src_configure
+ __ebuild_phase src_configure
>> "$PORTAGE_BUILDDIR/.configured" || \
die "Failed to create $PORTAGE_BUILDDIR/.configured"
__vecho ">>> Source configured."
- ebuild_phase post_src_configure
+ __ebuild_phase post_src_configure
trap - SIGINT SIGQUIT
}
-dyn_compile() {
+__dyn_compile() {
if [[ -e $PORTAGE_BUILDDIR/.compiled ]] ; then
__vecho ">>> It appears that '${PF}' is already compiled; skipping."
cd "${S}"
elif has $EAPI 0 1 2 3 ; then
cd "${WORKDIR}"
- elif [[ -z ${A} ]] && ! has_phase_defined_up_to compile; then
+ elif [[ -z ${A} ]] && ! __has_phase_defined_up_to compile; then
cd "${WORKDIR}"
else
die "The source directory '${S}' doesn't exist"
fi
- trap abort_compile SIGINT SIGQUIT
+ trap __abort_compile SIGINT SIGQUIT
if has distcc $FEATURES && has distcc-pump $FEATURES ; then
if [[ -z $INCLUDE_SERVER_PORT ]] || [[ ! -w $INCLUDE_SERVER_PORT ]] ; then
fi
fi
- ebuild_phase pre_src_compile
+ __ebuild_phase pre_src_compile
__vecho ">>> Compiling source in $PWD ..."
- ebuild_phase src_compile
+ __ebuild_phase src_compile
>> "$PORTAGE_BUILDDIR/.compiled" || \
die "Failed to create $PORTAGE_BUILDDIR/.compiled"
__vecho ">>> Source compiled."
- ebuild_phase post_src_compile
+ __ebuild_phase post_src_compile
trap - SIGINT SIGQUIT
}
-dyn_test() {
+__dyn_test() {
if [[ -e $PORTAGE_BUILDDIR/.tested ]] ; then
__vecho ">>> It appears that ${PN} has already been tested; skipping."
! has test ${USE} && export USE="${USE} test"
fi
- trap "abort_test" SIGINT SIGQUIT
+ trap "__abort_test" SIGINT SIGQUIT
if [ -d "${S}" ]; then
cd "${S}"
else
else
local save_sp=${SANDBOX_PREDICT}
addpredict /
- ebuild_phase pre_src_test
- ebuild_phase src_test
+ __ebuild_phase pre_src_test
+ __ebuild_phase src_test
>> "$PORTAGE_BUILDDIR/.tested" || \
die "Failed to create $PORTAGE_BUILDDIR/.tested"
- ebuild_phase post_src_test
+ __ebuild_phase post_src_test
SANDBOX_PREDICT=${save_sp}
fi
trap - SIGINT SIGQUIT
}
-dyn_install() {
+__dyn_install() {
[ -z "$PORTAGE_BUILDDIR" ] && die "${FUNCNAME}: PORTAGE_BUILDDIR is unset"
if has noauto $FEATURES ; then
rm -f "${PORTAGE_BUILDDIR}/.installed"
__vecho ">>> Remove '${PORTAGE_BUILDDIR}/.installed' to force install."
return 0
fi
- trap "abort_install" SIGINT SIGQUIT
- ebuild_phase pre_src_install
+ trap "__abort_install" SIGINT SIGQUIT
+ __ebuild_phase pre_src_install
_x=${ED}
[[ " ${FEATURES} " == *" force-prefix "* ]] || \
cd "${S}"
elif has $EAPI 0 1 2 3 ; then
cd "${WORKDIR}"
- elif [[ -z ${A} ]] && ! has_phase_defined_up_to install; then
+ elif [[ -z ${A} ]] && ! __has_phase_defined_up_to install; then
cd "${WORKDIR}"
else
die "The source directory '${S}' doesn't exist"
export _E_EXEDESTTREE_=""
export _E_DOCDESTTREE_=""
- ebuild_phase src_install
+ __ebuild_phase src_install
>> "$PORTAGE_BUILDDIR/.installed" || \
die "Failed to create $PORTAGE_BUILDDIR/.installed"
__vecho ">>> Completed installing ${PF} into ${D}"
__vecho
- ebuild_phase post_src_install
+ __ebuild_phase post_src_install
cd "${PORTAGE_BUILDDIR}"/build-info
set -f
# local variables can leak into the saved environment.
unset f
- save_ebuild_env --exclude-init-phases | filter_readonly_variables \
+ save_ebuild_env --exclude-init-phases | __filter_readonly_variables \
--filter-path --filter-sandbox --allow-extra-vars > environment
assert "save_ebuild_env failed"
trap - SIGINT SIGQUIT
}
-dyn_preinst() {
+__dyn_preinst() {
if [ -z "${D}" ]; then
eerror "${FUNCNAME}: D is unset"
return 1
fi
- ebuild_phase_with_hooks pkg_preinst
+ __ebuild_phase_with_hooks pkg_preinst
}
-dyn_help() {
+__dyn_help() {
echo
echo "Portage"
echo "Copyright 1999-2010 Gentoo Foundation"
echo
}
-# @FUNCTION: _ebuild_arg_to_phase
+# @FUNCTION: __ebuild_arg_to_phase
# @DESCRIPTION:
# Translate a known ebuild(1) argument into the precise
# name of it's corresponding ebuild phase.
-_ebuild_arg_to_phase() {
+__ebuild_arg_to_phase() {
[ $# -ne 2 ] && die "expected exactly 2 args, got $#: $*"
local eapi=$1
local arg=$2
return 0
}
-_ebuild_phase_funcs() {
+__ebuild_phase_funcs() {
[ $# -ne 2 ] && die "expected exactly 2 args, got $#: $*"
local eapi=$1
local phase_func=$2
for x in pkg_nofetch src_unpack src_test ; do
declare -F $x >/dev/null || \
- eval "$x() { _eapi0_$x \"\$@\" ; }"
+ eval "$x() { __eapi0_$x \"\$@\" ; }"
done
case "$eapi" in
if ! declare -F src_compile >/dev/null ; then
case "$eapi" in
0)
- src_compile() { _eapi0_src_compile "$@" ; }
+ src_compile() { __eapi0_src_compile "$@" ; }
;;
*)
- src_compile() { _eapi1_src_compile "$@" ; }
+ src_compile() { __eapi1_src_compile "$@" ; }
;;
esac
fi
*)
declare -F src_configure >/dev/null || \
- src_configure() { _eapi2_src_configure "$@" ; }
+ src_configure() { __eapi2_src_configure "$@" ; }
declare -F src_compile >/dev/null || \
- src_compile() { _eapi2_src_compile "$@" ; }
+ src_compile() { __eapi2_src_compile "$@" ; }
has $eapi 2 3 || declare -F src_install >/dev/null || \
- src_install() { _eapi4_src_install "$@" ; }
+ src_install() { __eapi4_src_install "$@" ; }
if has $phase_func $default_phases ; then
- _eapi2_pkg_nofetch () { _eapi0_pkg_nofetch "$@" ; }
- _eapi2_src_unpack () { _eapi0_src_unpack "$@" ; }
- _eapi2_src_prepare () { true ; }
- _eapi2_src_test () { _eapi0_src_test "$@" ; }
- _eapi2_src_install () { die "$FUNCNAME is not supported" ; }
+ __eapi2_pkg_nofetch () { __eapi0_pkg_nofetch "$@" ; }
+ __eapi2_src_unpack () { __eapi0_src_unpack "$@" ; }
+ __eapi2_src_prepare () { true ; }
+ __eapi2_src_test () { __eapi0_src_test "$@" ; }
+ __eapi2_src_install () { die "$FUNCNAME is not supported" ; }
for x in $default_phases ; do
- eval "default_$x() { _eapi2_$x \"\$@\" ; }"
+ eval "default_$x() { __eapi2_$x \"\$@\" ; }"
done
- eval "default() { _eapi2_$phase_func \"\$@\" ; }"
+ eval "default() { __eapi2_$phase_func \"\$@\" ; }"
case "$eapi" in
2|3)
;;
*)
- eval "default_src_install() { _eapi4_src_install \"\$@\" ; }"
+ eval "default_src_install() { __eapi4_src_install \"\$@\" ; }"
[[ $phase_func = src_install ]] && \
- eval "default() { _eapi4_$phase_func \"\$@\" ; }"
+ eval "default() { __eapi4_$phase_func \"\$@\" ; }"
;;
esac
esac
}
-ebuild_main() {
+__ebuild_main() {
# Subshell/helper die support (must export for the die helper).
# Since this function is typically executed in a subshell,
# respect FEATURES="-ccache".
has ccache $FEATURES || export CCACHE_DISABLE=1
- local phase_func=$(_ebuild_arg_to_phase "$EAPI" "$EBUILD_PHASE")
- [[ -n $phase_func ]] && _ebuild_phase_funcs "$EAPI" "$phase_func"
+ local phase_func=$(__ebuild_arg_to_phase "$EAPI" "$EBUILD_PHASE")
+ [[ -n $phase_func ]] && __ebuild_phase_funcs "$EAPI" "$phase_func"
unset phase_func
source_all_bashrcs
case ${1} in
nofetch)
- ebuild_phase_with_hooks pkg_nofetch
+ __ebuild_phase_with_hooks pkg_nofetch
;;
prerm|postrm|postinst|config|info)
if has "${1}" config info && \
fi
export SANDBOX_ON="0"
if [ "${PORTAGE_DEBUG}" != "1" ] || [ "${-/x/}" != "$-" ]; then
- ebuild_phase_with_hooks pkg_${1}
+ __ebuild_phase_with_hooks pkg_${1}
else
set -x
- ebuild_phase_with_hooks pkg_${1}
+ __ebuild_phase_with_hooks pkg_${1}
set +x
fi
if [[ $EBUILD_PHASE == postinst ]] && [[ -n $PORTAGE_UPDATE_ENV ]]; then
# Update environment.bz2 in case installation phases
# need to pass some variables to uninstallation phases.
save_ebuild_env --exclude-init-phases | \
- filter_readonly_variables --filter-path \
+ __filter_readonly_variables --filter-path \
--filter-sandbox --allow-extra-vars \
| ${PORTAGE_BZIP2_COMMAND} -c -f9 > "$PORTAGE_UPDATE_ENV"
assert "save_ebuild_env failed"
esac
if [ "${PORTAGE_DEBUG}" != "1" ] || [ "${-/x/}" != "$-" ]; then
- dyn_${1}
+ __dyn_${1}
else
set -x
- dyn_${1}
+ __dyn_${1}
set +x
fi
export SANDBOX_ON="0"
#in /etc. If pkg_setup is in the sandbox, both our lilo and apache ebuilds break.
export SANDBOX_ON="0"
if [ "${PORTAGE_DEBUG}" != "1" ] || [ "${-/x/}" != "$-" ]; then
- dyn_${1}
+ __dyn_${1}
else
set -x
- dyn_${1}
+ __dyn_${1}
set +x
fi
;;
export SANDBOX_ON="1"
echo "Unrecognized arg '${1}'"
echo
- dyn_help
+ __dyn_help
exit 1
;;
esac
# Save the env only for relevant phases.
if ! has "${1}" clean help info nofetch ; then
umask 002
- save_ebuild_env | filter_readonly_variables \
+ save_ebuild_env | __filter_readonly_variables \
--filter-features > "$T/environment"
assert "save_ebuild_env failed"
chown portage:portage "$T/environment" &>/dev/null