diff options
author | Brian Harring <ferringb@gmail.com> | 2012-09-13 23:00:10 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2012-09-14 00:13:31 -0700 |
commit | 7571867c71392b5c61b040884017c00e9d1ecb3f (patch) | |
tree | 92b8b615b5d01c34b69d378033dc001723fcd7d2 /bin/phase-functions.sh | |
parent | 9b19ac5696c487dab58d7c10990fe07fd7f1f731 (diff) | |
download | portage-7571867c71392b5c61b040884017c00e9d1ecb3f.tar.gz portage-7571867c71392b5c61b040884017c00e9d1ecb3f.tar.bz2 portage-7571867c71392b5c61b040884017c00e9d1ecb3f.zip |
Convert funcs of phase*.sh to __ prefixed namespace.
Diffstat (limited to 'bin/phase-functions.sh')
-rw-r--r-- | bin/phase-functions.sh | 196 |
1 files changed, 98 insertions, 98 deletions
diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh index 34e9da12d..8585a7193 100644 --- a/bin/phase-functions.sh +++ b/bin/phase-functions.sh @@ -39,7 +39,7 @@ PORTAGE_SAVED_READONLY_VARS="A CATEGORY P PF PN PR PV PVR" # 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: @@ -81,7 +81,7 @@ PORTAGE_MUTABLE_FILTERED_VARS="AA HOSTNAME" # 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" @@ -140,14 +140,14 @@ filter_readonly_variables() { "${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, @@ -156,7 +156,7 @@ preprocess_ebuild_env() { # 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 $? @@ -187,7 +187,7 @@ preprocess_ebuild_env() { ) > "${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 @@ -197,44 +197,44 @@ preprocess_ebuild_env() { 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 @@ -243,16 +243,16 @@ dyn_unpack() { 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 @@ -299,7 +299,7 @@ dyn_clean() { true } -abort_handler() { +__abort_handler() { local msg if [ "$2" != "fail" ]; then msg="${EBUILD}: ${1} aborted; exiting." @@ -314,37 +314,37 @@ abort_handler() { 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 @@ -354,7 +354,7 @@ has_phase_defined_up_to() { return 1 } -dyn_prepare() { +__dyn_prepare() { if [[ -e $PORTAGE_BUILDDIR/.prepared ]] ; then __vecho ">>> It appears that '$PF' is already prepared; skipping." @@ -366,26 +366,26 @@ dyn_prepare() { 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." @@ -397,28 +397,28 @@ dyn_configure() { 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." @@ -430,13 +430,13 @@ dyn_compile() { 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 @@ -445,20 +445,20 @@ dyn_compile() { 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." @@ -472,7 +472,7 @@ dyn_test() { ! 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 @@ -487,18 +487,18 @@ dyn_test() { 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" @@ -507,8 +507,8 @@ dyn_install() { __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 "* ]] || \ @@ -521,7 +521,7 @@ dyn_install() { 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" @@ -541,12 +541,12 @@ dyn_install() { 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 @@ -586,7 +586,7 @@ dyn_install() { # 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" @@ -601,15 +601,15 @@ dyn_install() { 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" @@ -672,11 +672,11 @@ dyn_help() { 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 @@ -732,7 +732,7 @@ _ebuild_arg_to_phase() { return 0 } -_ebuild_phase_funcs() { +__ebuild_phase_funcs() { [ $# -ne 2 ] && die "expected exactly 2 args, got $#: $*" local eapi=$1 local phase_func=$2 @@ -742,7 +742,7 @@ _ebuild_phase_funcs() { 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 @@ -752,10 +752,10 @@ _ebuild_phase_funcs() { 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 @@ -775,35 +775,35 @@ _ebuild_phase_funcs() { *) 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 @@ -825,7 +825,7 @@ _ebuild_phase_funcs() { esac } -ebuild_main() { +__ebuild_main() { # Subshell/helper die support (must export for the die helper). # Since this function is typically executed in a subshell, @@ -861,15 +861,15 @@ ebuild_main() { # 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 && \ @@ -878,17 +878,17 @@ ebuild_main() { 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" @@ -952,10 +952,10 @@ ebuild_main() { 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" @@ -966,10 +966,10 @@ ebuild_main() { #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 ;; @@ -979,7 +979,7 @@ ebuild_main() { export SANDBOX_ON="1" echo "Unrecognized arg '${1}'" echo - dyn_help + __dyn_help exit 1 ;; esac @@ -987,7 +987,7 @@ ebuild_main() { # 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 |