2 # Copyright 1999-2006 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
6 PORTAGE_BIN_PATH="${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"
7 PORTAGE_PYM_PATH="${PORTAGE_PYM_PATH:-/usr/lib/portage/pym}"
8 declare -rx PORTAGE_BIN_PATH PORTAGE_PYM_PATH
10 SANDBOX_PREDICT="${SANDBOX_PREDICT}:/proc/self/maps:/dev/console:/dev/random"
11 export SANDBOX_PREDICT="${SANDBOX_PREDICT}:${PORTAGE_PYM_PATH}:${PORTAGE_DEPCACHEDIR}"
12 export SANDBOX_WRITE="${SANDBOX_WRITE}:/dev/shm:/dev/stdout:/dev/stderr:${PORTAGE_TMPDIR}"
13 export SANDBOX_READ="${SANDBOX_READ}:/dev/shm:/dev/stdin:${PORTAGE_TMPDIR}"
15 if [ ! -z "${PORTAGE_GPG_DIR}" ]; then
16 SANDBOX_PREDICT="${SANDBOX_PREDICT}:${PORTAGE_GPG_DIR}"
19 declare -rx EBUILD_PHASE
21 # These two functions wrap sourcing and calling respectively. At present they
22 # perform a qa check to make sure eclasses and ebuilds and profiles don't mess
23 # with shell opts (shopts). Ebuilds/eclasses changing shopts should reset them
24 # when they are done. Note: For now these shoudl always return success.
27 local shopts=$(shopt) OLDIFS="$IFS"
28 source "$@" || return 1
29 [[ $shopts != $(shopt) ]] &&
30 eqawarn "QA Notice: Global shell options changed and were not restored while sourcing '$*'"
31 [[ "$IFS" != "$OLDIFS" ]] &&
32 eqawarn "QA Notice: Global IFS changed and was not restored while sourcing '$*'"
37 local shopts=$(shopt) OLDIFS="$IFS"
39 [[ $shopts != $(shopt) ]] &&
40 eqawarn "QA Notice: Global shell options changed and were not restored while calling '$*'"
41 [[ "$IFS" != "$OLDIFS" ]] &&
42 eqawarn "QA Notice: Global IFS changed and was not restored while calling '$*'"
46 if [ "$*" != "depend" ] && [ "$*" != "clean" ] && [ "$*" != "nofetch" ]; then
47 if [ -f "${T}/environment" ]; then
48 qa_source "${T}/environment" &>/dev/null
52 # subshell die support
60 # Prevent aliases from causing portage to act inappropriately.
61 # Make sure it's before everything so we don't mess aliases that follow.
64 # Unset some variables that break things.
65 unset GZIP BZIP BZIP2 CDPATH GREP_OPTIONS GREP_COLOR GLOBIGNORE
67 # We need this next line for "die" and "assert". It expands
68 # It _must_ preceed all the calls to die and assert.
69 shopt -s expand_aliases
70 alias die='diefunc "$FUNCNAME" "$LINENO" "$?"'
71 alias assert='_pipestatus="${PIPESTATUS[*]}"; [[ "${_pipestatus// /}" -eq 0 ]] || diefunc "$FUNCNAME" "$LINENO" "$_pipestatus"'
72 alias save_IFS='[ "${IFS:-unset}" != "unset" ] && old_IFS="${IFS}"'
73 alias restore_IFS='if [ "${old_IFS:-unset}" != "unset" ]; then IFS="${old_IFS}"; unset old_IFS; else unset IFS; fi'
78 export PATH="/usr/local/sbin:/sbin:/usr/sbin:${PORTAGE_BIN_PATH}:/usr/local/bin:/bin:/usr/bin:${ROOTPATH}"
79 [ ! -z "$PREROOTPATH" ] && export PATH="${PREROOTPATH%%:}:$PATH"
81 source "${PORTAGE_BIN_PATH}/isolated-functions.sh" &>/dev/null
83 [[ $PORTAGE_QUIET != "" ]] && export PORTAGE_QUIET
85 # the sandbox is disabled by default except when overridden in the relevant stages
88 # sandbox support functions; defined prior to profile.bashrc srcing, since the profile might need to add a default exception (/usr/lib64/conftest fex)
90 [[ -z $1 || -n $2 ]] && die "Usage: addread <colon-delimited list of paths>"
91 export SANDBOX_READ="$SANDBOX_READ:$1"
95 [[ -z $1 || -n $2 ]] && die "Usage: addwrite <colon-delimited list of paths>"
96 export SANDBOX_WRITE="$SANDBOX_WRITE:$1"
100 [[ -z $1 || -n $2 ]] && die "Usage: adddeny <colon-delimited list of paths>"
101 export SANDBOX_DENY="$SANDBOX_DENY:$1"
105 [[ -z $1 || -n $2 ]] && die "Usage: addpredict <colon-delimited list of paths>"
106 export SANDBOX_PREDICT="$SANDBOX_PREDICT:$1"
117 # source the existing profile.bashrc's.
120 for dir in ${PROFILE_PATHS}; do
121 # Must unset it so that it doesn't mess up assumptions in the RCs.
123 if [ -f "${dir}/profile.bashrc" ]; then
124 qa_source "${dir}/profile.bashrc"
129 # We assume if people are changing shopts in their bashrc they do so at their
130 # own peril. This is the ONLY non-portage bit of code that can change shopts
131 # without a QA violation.
132 if [ -f "${PORTAGE_BASHRC}" ]; then
133 # If $- contains x, then tracing has already enabled elsewhere for some
134 # reason. We preserve it's state so as not to interfere.
135 if [ "$PORTAGE_DEBUG" != "1" ] || [ "${-/x/}" != "$-" ]; then
136 source "${PORTAGE_BASHRC}"
139 source "${PORTAGE_BASHRC}"
144 [ ! -z "$OCC" ] && export CC="$OCC"
145 [ ! -z "$OCXX" ] && export CXX="$OCXX"
148 # Custom version of esyslog() to take care of the "Red Star" bug.
149 # MUST follow functions.sh to override the "" parameter problem.
169 # if we got something like '!flag', then invert the return value
170 if [[ ${u:0:1} == "!" ]] ; then
175 # Make sure we have this USE flag in IUSE
176 if ! hasq "${u}" ${IUSE} ${E_IUSE} && ! hasq "${u}" ${PORTAGE_ARCHLIST} selinux; then
177 eqawarn "QA Notice: USE Flag '${u}' not in IUSE for ${CATEGORY}/${PF}"
180 if hasq ${u} ${USE} ; then
188 if [ "${EBUILD_PHASE}" == "depend" ]; then
189 die "portageq calls (has_version calls portageq) are not allowed in the global scope"
191 # return shell-true/shell-false if exists.
192 # Takes single depend-type atoms.
193 if "${PORTAGE_BIN_PATH}/portageq" 'has_version' "${ROOT}" "$1"; then
201 if [ "${EBUILD_PHASE}" == "depend" ]; then
202 die "portageq calls are not allowed in the global scope"
204 "${PORTAGE_BIN_PATH}/portageq" "$@"
208 # ----------------------------------------------------------------------------
209 # ----------------------------------------------------------------------------
210 # ----------------------------------------------------------------------------
214 if [ "${EBUILD_PHASE}" == "depend" ]; then
215 die "portageq calls (best_version calls portageq) are not allowed in the global scope"
217 # returns the best/most-current match.
218 # Takes single depend-type atoms.
219 "${PORTAGE_BIN_PATH}/portageq" 'best_version' "${ROOT}" "$1"
224 echo "!!! use_with() called without a parameter." >&2
225 echo "!!! use_with <USEFLAG> [<flagname> [value]]" >&2
230 if [ ! -z "${3}" ]; then
235 if [ -z "${UWORD}" ]; then
240 echo "--with-${UWORD}${UW_SUFFIX}"
242 echo "--without-${UWORD}"
249 echo "!!! use_enable() called without a parameter." >&2
250 echo "!!! use_enable <USEFLAG> [<flagname> [value]]" >&2
255 if [ ! -z "${3}" ]; then
260 if [ -z "${UWORD}" ]; then
265 echo "--enable-${UWORD}${UE_SUFFIX}"
267 echo "--disable-${UWORD}"
272 register_die_hook() {
273 export EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} $*"
277 local funcname="$1" lineno="$2" exitcode="$3"
280 echo "!!! ERROR: $CATEGORY/$PF failed." >&2
282 echo " $(basename "${BASH_SOURCE[1]}"), line ${BASH_LINENO[0]}: Called die" 1>&2
284 echo "!!! ${*:-(no error message)}" >&2
285 echo "!!! If you need support, post the topmost build error, and the call stack if relevant." >&2
286 echo "!!! A complete build log is located at '${PORTAGE_LOG_FILE}'." >&2
288 if [ -n "${EBUILD_OVERLAY_ECLASSES}" ] ; then
289 echo "This ebuild used the following eclasses from overlays:" >&2
291 for x in ${EBUILD_OVERLAY_ECLASSES} ; do
297 if [ "${EBUILD_PHASE/depend}" == "${EBUILD_PHASE}" ]; then
299 for x in $EBUILD_DEATH_HOOKS; do
304 # subshell die support
305 kill -s SIGTERM ${EBUILD_MASTER_PID}
309 shopt -s extdebug &> /dev/null
311 # usage- first arg is the number of funcs on the stack to ignore.
312 # defaults to 1 (ignoring dump_trace)
314 local funcname="" sourcefile="" lineno="" n e s="yes"
323 for (( n = ${#FUNCNAME[@]} - 1, p = ${#BASH_ARGV[@]} ; n > $strip ; n-- )) ; do
324 funcname=${FUNCNAME[${n} - 1]}
325 sourcefile=$(basename ${BASH_SOURCE[${n}]})
326 lineno=${BASH_LINENO[${n} - 1]}
327 # Display function arguments
329 if [[ -n "${BASH_ARGV[@]}" ]]; then
330 for (( j = 1 ; j <= ${BASH_ARGC[${n} - 1]} ; ++j )); do
331 newarg=${BASH_ARGV[$(( p - j - 1 ))]}
332 args="${args:+${args} }'${newarg}'"
334 (( p -= ${BASH_ARGC[${n} - 1]} ))
336 echo " ${sourcefile}, line ${lineno}: Called ${funcname}${args:+ ${args}}"
342 #if no perms are specified, dirs/files will have decent defaults
343 #(not secretive, but not stupid)
346 export INSDESTTREE=""
347 export EXEDESTTREE=""
348 export DOCDESTTREE=""
349 export INSOPTIONS="-m0644"
350 export EXEOPTIONS="-m0755"
351 export LIBOPTIONS="-m0644"
352 export DIROPTIONS="-m0755"
353 export MOPREFIX=${PN}
356 if [ -z "${KV}" ]; then
358 eerror "Could not determine your kernel version."
359 eerror "Make sure that you have a /usr/src/linux symlink,"
360 eerror "and that the indicated kernel has been configured."
361 eerror "You can also simply run the following command"
362 eerror "in the directory referenced by /usr/src/linux:"
363 eerror " make include/linux/version.h"
369 # adds ".keep" files so that dirs aren't auto-cleaned
373 if [ "$1" == "-R" ] || [ "$1" == "-r" ]; then
375 find "$@" -type d -printf "${D}/%p/.keep_${CATEGORY}_${PN}-${SLOT}\n" | tr "\n" "\0" | $XARGS -0 -n100 touch || die "Failed to recursively create .keep files"
378 touch "${D}/${x}/.keep_${CATEGORY}_${PN}-${SLOT}" || die "Failed to create .keep in ${D}/${x}"
388 [ -z "$*" ] && die "Nothing passed to the 'unpack' command"
391 vecho ">>> Unpacking ${x} to ${PWD}"
395 myfail="${x} does not exist"
396 if [ "${x:0:2}" = "./" ] ; then
401 [[ ${x} == ${DISTDIR}* ]] && \
402 die "Arguments to unpack() should not begin with \${DISTDIR}."
403 [ ! -s "${srcdir}${x}" ] && die "$myfail"
405 myfail="failure unpacking ${x}"
408 tar xof "${srcdir}${x}" || die "$myfail"
411 tar xozf "${srcdir}${x}" || die "$myfail"
414 bzip2 -dc "${srcdir}${x}" | tar xof -
418 unzip -qo "${srcdir}${x}" || die "$myfail"
421 if [ "${y}" == "tar" ]; then
422 tar zoxf "${srcdir}${x}" || die "$myfail"
424 gzip -dc "${srcdir}${x}" > ${x%.*} || die "$myfail"
428 if [ "${y}" == "tar" ]; then
429 bzip2 -dc "${srcdir}${x}" | tar xof -
432 bzip2 -dc "${srcdir}${x}" > ${x%.*} || die "$myfail"
437 my_output="$(7z x -y "${srcdir}/${x}")"
438 if [ $? -ne 0 ]; then
439 echo "${my_output}" >&2
444 unrar x -idq -o+ "${srcdir}/${x}" || die "$myfail"
447 lha xqf "${srcdir}/${x}" || die "$myfail"
450 ar x "${srcdir}/${x}" || die "$myfail"
453 vecho "unpack ${x}: file format not recognized. Ignoring."
457 # Do not chmod '.' since it's probably ${WORKDIR} and PORTAGE_WORKDIR_MODE
458 # should be preserved.
459 find . -mindepth 1 -print0 | ${XARGS} -0 chmod -f a+rX,u+w,g-w,o-w
462 strip_duplicate_slashes() {
463 if [[ -n $1 ]] ; then
465 while [[ ${removed} == *//* ]] ; do
466 removed=${removed//\/\///}
474 local LOCAL_EXTRA_ECONF="${EXTRA_ECONF}"
476 if [ -z "${ECONF_SOURCE}" ]; then
479 if [ -x "${ECONF_SOURCE}/configure" ]; then
480 if [ -e /usr/share/gnuconfig/ ]; then
481 for x in $(find "${WORKDIR}" -type f '(' -name config.guess -o -name config.sub ')') ; do
482 vecho " * econf: updating ${x/${WORKDIR}\/} with /usr/share/gnuconfig/${x##*/}"
483 cp -f /usr/share/gnuconfig/${x##*/} ${x}
487 if [ ! -z "${CBUILD}" ]; then
488 LOCAL_EXTRA_ECONF="--build=${CBUILD} ${LOCAL_EXTRA_ECONF}"
491 if [ ! -z "${CTARGET}" ]; then
492 LOCAL_EXTRA_ECONF="--target=${CTARGET} ${LOCAL_EXTRA_ECONF}"
495 # if the profile defines a location to install libs to aside from default, pass it on.
496 # if the ebuild passes in --libdir, they're responsible for the conf_libdir fun.
497 LIBDIR_VAR="LIBDIR_${ABI}"
498 if [ -n "${ABI}" -a -n "${!LIBDIR_VAR}" ]; then
499 CONF_LIBDIR="${!LIBDIR_VAR}"
502 if [ -n "${CONF_LIBDIR}" ] && [ "${*/--libdir}" == "$*" ]; then
503 if [ "${*/--exec-prefix}" != "$*" ]; then
504 local args="$(echo $*)"
505 local -a pref=($(echo ${args/*--exec-prefix[= ]}))
507 [ "${CONF_PREFIX:0:1}" != "/" ] && CONF_PREFIX="/${CONF_PREFIX}"
508 elif [ "${*/--prefix}" != "$*" ]; then
509 local args="$(echo $*)"
510 local -a pref=($(echo ${args/*--prefix[= ]}))
512 [ "${CONF_PREFIX:0:1}" != "/" ] && CONF_PREFIX="/${CONF_PREFIX}"
517 [ "${CONF_LIBDIR:0:1}" != "/" ] && CONF_LIBDIR="/${CONF_LIBDIR}"
519 CONF_LIBDIR_RESULT="$(strip_duplicate_slashes ${CONF_PREFIX}${CONF_LIBDIR})"
521 LOCAL_EXTRA_ECONF="--libdir=${CONF_LIBDIR_RESULT} ${LOCAL_EXTRA_ECONF}"
524 local TMP_CONFCACHE_DIR CONFCACHE_ARG
525 if hasq confcache $FEATURES && ! hasq confcache $RESTRICT; then
526 CONFCACHE="$(type -p confcache)"
527 if [ -z "${CONFCACHE}" ]; then
528 ewarn "disabling confcache, binary cannot be found"
530 CONFCACHE="${CONFCACHE/ /\ }"
531 TMP_CONFCACHE_DIR="${CONFCACHE:+${CONFCACHE_DIR:-${PORTAGE_TMPDIR}/confcache}}"
532 TMP_CONFCACHE_DIR="${TMP_CONFCACHE_DIR/ /\ }"
533 CONFCACHE_ARG="--confcache-dir"
535 if [ -n "$CCACHE_DIR" ]; then
538 if [ -n "$DISTCC_DIR" ]; then
539 s="${s:+${s}:}$DISTCC_DIR"
542 CONFCACHE_ARG="--confcache-ignore $s $CONFCACHE_ARG"
549 vecho ${CONFCACHE} ${CONFCACHE_ARG} ${TMP_CONFCACHE_DIR} "${ECONF_SOURCE}/configure" \
552 --mandir=/usr/share/man \
553 --infodir=/usr/share/info \
554 --datadir=/usr/share \
556 --localstatedir=/var/lib \
560 if ! ${CONFCACHE} ${CONFCACHE_ARG} ${TMP_CONFCACHE_DIR} "${ECONF_SOURCE}/configure" \
563 --mandir=/usr/share/man \
564 --infodir=/usr/share/info \
565 --datadir=/usr/share \
567 --localstatedir=/var/lib \
569 ${LOCAL_EXTRA_ECONF}; then
571 if [ -s config.log ]; then
573 echo "!!! Please attach the following file when filing a report to bugs.gentoo.org:"
574 echo "!!! ${PWD}/config.log"
579 die "no configure script found"
584 # CONF_PREFIX is only set if they didn't pass in libdir above.
585 LIBDIR_VAR="LIBDIR_${ABI}"
586 if [ -n "${ABI}" -a -n "${!LIBDIR_VAR}" ]; then
587 CONF_LIBDIR="${!LIBDIR_VAR}"
590 if [ -n "${CONF_LIBDIR}" ] && [ "${CONF_PREFIX:-unset}" != "unset" ]; then
591 EI_DESTLIBDIR="${D}/${CONF_PREFIX}/${CONF_LIBDIR}"
592 EI_DESTLIBDIR="$(strip_duplicate_slashes ${EI_DESTLIBDIR})"
593 EXTRA_EINSTALL="libdir=${EI_DESTLIBDIR} ${EXTRA_EINSTALL}"
597 if [ -f ./[mM]akefile -o -f ./GNUmakefile ] ; then
598 if [ "${PORTAGE_DEBUG}" == "1" ]; then
599 make -n prefix="${D}/usr" \
600 datadir="${D}/usr/share" \
601 infodir="${D}/usr/share/info" \
602 localstatedir="${D}/var/lib" \
603 mandir="${D}/usr/share/man" \
604 sysconfdir="${D}/etc" \
608 make prefix="${D}/usr" \
609 datadir="${D}/usr/share" \
610 infodir="${D}/usr/share/info" \
611 localstatedir="${D}/var/lib" \
612 mandir="${D}/usr/share/man" \
613 sysconfdir="${D}/etc" \
615 "$@" install || die "einstall failed"
617 die "no Makefile found"
626 [ -z "${SRC_URI}" ] && return
628 echo "!!! The following are listed in SRC_URI for ${PN}:"
630 for x in $(echo ${SRC_URI}); do
636 [[ -n ${A} ]] && unpack ${A}
640 if [ -x ./configure ]; then
643 if [ -f Makefile ] || [ -f GNUmakefile ] || [ -f makefile ]; then
644 emake || die "emake failed"
649 if emake -j1 check -n &> /dev/null; then
650 vecho ">>> Test phase [check]: ${CATEGORY}/${PF}"
651 if ! emake -j1 check; then
652 hasq test $FEATURES && die "Make check failed. See above for details."
653 hasq test $FEATURES || eerror "Make check failed. See above for details."
655 elif emake -j1 test -n &> /dev/null; then
656 vecho ">>> Test phase [test]: ${CATEGORY}/${PF}"
657 if ! emake -j1 test; then
658 hasq test $FEATURES && die "Make test failed. See above for details."
659 hasq test $FEATURES || eerror "Make test failed. See above for details."
662 vecho ">>> Test phase [none]: ${CATEGORY}/${PF}"
687 eerror "This ebuild does not have a config function."
690 # Used to generate the /lib/cpp and /usr/bin/cc wrappers
700 [ "$(type -t pre_pkg_setup)" == "function" ] && qa_call pre_pkg_setup
702 [ "$(type -t post_pkg_setup)" == "function" ] && qa_call post_pkg_setup
706 [ "$(type -t pre_src_unpack)" == "function" ] && qa_call pre_src_unpack
708 if [ -e "${WORKDIR}" ]; then
712 vecho ">>> Checking ${x}'s mtime..."
713 if [ "${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/${x}" -nt "${WORKDIR}" ]; then
714 vecho ">>> ${x} has been updated; recreating WORKDIR..."
719 if [ "${EBUILD}" -nt "${WORKDIR}" ] && ! hasq keepwork ${FEATURES} ; then
720 vecho ">>> ${EBUILD} has been updated; recreating WORKDIR..."
722 elif [ ! -f "${PORTAGE_BUILDDIR}/.unpacked" ]; then
723 vecho ">>> Not marked as unpacked; recreating WORKDIR..."
727 if [ "${newstuff}" == "yes" ]; then
728 # We don't necessarily have privileges to do a full dyn_clean here.
730 if [ -d "${T}" ] && ! hasq keeptemp ${FEATURES} ; then
731 rm -rf "${T}" && mkdir "${T}"
733 [ -e "${T}/environment" ] && \
734 mv "${T}/environment" "${T}/environment.keeptemp"
737 if [ -e "${WORKDIR}" ]; then
738 if [ "$newstuff" == "no" ]; then
739 vecho ">>> WORKDIR is up-to-date, keeping..."
740 [ "$(type -t post_src_unpack)" == "function" ] && qa_call post_src_unpack
745 if [ ! -d "${WORKDIR}" ]; then
746 install -m${PORTAGE_WORKDIR_MODE:-0700} -d "${WORKDIR}" || die "Failed to create dir '${WORKDIR}'"
748 cd "${WORKDIR}" || die "Directory change failed: \`cd '${WORKDIR}'\`"
749 vecho ">>> Unpacking source..."
751 touch "${PORTAGE_BUILDDIR}/.unpacked" || die "IO Failure -- Failed 'touch .unpacked' in ${PORTAGE_BUILDDIR}"
752 vecho ">>> Source unpacked."
753 cd "${PORTAGE_BUILDDIR}"
755 [ "$(type -t post_src_unpack)" == "function" ] && qa_call post_src_unpack
759 if [ -z "${PORTAGE_BUILDDIR}" ]; then
760 echo "Aborting clean phase because PORTAGE_BUILDDIR is unset!"
764 if type -p chflags &>/dev/null; then
765 chflags -R noschg,nouchg,nosappnd,nouappnd "${PORTAGE_BUILDDIR}"
766 chflags -R nosunlnk,nouunlnk "${PORTAGE_BUILDDIR}" 2>/dev/null
769 rm -rf "${PORTAGE_BUILDDIR}/image" "${PORTAGE_BUILDDIR}/homedir"
771 if ! hasq keeptemp $FEATURES; then
774 [ -e "${T}/environment" ] && mv "${T}/environment" "${T}/environment.keeptemp"
777 if ! hasq keepwork $FEATURES; then
778 rm -rf "${PORTAGE_BUILDDIR}/.logid"
779 rm -rf "${PORTAGE_BUILDDIR}/.unpacked"
780 rm -rf "${PORTAGE_BUILDDIR}/.compiled"
781 rm -rf "${PORTAGE_BUILDDIR}/.tested"
782 rm -rf "${PORTAGE_BUILDDIR}/.installed"
783 rm -rf "${PORTAGE_BUILDDIR}/.packaged"
784 rm -rf "${PORTAGE_BUILDDIR}/build-info"
788 if [ -f "${PORTAGE_BUILDDIR}/.unpacked" ]; then
789 find "${PORTAGE_BUILDDIR}" -type d ! -regex "^${WORKDIR}" | sort -r | tr "\n" "\0" | $XARGS -0 rmdir &>/dev/null
792 # do not bind this to doebuild defined DISTDIR; don't trust doebuild, and if mistakes are made it'll
793 # result in it wiping the users distfiles directory (bad).
794 rm -rf "${PORTAGE_BUILDDIR}/distdir"
796 if [ -z "$(find "${PORTAGE_BUILDDIR}" -mindepth 1 -maxdepth 1)" ]; then
797 rmdir "${PORTAGE_BUILDDIR}"
804 if [ "$1" == "/" ]; then
808 if [ ! -d "${D}${DESTTREE}" ]; then
809 install -d "${D}${DESTTREE}"
815 if [ "$1" == "/" ]; then
816 export INSDESTTREE=""
818 export INSDESTTREE=$1
819 if [ ! -d "${D}${INSDESTTREE}" ]; then
820 install -d "${D}${INSDESTTREE}"
826 if [ "$1" == "/" ]; then
827 export EXEDESTTREE=""
829 export EXEDESTTREE="$1"
830 if [ ! -d "${D}${EXEDESTTREE}" ]; then
831 install -d "${D}${EXEDESTTREE}"
837 if [ "$1" == "/" ]; then
838 export DOCDESTTREE=""
840 export DOCDESTTREE="$1"
841 if [ ! -d "${D}usr/share/doc/${PF}/${DOCDESTTREE}" ]; then
842 install -d "${D}usr/share/doc/${PF}/${DOCDESTTREE}"
848 export INSOPTIONS="$@"
850 # `install` should never be called with '-s' ...
851 hasq -s ${INSOPTIONS} && die "Never call insopts() with -s"
855 export DIROPTIONS="$@"
859 export EXEOPTIONS="$@"
861 # `install` should never be called with '-s' ...
862 hasq -s ${EXEOPTIONS} && die "Never call exeopts() with -s"
866 export LIBOPTIONS="$@"
868 # `install` should never be called with '-s' ...
869 hasq -s ${LIBOPTIONS} && die "Never call libopts() with -s"
874 if [ "$2" != "fail" ]; then
875 msg="${EBUILD}: ${1} aborted; exiting."
877 msg="${EBUILD}: ${1} failed; exiting."
883 #unset signal handler
888 abort_handler "src_compile" $1
889 rm -f "${PORTAGE_BUILDDIR}/.compiled"
894 abort_handler "dyn_test" $1
895 rm -f "${PORTAGE_BUILDDIR}/.tested"
900 abort_handler "src_install" $1
901 rm -rf "${PORTAGE_BUILDDIR}/image"
906 trap "abort_compile" SIGINT SIGQUIT
908 [ "$(type -t pre_src_compile)" == "function" ] && qa_call pre_src_compile
910 [ "${CFLAGS-unset}" != "unset" ] && export CFLAGS
911 [ "${CXXFLAGS-unset}" != "unset" ] && export CXXFLAGS
912 [ "${LIBCFLAGS-unset}" != "unset" ] && export LIBCFLAGS
913 [ "${LIBCXXFLAGS-unset}" != "unset" ] && export LIBCXXFLAGS
914 [ "${LDFLAGS-unset}" != "unset" ] && export LDFLAGS
915 [ "${ASFLAGS-unset}" != "unset" ] && export ASFLAGS
917 [ "${CCACHE_DIR-unset}" != "unset" ] && export CCACHE_DIR
918 [ "${CCACHE_SIZE-unset}" != "unset" ] && export CCACHE_SIZE
920 [ "${DISTCC_DIR-unset}" == "unset" ] && export DISTCC_DIR="${PORTAGE_TMPDIR}/.distcc"
921 [ ! -z "${DISTCC_DIR}" ] && addwrite "${DISTCC_DIR}"
923 LIBDIR_VAR="LIBDIR_${ABI}"
924 if [ -z "${PKG_CONFIG_PATH}" -a -n "${ABI}" -a -n "${!LIBDIR_VAR}" ]; then
925 export PKG_CONFIG_PATH="/usr/${!LIBDIR_VAR}/pkgconfig"
929 if hasq noauto $FEATURES && [ ! -f ${PORTAGE_BUILDDIR}/.unpacked ]; then
931 echo "!!! We apparently haven't unpacked... This is probably not what you"
932 echo "!!! want to be doing... You are using FEATURES=noauto so I'll assume"
933 echo "!!! that you know what you are doing... You have 5 seconds to abort..."
937 for x in 1 2 3 4 5 6 7 8; do
945 local srcdir=${PORTAGE_BUILDDIR}
946 cd "${PORTAGE_BUILDDIR}"
947 if [ ! -e "build-info" ]; then
950 cp "${EBUILD}" "build-info/${PF}.ebuild"
952 if [[ ${PORTAGE_BUILDDIR}/.compiled -nt ${WORKDIR} ]] ; then
953 vecho ">>> It appears that '${PF}' is already compiled; skipping."
954 vecho ">>> Remove '${PORTAGE_BUILDDIR}/.compiled' to force compilation."
956 [ "$(type -t post_src_compile)" == "function" ] && qa_call post_src_compile
959 if [ -d "${S}" ]; then
963 #our custom version of libtool uses $S and $D to fix
964 #invalid paths in .la files
966 #some packages use an alternative to $S to build in, cause
967 #our libtool to create problematic .la files
968 export PWORKDIR="$WORKDIR"
969 vecho ">>> Compiling source in ${srcdir} ..."
971 vecho ">>> Source compiled."
972 #|| abort_compile "fail"
973 cd "${PORTAGE_BUILDDIR}"
978 for f in ASFLAGS CATEGORY CBUILD CC CFLAGS CHOST CTARGET CXX \
979 CXXFLAGS DEPEND EXTRA_ECONF EXTRA_EINSTALL EXTRA_MAKE \
980 FEATURES INHERITED IUSE LDFLAGS LIBCFLAGS LIBCXXFLAGS \
981 LICENSE PDEPEND PF PKGUSE PROVIDE RDEPEND RESTRICT SLOT \
982 KEYWORDS HOMEPAGE SRC_URI DESCRIPTION; do
983 [ -n "${!f}" ] && echo $(echo "${!f}" | tr '\n,\r,\t' ' , , ' | sed s/' \+'/' '/g) > ${f}
986 echo "${EAPI:-0}" > EAPI
989 export -p | sed 's:declare -rx:declare -x:' >> environment
990 bzip2 -f9 environment
992 cp "${EBUILD}" "${PF}.ebuild"
993 if hasq nostrip ${FEATURES} ${RESTRICT} || hasq strip ${RESTRICT}
998 [ "$(type -t post_src_compile)" == "function" ] && qa_call post_src_compile
1004 [ "${EBUILD_FORCE_TEST}" == "1" ] && rm -f "${PORTAGE_BUILDDIR}/.tested"
1005 [ "$(type -t pre_src_test)" == "function" ] && qa_call pre_src_test
1006 if [ "${PORTAGE_BUILDDIR}/.tested" -nt "${WORKDIR}" ]; then
1007 vecho ">>> It appears that ${PN} has already been tested; skipping."
1008 [ "$(type -t post_src_test)" == "function" ] && qa_call post_src_test
1011 trap "abort_test" SIGINT SIGQUIT
1012 if [ -d "${S}" ]; then
1015 if ! hasq test $FEATURES && [ "${EBUILD_FORCE_TEST}" != "1" ]; then
1016 vecho ">>> Test phase [not enabled]: ${CATEGORY}/${PF}"
1017 elif ! hasq test ${USE} && [ "${EBUILD_FORCE_TEST}" != "1" ]; then
1018 ewarn "Skipping make test/check since USE=test is masked."
1019 vecho ">>> Test phase [explicitly disabled]: ${CATEGORY}/${PF}"
1020 elif hasq test $RESTRICT; then
1021 ewarn "Skipping make test/check due to ebuild restriction."
1022 vecho ">>> Test phase [explicitly disabled]: ${CATEGORY}/${PF}"
1026 SANDBOX_PREDICT="${SANDBOX_PREDICT%:/}"
1029 cd "${PORTAGE_BUILDDIR}"
1030 touch .tested || die "Failed to 'touch .tested' in ${PORTAGE_BUILDDIR}"
1031 [ "$(type -t post_src_test)" == "function" ] && qa_call post_src_test
1036 [ -z "$PORTAGE_BUILDDIR" ] && die "${FUNCNAME}: PORTAGE_BUILDDIR is unset"
1037 if hasq noauto $FEATURES ; then
1038 rm -f "${PORTAGE_BUILDDIR}/.installed"
1039 elif [[ ${PORTAGE_BUILDDIR}/.installed -nt ${WORKDIR} ]] ; then
1040 vecho ">>> It appears that '${PF}' is already installed; skipping."
1041 vecho ">>> Remove '${PORTAGE_BUILDDIR}/.installed' to force install."
1044 trap "abort_install" SIGINT SIGQUIT
1045 [ "$(type -t pre_src_install)" == "function" ] && qa_call pre_src_install
1046 rm -rf "${PORTAGE_BUILDDIR}/image"
1047 mkdir "${PORTAGE_BUILDDIR}/image"
1048 if [ -d "${S}" ]; then
1052 vecho ">>> Install ${PF} into ${D} category ${CATEGORY}"
1053 #our custom version of libtool uses $S and $D to fix
1054 #invalid paths in .la files
1056 #some packages uses an alternative to $S to build in, cause
1057 #our libtool to create problematic .la files
1058 export PWORKDIR="$WORKDIR"
1060 touch "${PORTAGE_BUILDDIR}/.installed"
1061 vecho ">>> Completed installing ${PF} into ${D}"
1063 cd ${PORTAGE_BUILDDIR}
1064 [ "$(type -t post_src_install)" == "function" ] && qa_call post_src_install
1069 if [ -z "$IMAGE" ]; then
1070 eerror "${FUNCNAME}: IMAGE is unset"
1074 [ "$(type -t pre_pkg_preinst)" == "function" ] && qa_call pre_pkg_preinst
1076 declare -r D=${IMAGE}
1079 [ "$(type -t post_pkg_preinst)" == "function" ] && qa_call post_pkg_preinst
1085 echo "Copyright 1999-2006 Gentoo Foundation"
1087 echo "How to use the ebuild command:"
1089 echo "The first argument to ebuild should be an existing .ebuild file."
1091 echo "One or more of the following options can then be specified. If more"
1092 echo "than one option is specified, each will be executed in order."
1094 echo " help : show this help screen"
1095 echo " setup : execute package specific setup actions"
1096 echo " fetch : download source archive(s) and patches"
1097 echo " digest : create a digest and a manifest file for the package"
1098 echo " manifest : create a manifest file for the package"
1099 echo " unpack : unpack/patch sources (auto-fetch if needed)"
1100 echo " compile : compile sources (auto-fetch/unpack if needed)"
1101 echo " test : test package (auto-fetch/unpack/compile if needed)"
1102 echo " preinst : execute pre-install instructions"
1103 echo " postinst : execute post-install instructions"
1104 echo " install : install the package to the temporary install directory"
1105 echo " qmerge : merge image into live filesystem, recording files in db"
1106 echo " merge : do fetch, unpack, compile, install and qmerge"
1107 echo " prerm : execute pre-removal instructions"
1108 echo " postrm : execute post-removal instructions"
1109 echo " unmerge : remove package from live filesystem"
1110 echo " config : execute package specific configuration actions"
1111 echo " package : create a tarball package in ${PKGDIR}/All"
1112 echo " rpm : build a RedHat RPM package"
1113 echo " clean : clean up all source and temporary files"
1115 echo "The following settings will be used for the ebuild process:"
1117 echo " package : ${PF}"
1118 echo " slot : ${SLOT}"
1119 echo " category : ${CATEGORY}"
1120 echo " description : ${DESCRIPTION}"
1121 echo " system : ${CHOST}"
1122 echo " c flags : ${CFLAGS}"
1123 echo " c++ flags : ${CXXFLAGS}"
1124 echo " make flags : ${MAKEOPTS}"
1125 echo -n " build mode : "
1126 if hasq nostrip ${FEATURES} ${RESTRICT} || hasq strip ${RESTRICT} ;
1128 echo "debug (large)"
1130 echo "production (stripped)"
1132 echo " merge to : ${ROOT}"
1134 if [ -n "$USE" ]; then
1135 echo "Additionally, support for the following optional features will be enabled:"
1142 # debug-print() gets called from many places with verbose status information useful
1143 # for tracking down problems. The output is in $T/eclass-debug.log.
1144 # You can set ECLASS_DEBUG_OUTPUT to redirect the output somewhere else as well.
1145 # The special "on" setting echoes the information, mixing it with the rest of the
1147 # You can override the setting by exporting a new one from the console, or you can
1148 # set a new default in make.*. Here the default is "" or unset.
1150 # in the future might use e* from /etc/init.d/functions.sh if i feel like it
1152 # if $T isn't defined, we're in dep calculation mode and
1153 # shouldn't do anything
1154 [ ! -d "$T" ] && return 0
1158 # extra user-configurable targets
1159 if [ "$ECLASS_DEBUG_OUTPUT" == "on" ]; then
1161 elif [ -n "$ECLASS_DEBUG_OUTPUT" ]; then
1162 echo "debug: $1" >> $ECLASS_DEBUG_OUTPUT
1166 echo "$1" >> "${T}/eclass-debug.log"
1167 # let the portage user own/write to this file
1168 chmod g+w "${T}/eclass-debug.log" &>/dev/null
1174 # The following 2 functions are debug-print() wrappers
1176 debug-print-function() {
1177 str="$1: entering function"
1179 debug-print "$str, parameters: $*"
1182 debug-print-section() {
1183 debug-print "now in section $*"
1186 # Sources all eclasses in parameters
1187 declare -ix ECLASS_DEPTH=0
1189 ECLASS_DEPTH=$(($ECLASS_DEPTH + 1))
1190 if [[ ${ECLASS_DEPTH} > 1 ]]; then
1191 debug-print "*** Multiple Inheritence (Level: ${ECLASS_DEPTH})"
1203 location="${ECLASSDIR}/${1}.eclass"
1206 # PECLASS is used to restore the ECLASS var after recursion.
1210 if [ "${EBUILD_PHASE}" != "depend" ] && \
1211 [[ ${EBUILD_PHASE} != *rm ]]; then
1212 # This is disabled in the *rm phases because they frequently give
1213 # false alarms due to INHERITED in /var/db/pkg being outdated
1214 # in comparison the the eclasses from the portage tree.
1215 if ! hasq $ECLASS $INHERITED; then
1216 eqawarn "QA Notice: ECLASS '$ECLASS' inherited illegally in $CATEGORY/$PF"
1220 # any future resolution code goes here
1221 if [ -n "$PORTDIR_OVERLAY" ]; then
1223 for overlay in ${PORTDIR_OVERLAY}; do
1224 olocation="${overlay}/eclass/${1}.eclass"
1225 if [ -e "$olocation" ]; then
1226 location="${olocation}"
1227 debug-print " eclass exists: ${location}"
1231 debug-print "inherit: $1 -> $location"
1232 [ ! -e "$location" ] && die "${1}.eclass could not be found by inherit()"
1234 if [ "${location}" == "${olocation}" ] && \
1235 ! hasq "${location}" ${EBUILD_OVERLAY_ECLASSES} ; then
1236 EBUILD_OVERLAY_ECLASSES="${EBUILD_OVERLAY_ECLASSES} ${location}"
1239 #We need to back up the value of DEPEND and RDEPEND to B_DEPEND and B_RDEPEND
1240 #(if set).. and then restore them after the inherit call.
1242 #turn off glob expansion
1245 # Retain the old data and restore it later.
1246 unset B_IUSE B_DEPEND B_RDEPEND B_PDEPEND
1247 [ "${IUSE-unset}" != "unset" ] && B_IUSE="${IUSE}"
1248 [ "${DEPEND-unset}" != "unset" ] && B_DEPEND="${DEPEND}"
1249 [ "${RDEPEND-unset}" != "unset" ] && B_RDEPEND="${RDEPEND}"
1250 [ "${PDEPEND-unset}" != "unset" ] && B_PDEPEND="${PDEPEND}"
1251 unset IUSE DEPEND RDEPEND PDEPEND
1252 #turn on glob expansion
1255 qa_source "$location" || die "died sourcing $location in inherit()"
1257 #turn off glob expansion
1260 # If each var has a value, append it to the global variable E_* to
1261 # be applied after everything is finished. New incremental behavior.
1262 [ "${IUSE-unset}" != "unset" ] && export E_IUSE="${E_IUSE} ${IUSE}"
1263 [ "${DEPEND-unset}" != "unset" ] && export E_DEPEND="${E_DEPEND} ${DEPEND}"
1264 [ "${RDEPEND-unset}" != "unset" ] && export E_RDEPEND="${E_RDEPEND} ${RDEPEND}"
1265 [ "${PDEPEND-unset}" != "unset" ] && export E_PDEPEND="${E_PDEPEND} ${PDEPEND}"
1267 [ "${B_IUSE-unset}" != "unset" ] && IUSE="${B_IUSE}"
1268 [ "${B_IUSE-unset}" != "unset" ] || unset IUSE
1270 [ "${B_DEPEND-unset}" != "unset" ] && DEPEND="${B_DEPEND}"
1271 [ "${B_DEPEND-unset}" != "unset" ] || unset DEPEND
1273 [ "${B_RDEPEND-unset}" != "unset" ] && RDEPEND="${B_RDEPEND}"
1274 [ "${B_RDEPEND-unset}" != "unset" ] || unset RDEPEND
1276 [ "${B_PDEPEND-unset}" != "unset" ] && PDEPEND="${B_PDEPEND}"
1277 [ "${B_PDEPEND-unset}" != "unset" ] || unset PDEPEND
1279 #turn on glob expansion
1282 hasq $1 $INHERITED || export INHERITED="$INHERITED $1"
1284 export ECLASS="$PECLASS"
1288 ((--ECLASS_DEPTH)) # Returns 1 when ECLASS_DEPTH reaches 0.
1292 # Exports stub functions that call the eclass's functions, thereby making them default.
1293 # For example, if ECLASS="base" and you call "EXPORT_FUNCTIONS src_unpack", the following
1294 # code will be eval'd:
1295 # src_unpack() { base_src_unpack; }
1296 EXPORT_FUNCTIONS() {
1297 if [ -z "$ECLASS" ]; then
1298 echo "EXPORT_FUNCTIONS without a defined ECLASS" >&2
1302 debug-print "EXPORT_FUNCTIONS: ${1} -> ${ECLASS}_${1}"
1303 eval "$1() { ${ECLASS}_$1 "\$@" ; }" > /dev/null
1308 # adds all parameters to E_DEPEND and E_RDEPEND, which get added to DEPEND
1309 # and RDEPEND after the ebuild has been processed. This is important to
1310 # allow users to use DEPEND="foo" without frying dependencies added by an
1311 # earlier inherit. It also allows RDEPEND to work properly, since a lot
1312 # of ebuilds assume that an unset RDEPEND gets its value from DEPEND.
1313 # Without eclasses, this is true. But with them, the eclass may set
1314 # RDEPEND itself (or at least used to) which would prevent RDEPEND from
1315 # getting its value from DEPEND. This is a side-effect that made eclasses
1316 # have unreliable dependencies.
1319 debug-print-function newdepend $*
1320 debug-print "newdepend: E_DEPEND=$E_DEPEND E_RDEPEND=$E_RDEPEND"
1322 while [ -n "$1" ]; do
1325 do_newdepend DEPEND sys-devel/autoconf sys-devel/automake sys-devel/make
1328 do_newdepend DEPEND sys-devel/gcc virtual/libc
1329 do_newdepend RDEPEND virtual/libc
1332 do_newdepend DEPEND $1
1340 debug-print-function newrdepend $*
1341 do_newdepend RDEPEND $1
1345 debug-print-function newpdepend $*
1346 do_newdepend PDEPEND $1
1350 # This function does a generic change determining whether we're in an
1351 # eclass or not. If we are, we change the E_* variables for deps.
1352 debug-print-function do_newdepend $*
1353 [ -z "$1" ] && die "do_newdepend without arguments"
1355 # Grab what we're affecting... Figure out if we're affecting eclasses.
1356 [[ ${ECLASS_DEPTH} > 0 ]] && TARGET="E_$1"
1357 [[ ${ECLASS_DEPTH} > 0 ]] || TARGET="$1"
1358 shift # $1 was a variable name.
1360 while [ -n "$1" ]; do
1361 # This bit of evil takes TARGET and uses it to evaluate down to a
1362 # variable. This is a sneaky way to make this infinately expandable.
1363 # The normal translation of this would look something like this:
1364 # E_DEPEND="${E_DEPEND} $1" :::::: Cool, huh? :)
1365 eval export ${TARGET}=\"\${${TARGET}} \$1\"
1370 # this is a function for removing any directory matching a passed in pattern from
1372 remove_path_entry() {
1375 stripped_path="${PATH}"
1376 while [ -n "$1" ]; do
1378 for p in ${stripped_path}; do
1379 if [ "${p/${1}}" == "${p}" ]; then
1380 cur_path="${cur_path}:${p}"
1383 stripped_path="${cur_path#:*}"
1387 PATH="${stripped_path}"
1390 # === === === === === === === === === === === === === === === === === ===
1391 # === === === === === functions end, main part begins === === === === ===
1392 # === === === === === functions end, main part begins === === === === ===
1393 # === === === === === functions end, main part begins === === === === ===
1394 # === === === === === === === === === === === === === === === === === ===
1396 if [[ ${EBUILD_SH_ARGS} != "depend" ]] && [[ ${EBUILD_SH_ARGS} != "clean" ]] && [[ ${EBUILD_SH_ARGS} != "setup" ]]; then
1397 cd ${PORTAGE_TMPDIR} &> /dev/null
1398 cd ${BUILD_PREFIX} &> /dev/null
1400 if [ "$(id -nu)" == "portage" ] ; then
1404 if hasq distcc ${FEATURES} ; then
1405 if [ -d /usr/lib/distcc/bin ]; then
1406 #We can enable distributed compile support
1407 if [ -z "${PATH/*distcc*/}" ]; then
1408 # Remove the other reference.
1409 remove_path_entry "distcc"
1411 export PATH="/usr/lib/distcc/bin:${PATH}"
1412 [ ! -z "${DISTCC_LOG}" ] && addwrite "$(dirname ${DISTCC_LOG})"
1413 elif which distcc &>/dev/null; then
1414 if ! hasq distcc $CC; then
1415 export CC="distcc $CC"
1417 if ! hasq distcc $CXX; then
1418 export CXX="distcc $CXX"
1423 if hasq ccache ${FEATURES} ; then
1424 #We can enable compiler cache support
1425 if [ -z "${PATH/*ccache*/}" ]; then
1426 # Remove the other reference.
1427 remove_path_entry "ccache"
1430 if [ -d /usr/lib/ccache/bin ]; then
1431 export PATH="/usr/lib/ccache/bin:${PATH}"
1432 elif [ -d /usr/bin/ccache ]; then
1433 export PATH="/usr/bin/ccache:${PATH}"
1436 [ -z "${CCACHE_DIR}" ] && export CCACHE_DIR="/var/tmp/ccache"
1438 addread "${CCACHE_DIR}"
1439 addwrite "${CCACHE_DIR}"
1441 [ -n "${CCACHE_SIZE}" ] && ccache -M ${CCACHE_SIZE} &> /dev/null
1443 # Force configure scripts that automatically detect ccache to respect
1444 # FEATURES="-ccache"
1445 export CCACHE_DISABLE=1
1448 # XXX: Load up the helper functions.
1449 # for X in /usr/lib/portage/bin/functions/*.sh; do
1450 # source ${X} || die "Failed to source ${X}"
1457 kill ${PORTAGE_MASTER_PID}
1459 trap "killparent" INT
1461 fi # "$*"!="depend" && "$*"!="clean" && "$*" != "setup"
1463 export SANDBOX_ON="1"
1464 export S=${WORKDIR}/${P}
1466 unset E_IUSE E_DEPEND E_RDEPEND E_PDEPEND
1468 for x in T P PN PV PVR PR CATEGORY A EBUILD EMERGE_FROM O PPID FILESDIR PORTAGE_TMPDIR; do
1469 [[ ${!x-UNSET_VAR} != UNSET_VAR ]] && declare -r ${x}
1471 # Need to be able to change D in dyn_preinst due to the IMAGE stuff
1472 [[ ${EBUILD_SH_ARGS} != "preinst" ]] && declare -r D
1475 # Turn of extended glob matching so that g++ doesn't get incorrectly matched.
1478 QA_INTERCEPTORS="javac java-config python python-config perl grep egrep fgrep sed gcc g++ cc bash awk nawk gawk pkg-config"
1479 # level the QA interceptors if we're in depend
1480 if hasq "depend" "${EBUILD_SH_ARGS}"; then
1481 for BIN in ${QA_INTERCEPTORS}; do
1482 BIN_PATH=$(type -pf ${BIN})
1483 if [ "$?" != "0" ]; then
1484 BODY="echo \"*** missing command: ${BIN}\" >&2; return 127"
1486 BODY="${BIN_PATH} \"\$@\"; return \$?"
1488 FUNC_SRC="${BIN}() {
1489 if [ \$ECLASS_DEPTH -gt 0 ]; then
1490 eqawarn \"QA Notice: '${BIN}' called in global scope: eclass \${ECLASS}\"
1492 eqawarn \"QA Notice: '${BIN}' called in global scope: \${CATEGORY}/\${PF}\"
1496 eval "$FUNC_SRC" || echo "error creating QA interceptor ${BIN}" >&2
1498 unset BIN_PATH BIN BODY FUNC_SRC
1501 # reset the EBUILD_DEATH_HOOKS so they don't multiple due to stable's re-sourcing of env.
1502 # this can be left out of ebd variants, since they're unaffected.
1503 unset EBUILD_DEATH_HOOKS
1505 # *DEPEND and IUSE will be set during the sourcing of the ebuild. In order to
1506 # ensure correct interaction between ebuilds and eclasses, they need to be
1507 # unset before this process of interaction begins.
1508 unset DEPEND RDEPEND PDEPEND IUSE
1510 source ${EBUILD} || die "error sourcing ebuild"
1511 if ! hasq depend $EBUILD_PHASE; then
1512 RESTRICT="${PORTAGE_RESTRICT}"
1513 unset PORTAGE_RESTRICT
1517 # We need to turn off pathname expansion for -* in KEYWORDS and
1518 # we need to escape ~ to avoid tilde expansion
1520 KEYWORDS=$(eval echo ${KEYWORDS//~/\\~})
1523 if hasq nostrip ${FEATURES} ${RESTRICT} || hasq strip ${RESTRICT}
1528 #a reasonable default for $S
1529 if [ "$S" = "" ]; then
1530 export S=${WORKDIR}/${P}
1533 #wipe the interceptors. we don't want saved.
1534 if hasq "depend" "${EBUILD_SH_ARGS}"; then
1535 unset -f $QA_INTERCEPTORS
1536 unset QA_INTERCEPTORS
1539 #some users have $TMP/$TMPDIR to a custom dir in their home ...
1540 #this will cause sandbox errors with some ./configure
1541 #scripts, so set it to $T.
1543 export TMPDIR="${T}"
1545 # Note: this next line is not the same as export RDEPEND=${RDEPEND:-${DEPEND}}
1546 # That will test for unset *or* NULL (""). We want just to set for unset...
1548 #turn off glob expansion from here on in to prevent *'s and ? in the DEPEND
1549 #syntax from getting expanded :)
1550 #check eclass rdepends also.
1552 if [ "${RDEPEND-unset}" == "unset" ] ; then
1553 export RDEPEND=${DEPEND}
1554 debug-print "RDEPEND: not set... Setting to: ${DEPEND}"
1557 #add in dependency info from eclasses
1558 IUSE="$IUSE $E_IUSE"
1559 DEPEND="$DEPEND $E_DEPEND"
1560 RDEPEND="$RDEPEND $E_RDEPEND"
1561 PDEPEND="$PDEPEND $E_PDEPEND"
1563 unset E_IUSE E_DEPEND E_RDEPEND E_PDEPEND
1565 if [ "${EBUILD_PHASE}" != "depend" ]; then
1566 # Make IUSE defaults backward compatible with all the old shell code.
1568 for x in ${IUSE} ; do
1569 if [[ ${x} == +* ]]; then
1570 iuse_temp="${iuse_temp} ${x:1}"
1572 iuse_temp="${iuse_temp} ${x}"
1575 export IUSE=${iuse_temp}
1577 # Lock the dbkey variables after the global phase
1578 declare -r DEPEND RDEPEND SLOT SRC_URI RESTRICT HOMEPAGE LICENSE DESCRIPTION
1579 declare -r KEYWORDS INHERITED IUSE PDEPEND PROVIDE
1584 for myarg in ${EBUILD_SH_ARGS} ; do
1590 prerm|postrm|postinst|config)
1591 export SANDBOX_ON="0"
1592 if [ "$PORTAGE_DEBUG" != "1" ]; then
1593 [ "$(type -t pre_pkg_${myarg})" == "function" ] && qa_call pre_pkg_${myarg}
1594 qa_call pkg_${myarg}
1595 [ "$(type -t post_pkg_${myarg})" == "function" ] && qa_call post_pkg_${myarg}
1596 #Allow non-zero return codes since they can be caused by &&
1599 [ "$(type -t pre_pkg_${myarg})" == "function" ] && qa_call pre_pkg_${myarg}
1600 qa_call pkg_${myarg}
1601 [ "$(type -t post_pkg_${myarg})" == "function" ] && qa_call post_pkg_${myarg}
1602 #Allow non-zero return codes since they can be caused by &&
1606 unpack|compile|test|clean|install)
1607 if [ "${SANDBOX_DISABLED="0"}" == "0" ]; then
1608 export SANDBOX_ON="1"
1610 export SANDBOX_ON="0"
1612 if [ "$PORTAGE_DEBUG" != "1" ]; then
1614 #Allow non-zero return codes since they can be caused by &&
1618 #Allow non-zero return codes since they can be caused by &&
1621 export SANDBOX_ON="0"
1624 #pkg_setup needs to be out of the sandbox for tmp file creation;
1625 #for example, awking and piping a file in /tmp requires a temp file to be created
1626 #in /etc. If pkg_setup is in the sandbox, both our lilo and apache ebuilds break.
1627 export SANDBOX_ON="0"
1628 if [ "$PORTAGE_DEBUG" != "1" ]; then
1637 export SANDBOX_ON="0"
1640 if [ -n "${dbkey}" ] ; then
1641 if [ ! -d "${dbkey%/*}" ]; then
1642 install -d -g ${PORTAGE_GID} -m2775 "${dbkey%/*}"
1644 # Make it group writable. 666&~002==664
1648 auxdbkeys="DEPEND RDEPEND SLOT SRC_URI RESTRICT HOMEPAGE LICENSE
1649 DESCRIPTION KEYWORDS INHERITED IUSE CDEPEND PDEPEND PROVIDE EAPI
1650 UNUSED_01 UNUSED_02 UNUSED_03 UNUSED_04 UNUSED_05 UNUSED_06
1653 #the extra $(echo) commands remove newlines
1655 [ -n "${EAPI}" ] || EAPI=0
1656 if [ -n "${dbkey}" ] ; then
1658 for f in ${auxdbkeys} ; do
1659 echo $(echo ${!f}) >> "${dbkey}" || exit $?
1662 for f in ${auxdbkeys} ; do
1663 echo $(echo ${!f}) 1>&9 || exit $?
1668 #make sure it is writable by our group:
1672 export SANDBOX_ON="1"
1673 echo "Please specify a valid command."
1680 #if [ $? -ne 0 ]; then
1685 # Save the env only for relevant phases.
1686 if [ -n "${myarg}" ] && \
1687 [ "${myarg}" != "clean" ] && \
1688 [ "${myarg}" != "help" ] ; then
1689 # Do not save myarg in the env, or else the above [ -n "$myarg" ] test will
1690 # give a false positive when ebuild.sh is sourced.
1692 # Save current environment and touch a success file. (echo for success)
1694 set | egrep -v "^SANDBOX_" > "${T}/environment" 2>/dev/null
1695 chown portage:portage "${T}/environment" &>/dev/null
1696 chmod g+w "${T}/environment" &>/dev/null
1699 # Do not exit when ebuild.sh is sourced by other scripts.