# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-PORTAGE_BIN_PATH="${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"
-PORTAGE_PYM_PATH="${PORTAGE_PYM_PATH:-/usr/lib/portage/pym}"
+PORTAGE_BIN_PATH="${PORTAGE_BIN_PATH:-@PORTAGE_BASE@/bin}"
+PORTAGE_PYM_PATH="${PORTAGE_PYM_PATH:-@PORTAGE_BASE@/pym}"
-PATH=$PORTAGE_BIN_PATH/ebuild-helpers:$PREROOTPATH${PREROOTPATH:+:}/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin${ROOTPATH:+:}$ROOTPATH
+ ROOTPATH=${ROOTPATH##:}
+ ROOTPATH=${ROOTPATH%%:}
+ PREROOTPATH=${PREROOTPATH##:}
+ PREROOTPATH=${PREROOTPATH%%:}
++#PATH=$PORTAGE_BIN_PATH/ebuild-helpers:$PREROOTPATH${PREROOTPATH:+:}/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin${ROOTPATH:+:}$ROOTPATH
++# PREFIX: our DEFAULT_PATH is equal to the above when not using an
++# offset prefix. With such prefix, the usr/local bits are excluded, and
++# the prefixed variants of {usr/,}{s,}bin are taken. The additional
++# paths given during configure, always come as last thing since they
++# should never override anything from the prefix itself.
++PATH="$PORTAGE_BIN_PATH/ebuild-helpers:$PREROOTPATH${PREROOTPATH:+:}${DEFAULT_PATH}${ROOTPATH:+:}$ROOTPATH${EXTRA_PATH:+:}${EXTRA_PATH}"
+ export PATH
+
++
+ # Prevent aliases from causing portage to act inappropriately.
+ # Make sure it's before everything so we don't mess aliases that follow.
+ unalias -a
+
+ source "${PORTAGE_BIN_PATH}/isolated-functions.sh" || exit 1
+
+ if [[ $EBUILD_PHASE != depend ]] ; then
+ source "${PORTAGE_BIN_PATH}/phase-functions.sh" || die
+ source "${PORTAGE_BIN_PATH}/save-ebuild-env.sh" || die
+ source "${PORTAGE_BIN_PATH}/phase-helpers.sh" || die
+ source "${PORTAGE_BIN_PATH}/bashrc-functions.sh" || die
+ else
+ # These dummy functions are for things that are likely to be called
+ # in global scope, even though they are completely useless during
+ # the "depend" phase.
+ for x in diropts docompress exeopts get_KV insopts \
+ keepdir KV_major KV_micro KV_minor KV_to_int \
+ libopts register_die_hook register_success_hook \
+ remove_path_entry set_unless_changed strip_duplicate_slashes \
+ unset_unless_changed use_with use_enable ; do
+ eval "${x}() { : ; }"
+ done
+ # These dummy functions return false, in order to ensure that
+ # `use multislot` is false for the "depend" phase.
+ for x in use useq usev ; do
+ eval "${x}() { return 1; }"
+ done
+ # These functions die because calls to them during the "depend" phase
+ # are considered to be severe QA violations.
+ for x in best_version has_version portageq ; do
+ eval "${x}() { die \"\${FUNCNAME} calls are not allowed in global scope\"; }"
+ done
+ unset x
+ fi
+
if [[ $PORTAGE_SANDBOX_COMPAT_LEVEL -lt 22 ]] ; then
# Ensure that /dev/std* streams have appropriate sandbox permission for
# bug #288863. This can be removed after sandbox is fixed and portage
0|1|2)
;;
*)
- declare -r ED EPREFIX EROOT
+ # PREFIX LOCAL: allow prefix vars in any EAPI
+ #declare -r ED EPREFIX EROOT
+ # PREFIX LOCAL
;;
esac
- fi
-
- ebuild_main() {
- # Subshell/helper die support (must export for the die helper).
- # Since this function is typically executed in a subshell,
- # setup EBUILD_MASTER_PID to refer to the current $BASHPID,
- # which seems to give the best results when further
- # nested subshells call die.
- export EBUILD_MASTER_PID=$BASHPID
- trap 'exit 1' SIGTERM
-
- if [[ $EBUILD_PHASE != depend ]] ; then
- # Force configure scripts that automatically detect ccache to
- # 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"
- unset phase_func
- fi
-
- source_all_bashrcs
-
- case ${EBUILD_SH_ARGS} in
- nofetch)
- ebuild_phase_with_hooks pkg_nofetch
- ;;
- prerm|postrm|postinst|config|info)
- if has "$EBUILD_SH_ARGS" config info && \
- ! declare -F "pkg_$EBUILD_SH_ARGS" >/dev/null ; then
- ewarn "pkg_${EBUILD_SH_ARGS}() is not defined: '${EBUILD##*/}'"
- fi
- export SANDBOX_ON="0"
- if [ "${PORTAGE_DEBUG}" != "1" ] || [ "${-/x/}" != "$-" ]; then
- ebuild_phase_with_hooks pkg_${EBUILD_SH_ARGS}
- else
- set -x
- ebuild_phase_with_hooks pkg_${EBUILD_SH_ARGS}
- 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-sandbox --allow-extra-vars \
- | ${PORTAGE_BZIP2_COMMAND} -c -f9 > "$PORTAGE_UPDATE_ENV"
- assert "save_ebuild_env failed"
- fi
- ;;
- unpack|prepare|configure|compile|test|clean|install)
- if [[ ${SANDBOX_DISABLED:-0} = 0 ]] ; then
- export SANDBOX_ON="1"
- else
- export SANDBOX_ON="0"
- fi
-
- case "$EBUILD_SH_ARGS" in
- configure|compile)
-
- local x
- for x in ASFLAGS CCACHE_DIR CCACHE_SIZE \
- CFLAGS CXXFLAGS LDFLAGS LIBCFLAGS LIBCXXFLAGS ; do
- [[ ${!x+set} = set ]] && export $x
- done
- unset x
-
- has distcc $FEATURES && [[ -n $DISTCC_DIR ]] && \
- [[ ${SANDBOX_WRITE/$DISTCC_DIR} = $SANDBOX_WRITE ]] && \
- addwrite "$DISTCC_DIR"
-
- x=LIBDIR_$ABI
- [ -z "$PKG_CONFIG_PATH" -a -n "$ABI" -a -n "${!x}" ] && \
- export PKG_CONFIG_PATH=/usr/${!x}/pkgconfig
-
- if has noauto $FEATURES && \
- [[ ! -f $PORTAGE_BUILDDIR/.unpacked ]] ; then
- echo
- echo "!!! We apparently haven't unpacked..." \
- "This is probably not what you"
- echo "!!! want to be doing... You are using" \
- "FEATURES=noauto so I'll assume"
- echo "!!! that you know what you are doing..." \
- "You have 5 seconds to abort..."
- echo
-
- local x
- for x in 1 2 3 4 5 6 7 8; do
- LC_ALL=C sleep 0.25
- done
-
- sleep 3
- fi
-
- cd "$PORTAGE_BUILDDIR"
- if [ ! -d build-info ] ; then
- mkdir build-info
- cp "$EBUILD" "build-info/$PF.ebuild"
- fi
-
- #our custom version of libtool uses $S and $D to fix
- #invalid paths in .la files
- export S D
-
- ;;
- esac
-
- if [ "${PORTAGE_DEBUG}" != "1" ] || [ "${-/x/}" != "$-" ]; then
- dyn_${EBUILD_SH_ARGS}
- else
- set -x
- dyn_${EBUILD_SH_ARGS}
- set +x
- fi
- export SANDBOX_ON="0"
- ;;
- help|pretend|setup|preinst)
- #pkg_setup needs to be out of the sandbox for tmp file creation;
- #for example, awking and piping a file in /tmp requires a temp file to be created
- #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_${EBUILD_SH_ARGS}
- else
- set -x
- dyn_${EBUILD_SH_ARGS}
- set +x
- fi
- ;;
- depend)
- export SANDBOX_ON="0"
- set -f
-
- if [ -n "${dbkey}" ] ; then
- if [ ! -d "${dbkey%/*}" ]; then
- install -d -g ${PORTAGE_GID} -m2775 "${dbkey%/*}"
- fi
- # Make it group writable. 666&~002==664
- umask 002
- fi
-
- auxdbkeys="DEPEND RDEPEND SLOT SRC_URI RESTRICT HOMEPAGE LICENSE
- DESCRIPTION KEYWORDS INHERITED IUSE REQUIRED_USE PDEPEND PROVIDE EAPI
- PROPERTIES DEFINED_PHASES UNUSED_05 UNUSED_04
- UNUSED_03 UNUSED_02 UNUSED_01"
-
- #the extra $(echo) commands remove newlines
- [ -n "${EAPI}" ] || EAPI=0
-
- if [ -n "${dbkey}" ] ; then
- > "${dbkey}"
- for f in ${auxdbkeys} ; do
- echo $(echo ${!f}) >> "${dbkey}" || exit $?
- done
- else
- for f in ${auxdbkeys} ; do
- echo $(echo ${!f}) 1>&9 || exit $?
- done
+ if [[ -n $EBUILD_SH_ARGS ]] ; then
+ (
+ # Don't allow subprocesses to inherit the pipe which
+ # emerge uses to monitor ebuild.sh.
exec 9>&-
- fi
- set +f
- ;;
- _internal_test)
- ;;
- *)
- export SANDBOX_ON="1"
- echo "Unrecognized EBUILD_SH_ARGS: '${EBUILD_SH_ARGS}'"
- echo
- dyn_help
- exit 1
- ;;
- esac
- }
-
- if [[ -s $SANDBOX_LOG ]] ; then
- # We use SANDBOX_LOG to check for sandbox violations,
- # so we ensure that there can't be a stale log to
- # interfere with our logic.
- x=
- if [[ -n SANDBOX_ON ]] ; then
- x=$SANDBOX_ON
- export SANDBOX_ON=0
+ ebuild_main ${EBUILD_SH_ARGS}
+ exit 0
+ )
+ exit $?
fi
-
- rm -f "$SANDBOX_LOG" || \
- die "failed to remove stale sandbox log: '$SANDBOX_LOG'"
-
- if [[ -n $x ]] ; then
- export SANDBOX_ON=$x
- fi
- unset x
- fi
-
- if [[ $EBUILD_PHASE = depend ]] ; then
- ebuild_main
- elif [[ -n $EBUILD_SH_ARGS ]] ; then
- (
- # Don't allow subprocesses to inherit the pipe which
- # emerge uses to monitor ebuild.sh.
- exec 9>&-
-
- ebuild_main
-
- # Save the env only for relevant phases.
- if ! has "$EBUILD_SH_ARGS" clean help info nofetch ; then
- umask 002
- save_ebuild_env | filter_readonly_variables \
- --filter-features > "$T/environment"
- assert "save_ebuild_env failed"
- chown ${PORTAGE_USER:-portage}:${PORTAGE_GROUP:-portage} "$T/environment" &>/dev/null
- chmod g+w "$T/environment" &>/dev/null
- fi
- [[ -n $PORTAGE_EBUILD_EXIT_FILE ]] && > "$PORTAGE_EBUILD_EXIT_FILE"
- if [[ -n $PORTAGE_IPC_DAEMON ]] ; then
- [[ ! -s $SANDBOX_LOG ]]
- "$PORTAGE_BIN_PATH"/ebuild-ipc exit $?
- fi
- exit 0
- )
- exit $?
fi
# Do not exit when ebuild.sh is sourced by other scripts.