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 if [ "$*" != "depend" ] && [ "$*" != "clean" ] && [ "$*" != "nofetch" ]; then
22 if [ -f "${T}/environment" ]; then
23 source "${T}/environment" >& /dev/null
27 # These two functions wrap sourcing and calling respectively. At present they
28 # perform a qa check to make sure eclasses and ebuilds and profiles don't mess
29 # with shell opts (shopts). Ebuilds/eclasses changing shopts should reset them
30 # when they are done. Note: For now these shoudl always return success.
33 local shopts=$(shopt) OLDIFS="$IFS"
34 source "$@" || return 1
35 [[ $shopts != $(shopt) ]] &&
36 eqawarn "QA Notice: Global shell options changed and were not restored while sourcing '$*'"
37 [[ "$IFS" != "$OLDIFS" ]] &&
38 eqawarn "QA Notice: Global IFS changed and was not restored while sourcing '$*'"
43 local shopts=$(shopt) OLDIFS="$IFS"
45 [[ $shopts != $(shopt) ]] &&
46 eqawarn "QA Notice: Global shell options changed and were not restored while calling '$*'"
47 [[ "$IFS" != "$OLDIFS" ]] &&
48 eqawarn "QA Notice: Global IFS changed and was not restored while calling '$*'"
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 [ -n "${PORTAGE_LOG_FILE}" ] && \
287 echo "!!! A complete build log is located at '${PORTAGE_LOG_FILE}'." >&2
289 if [ -n "${EBUILD_OVERLAY_ECLASSES}" ] ; then
290 echo "This ebuild used the following eclasses from overlays:" >&2
292 for x in ${EBUILD_OVERLAY_ECLASSES} ; do
298 if [ "${EBUILD_PHASE/depend}" == "${EBUILD_PHASE}" ]; then
300 for x in $EBUILD_DEATH_HOOKS; do
305 # subshell die support
306 kill -s SIGTERM ${EBUILD_MASTER_PID}
310 shopt -s extdebug &> /dev/null
312 # usage- first arg is the number of funcs on the stack to ignore.
313 # defaults to 1 (ignoring dump_trace)
315 local funcname="" sourcefile="" lineno="" n e s="yes"
324 for (( n = ${#FUNCNAME[@]} - 1, p = ${#BASH_ARGV[@]} ; n > $strip ; n-- )) ; do
325 funcname=${FUNCNAME[${n} - 1]}
326 sourcefile=$(basename ${BASH_SOURCE[${n}]})
327 lineno=${BASH_LINENO[${n} - 1]}
328 # Display function arguments
330 if [[ -n "${BASH_ARGV[@]}" ]]; then
331 for (( j = 1 ; j <= ${BASH_ARGC[${n} - 1]} ; ++j )); do
332 newarg=${BASH_ARGV[$(( p - j - 1 ))]}
333 args="${args:+${args} }'${newarg}'"
335 (( p -= ${BASH_ARGC[${n} - 1]} ))
337 echo " ${sourcefile}, line ${lineno}: Called ${funcname}${args:+ ${args}}"
343 #if no perms are specified, dirs/files will have decent defaults
344 #(not secretive, but not stupid)
347 export INSDESTTREE=""
348 export EXEDESTTREE=""
349 export DOCDESTTREE=""
350 export INSOPTIONS="-m0644"
351 export EXEOPTIONS="-m0755"
352 export LIBOPTIONS="-m0644"
353 export DIROPTIONS="-m0755"
354 export MOPREFIX=${PN}
357 if [ -z "${KV}" ]; then
359 eerror "Could not determine your kernel version."
360 eerror "Make sure that you have a /usr/src/linux symlink,"
361 eerror "and that the indicated kernel has been configured."
362 eerror "You can also simply run the following command"
363 eerror "in the directory referenced by /usr/src/linux:"
364 eerror " make include/linux/version.h"
370 # adds ".keep" files so that dirs aren't auto-cleaned
374 if [ "$1" == "-R" ] || [ "$1" == "-r" ]; then
376 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"
379 touch "${D}/${x}/.keep_${CATEGORY}_${PN}-${SLOT}" || die "Failed to create .keep in ${D}/${x}"
389 [ -z "$*" ] && die "Nothing passed to the 'unpack' command"
392 vecho ">>> Unpacking ${x} to ${PWD}"
396 myfail="${x} does not exist"
397 if [ "${x:0:2}" = "./" ] ; then
402 [[ ${x} == ${DISTDIR}* ]] && \
403 die "Arguments to unpack() should not begin with \${DISTDIR}."
404 [ ! -s "${srcdir}${x}" ] && die "$myfail"
406 myfail="failure unpacking ${x}"
409 tar xof "${srcdir}${x}" ${tar_opts} || die "$myfail"
412 tar xozf "${srcdir}${x}" ${tar_opts} || die "$myfail"
415 bzip2 -dc "${srcdir}${x}" | tar xof - ${tar_opts}
419 unzip -qo "${srcdir}${x}" || die "$myfail"
422 if [ "${y}" == "tar" ]; then
423 tar zoxf "${srcdir}${x}" ${tar_opts} || die "$myfail"
425 gzip -dc "${srcdir}${x}" > ${x%.*} || die "$myfail"
429 if [ "${y}" == "tar" ]; then
430 bzip2 -dc "${srcdir}${x}" | tar xof - ${tar_opts}
433 bzip2 -dc "${srcdir}${x}" > ${x%.*} || die "$myfail"
438 my_output="$(7z x -y "${srcdir}/${x}")"
439 if [ $? -ne 0 ]; then
440 echo "${my_output}" >&2
445 unrar x -idq -o+ "${srcdir}/${x}" || die "$myfail"
448 lha xqf "${srcdir}/${x}" || die "$myfail"
451 ar x "${srcdir}/${x}" || die "$myfail"
454 vecho "unpack ${x}: file format not recognized. Ignoring."
458 # Do not chmod '.' since it's probably ${WORKDIR} and PORTAGE_WORKDIR_MODE
459 # should be preserved.
460 find . -mindepth 1 -maxdepth 1 ! -type l -print0 | \
461 ${XARGS} -0 chmod -fR a+rX,u+w,g-w,o-w
464 strip_duplicate_slashes() {
465 if [[ -n $1 ]] ; then
467 while [[ ${removed} == *//* ]] ; do
468 removed=${removed//\/\///}
476 local LOCAL_EXTRA_ECONF="${EXTRA_ECONF}"
478 if [ -z "${ECONF_SOURCE}" ]; then
481 if [ -x "${ECONF_SOURCE}/configure" ]; then
482 if [ -e /usr/share/gnuconfig/ ]; then
483 for x in $(find "${WORKDIR}" -type f '(' -name config.guess -o -name config.sub ')') ; do
484 vecho " * econf: updating ${x/${WORKDIR}\/} with /usr/share/gnuconfig/${x##*/}"
485 cp -f /usr/share/gnuconfig/${x##*/} ${x}
489 if [ ! -z "${CBUILD}" ]; then
490 LOCAL_EXTRA_ECONF="--build=${CBUILD} ${LOCAL_EXTRA_ECONF}"
493 if [ ! -z "${CTARGET}" ]; then
494 LOCAL_EXTRA_ECONF="--target=${CTARGET} ${LOCAL_EXTRA_ECONF}"
497 # if the profile defines a location to install libs to aside from default, pass it on.
498 # if the ebuild passes in --libdir, they're responsible for the conf_libdir fun.
499 LIBDIR_VAR="LIBDIR_${ABI}"
500 if [ -n "${ABI}" -a -n "${!LIBDIR_VAR}" ]; then
501 CONF_LIBDIR="${!LIBDIR_VAR}"
504 if [ -n "${CONF_LIBDIR}" ] && [ "${*/--libdir}" == "$*" ]; then
505 if [ "${*/--exec-prefix}" != "$*" ]; then
506 local args="$(echo $*)"
507 local -a pref=($(echo ${args/*--exec-prefix[= ]}))
509 [ "${CONF_PREFIX:0:1}" != "/" ] && CONF_PREFIX="/${CONF_PREFIX}"
510 elif [ "${*/--prefix}" != "$*" ]; then
511 local args="$(echo $*)"
512 local -a pref=($(echo ${args/*--prefix[= ]}))
514 [ "${CONF_PREFIX:0:1}" != "/" ] && CONF_PREFIX="/${CONF_PREFIX}"
519 [ "${CONF_LIBDIR:0:1}" != "/" ] && CONF_LIBDIR="/${CONF_LIBDIR}"
521 CONF_LIBDIR_RESULT="$(strip_duplicate_slashes ${CONF_PREFIX}${CONF_LIBDIR})"
523 LOCAL_EXTRA_ECONF="--libdir=${CONF_LIBDIR_RESULT} ${LOCAL_EXTRA_ECONF}"
526 local TMP_CONFCACHE_DIR CONFCACHE_ARG
527 if hasq confcache $FEATURES && ! hasq confcache $RESTRICT; then
528 CONFCACHE="$(type -P confcache)"
529 if [ -z "${CONFCACHE}" ]; then
530 ewarn "disabling confcache, binary cannot be found"
532 CONFCACHE="${CONFCACHE/ /\ }"
533 TMP_CONFCACHE_DIR="${CONFCACHE:+${CONFCACHE_DIR:-${PORTAGE_TMPDIR}/confcache}}"
534 TMP_CONFCACHE_DIR="${TMP_CONFCACHE_DIR/ /\ }"
535 CONFCACHE_ARG="--confcache-dir"
537 if [ -n "$CCACHE_DIR" ]; then
540 if [ -n "$DISTCC_DIR" ]; then
541 s="${s:+${s}:}$DISTCC_DIR"
544 CONFCACHE_ARG="--confcache-ignore $s $CONFCACHE_ARG"
551 vecho ${CONFCACHE} ${CONFCACHE_ARG} ${TMP_CONFCACHE_DIR} "${ECONF_SOURCE}/configure" \
554 --mandir=/usr/share/man \
555 --infodir=/usr/share/info \
556 --datadir=/usr/share \
558 --localstatedir=/var/lib \
562 if ! ${CONFCACHE} ${CONFCACHE_ARG} ${TMP_CONFCACHE_DIR} "${ECONF_SOURCE}/configure" \
565 --mandir=/usr/share/man \
566 --infodir=/usr/share/info \
567 --datadir=/usr/share \
569 --localstatedir=/var/lib \
571 ${LOCAL_EXTRA_ECONF}; then
573 if [ -s config.log ]; then
575 echo "!!! Please attach the following file when filing a report to bugs.gentoo.org:"
576 echo "!!! ${PWD}/config.log"
581 die "no configure script found"
586 # CONF_PREFIX is only set if they didn't pass in libdir above.
587 local LOCAL_EXTRA_EINSTALL="${EXTRA_EINSTALL}"
588 LIBDIR_VAR="LIBDIR_${ABI}"
589 if [ -n "${ABI}" -a -n "${!LIBDIR_VAR}" ]; then
590 CONF_LIBDIR="${!LIBDIR_VAR}"
593 if [ -n "${CONF_LIBDIR}" ] && [ "${CONF_PREFIX:-unset}" != "unset" ]; then
594 EI_DESTLIBDIR="${D}/${CONF_PREFIX}/${CONF_LIBDIR}"
595 EI_DESTLIBDIR="$(strip_duplicate_slashes ${EI_DESTLIBDIR})"
596 LOCAL_EXTRA_EINSTALL="libdir=${EI_DESTLIBDIR} ${LOCAL_EXTRA_EINSTALL}"
600 if [ -f ./[mM]akefile -o -f ./GNUmakefile ] ; then
601 if [ "${PORTAGE_DEBUG}" == "1" ]; then
602 make -n prefix="${D}/usr" \
603 datadir="${D}/usr/share" \
604 infodir="${D}/usr/share/info" \
605 localstatedir="${D}/var/lib" \
606 mandir="${D}/usr/share/man" \
607 sysconfdir="${D}/etc" \
608 ${LOCAL_EXTRA_EINSTALL} \
611 make prefix="${D}/usr" \
612 datadir="${D}/usr/share" \
613 infodir="${D}/usr/share/info" \
614 localstatedir="${D}/var/lib" \
615 mandir="${D}/usr/share/man" \
616 sysconfdir="${D}/etc" \
617 ${LOCAL_EXTRA_EINSTALL} \
618 "$@" install || die "einstall failed"
620 die "no Makefile found"
629 [ -z "${SRC_URI}" ] && return
631 echo "!!! The following are listed in SRC_URI for ${PN}:"
633 for x in $(echo ${SRC_URI}); do
639 [[ -n ${A} ]] && unpack ${A}
643 if [ -x ./configure ]; then
646 if [ -f Makefile ] || [ -f GNUmakefile ] || [ -f makefile ]; then
647 emake || die "emake failed"
652 if emake -j1 check -n &> /dev/null; then
653 vecho ">>> Test phase [check]: ${CATEGORY}/${PF}"
654 if ! emake -j1 check; then
655 hasq test $FEATURES && die "Make check failed. See above for details."
656 hasq test $FEATURES || eerror "Make check failed. See above for details."
658 elif emake -j1 test -n &> /dev/null; then
659 vecho ">>> Test phase [test]: ${CATEGORY}/${PF}"
660 if ! emake -j1 test; then
661 hasq test $FEATURES && die "Make test failed. See above for details."
662 hasq test $FEATURES || eerror "Make test failed. See above for details."
665 vecho ">>> Test phase [none]: ${CATEGORY}/${PF}"
690 eerror "This ebuild does not have a config function."
693 # Used to generate the /lib/cpp and /usr/bin/cc wrappers
703 [ "$(type -t pre_pkg_setup)" == "function" ] && qa_call pre_pkg_setup
705 [ "$(type -t post_pkg_setup)" == "function" ] && qa_call post_pkg_setup
709 [ "$(type -t pre_src_unpack)" == "function" ] && qa_call pre_src_unpack
711 if [ -e "${WORKDIR}" ]; then
715 vecho ">>> Checking ${x}'s mtime..."
716 if [ "${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/${x}" -nt "${WORKDIR}" ]; then
717 vecho ">>> ${x} has been updated; recreating WORKDIR..."
722 if [ "${EBUILD}" -nt "${WORKDIR}" ] && ! hasq keepwork ${FEATURES} ; then
723 vecho ">>> ${EBUILD} has been updated; recreating WORKDIR..."
725 elif [ ! -f "${PORTAGE_BUILDDIR}/.unpacked" ]; then
726 vecho ">>> Not marked as unpacked; recreating WORKDIR..."
730 if [ "${newstuff}" == "yes" ]; then
731 # We don't necessarily have privileges to do a full dyn_clean here.
733 if [ -d "${T}" ] && ! hasq keeptemp ${FEATURES} ; then
734 rm -rf "${T}" && mkdir "${T}"
736 [ -e "${T}/environment" ] && \
737 mv "${T}/environment" "${T}/environment.keeptemp"
740 if [ -e "${WORKDIR}" ]; then
741 if [ "$newstuff" == "no" ]; then
742 vecho ">>> WORKDIR is up-to-date, keeping..."
743 [ "$(type -t post_src_unpack)" == "function" ] && qa_call post_src_unpack
748 if [ ! -d "${WORKDIR}" ]; then
749 install -m${PORTAGE_WORKDIR_MODE:-0700} -d "${WORKDIR}" || die "Failed to create dir '${WORKDIR}'"
751 cd "${WORKDIR}" || die "Directory change failed: \`cd '${WORKDIR}'\`"
752 vecho ">>> Unpacking source..."
754 touch "${PORTAGE_BUILDDIR}/.unpacked" || die "IO Failure -- Failed 'touch .unpacked' in ${PORTAGE_BUILDDIR}"
755 vecho ">>> Source unpacked."
756 cd "${PORTAGE_BUILDDIR}"
758 [ "$(type -t post_src_unpack)" == "function" ] && qa_call post_src_unpack
762 if [ -z "${PORTAGE_BUILDDIR}" ]; then
763 echo "Aborting clean phase because PORTAGE_BUILDDIR is unset!"
767 if type -P chflags > /dev/null ; then
768 chflags -R noschg,nouchg,nosappnd,nouappnd "${PORTAGE_BUILDDIR}"
769 chflags -R nosunlnk,nouunlnk "${PORTAGE_BUILDDIR}" 2>/dev/null
772 rm -rf "${PORTAGE_BUILDDIR}/image" "${PORTAGE_BUILDDIR}/homedir"
774 if ! hasq keeptemp $FEATURES; then
777 [ -e "${T}/environment" ] && mv "${T}/environment" "${T}/environment.keeptemp"
780 if ! hasq keepwork $FEATURES; then
781 rm -rf "${PORTAGE_BUILDDIR}/.logid"
782 rm -rf "${PORTAGE_BUILDDIR}/.unpacked"
783 rm -rf "${PORTAGE_BUILDDIR}/.compiled"
784 rm -rf "${PORTAGE_BUILDDIR}/.tested"
785 rm -rf "${PORTAGE_BUILDDIR}/.installed"
786 rm -rf "${PORTAGE_BUILDDIR}/.packaged"
787 rm -rf "${PORTAGE_BUILDDIR}/build-info"
791 if [ -f "${PORTAGE_BUILDDIR}/.unpacked" ]; then
792 find "${PORTAGE_BUILDDIR}" -type d ! -regex "^${WORKDIR}" | sort -r | tr "\n" "\0" | $XARGS -0 rmdir &>/dev/null
795 # do not bind this to doebuild defined DISTDIR; don't trust doebuild, and if mistakes are made it'll
796 # result in it wiping the users distfiles directory (bad).
797 rm -rf "${PORTAGE_BUILDDIR}/distdir"
799 if [ -z "$(find "${PORTAGE_BUILDDIR}" -mindepth 1 -maxdepth 1)" ]; then
800 rmdir "${PORTAGE_BUILDDIR}"
807 if [ "$1" == "/" ]; then
811 if [ ! -d "${D}${DESTTREE}" ]; then
812 install -d "${D}${DESTTREE}"
818 if [ "$1" == "/" ]; then
819 export INSDESTTREE=""
821 export INSDESTTREE=$1
822 if [ ! -d "${D}${INSDESTTREE}" ]; then
823 install -d "${D}${INSDESTTREE}"
829 if [ "$1" == "/" ]; then
830 export EXEDESTTREE=""
832 export EXEDESTTREE="$1"
833 if [ ! -d "${D}${EXEDESTTREE}" ]; then
834 install -d "${D}${EXEDESTTREE}"
840 if [ "$1" == "/" ]; then
841 export DOCDESTTREE=""
843 export DOCDESTTREE="$1"
844 if [ ! -d "${D}usr/share/doc/${PF}/${DOCDESTTREE}" ]; then
845 install -d "${D}usr/share/doc/${PF}/${DOCDESTTREE}"
851 export INSOPTIONS="$@"
853 # `install` should never be called with '-s' ...
854 hasq -s ${INSOPTIONS} && die "Never call insopts() with -s"
858 export DIROPTIONS="$@"
862 export EXEOPTIONS="$@"
864 # `install` should never be called with '-s' ...
865 hasq -s ${EXEOPTIONS} && die "Never call exeopts() with -s"
869 export LIBOPTIONS="$@"
871 # `install` should never be called with '-s' ...
872 hasq -s ${LIBOPTIONS} && die "Never call libopts() with -s"
877 if [ "$2" != "fail" ]; then
878 msg="${EBUILD}: ${1} aborted; exiting."
880 msg="${EBUILD}: ${1} failed; exiting."
886 #unset signal handler
891 abort_handler "src_compile" $1
892 rm -f "${PORTAGE_BUILDDIR}/.compiled"
897 abort_handler "dyn_test" $1
898 rm -f "${PORTAGE_BUILDDIR}/.tested"
903 abort_handler "src_install" $1
904 rm -rf "${PORTAGE_BUILDDIR}/image"
909 trap "abort_compile" SIGINT SIGQUIT
911 [ "$(type -t pre_src_compile)" == "function" ] && qa_call pre_src_compile
913 [ "${CFLAGS-unset}" != "unset" ] && export CFLAGS
914 [ "${CXXFLAGS-unset}" != "unset" ] && export CXXFLAGS
915 [ "${LIBCFLAGS-unset}" != "unset" ] && export LIBCFLAGS
916 [ "${LIBCXXFLAGS-unset}" != "unset" ] && export LIBCXXFLAGS
917 [ "${LDFLAGS-unset}" != "unset" ] && export LDFLAGS
918 [ "${ASFLAGS-unset}" != "unset" ] && export ASFLAGS
920 [ "${CCACHE_DIR-unset}" != "unset" ] && export CCACHE_DIR
921 [ "${CCACHE_SIZE-unset}" != "unset" ] && export CCACHE_SIZE
923 [ "${DISTCC_DIR-unset}" == "unset" ] && export DISTCC_DIR="${PORTAGE_TMPDIR}/.distcc"
924 [ ! -z "${DISTCC_DIR}" ] && addwrite "${DISTCC_DIR}"
926 LIBDIR_VAR="LIBDIR_${ABI}"
927 if [ -z "${PKG_CONFIG_PATH}" -a -n "${ABI}" -a -n "${!LIBDIR_VAR}" ]; then
928 export PKG_CONFIG_PATH="/usr/${!LIBDIR_VAR}/pkgconfig"
932 if hasq noauto $FEATURES && [ ! -f ${PORTAGE_BUILDDIR}/.unpacked ]; then
934 echo "!!! We apparently haven't unpacked... This is probably not what you"
935 echo "!!! want to be doing... You are using FEATURES=noauto so I'll assume"
936 echo "!!! that you know what you are doing... You have 5 seconds to abort..."
940 for x in 1 2 3 4 5 6 7 8; do
948 local srcdir=${PORTAGE_BUILDDIR}
949 cd "${PORTAGE_BUILDDIR}"
950 if [ ! -e "build-info" ]; then
953 cp "${EBUILD}" "build-info/${PF}.ebuild"
955 if [[ ${PORTAGE_BUILDDIR}/.compiled -nt ${WORKDIR} ]] ; then
956 vecho ">>> It appears that '${PF}' is already compiled; skipping."
957 vecho ">>> Remove '${PORTAGE_BUILDDIR}/.compiled' to force compilation."
959 [ "$(type -t post_src_compile)" == "function" ] && qa_call post_src_compile
962 if [ -d "${S}" ]; then
966 #our custom version of libtool uses $S and $D to fix
967 #invalid paths in .la files
969 #some packages use an alternative to $S to build in, cause
970 #our libtool to create problematic .la files
971 export PWORKDIR="$WORKDIR"
972 vecho ">>> Compiling source in ${srcdir} ..."
974 vecho ">>> Source compiled."
975 #|| abort_compile "fail"
976 cd "${PORTAGE_BUILDDIR}"
981 for f in ASFLAGS CATEGORY CBUILD CC CFLAGS CHOST CTARGET CXX \
982 CXXFLAGS DEPEND EXTRA_ECONF EXTRA_EINSTALL EXTRA_MAKE \
983 FEATURES INHERITED IUSE LDFLAGS LIBCFLAGS LIBCXXFLAGS \
984 LICENSE PDEPEND PF PKGUSE PROVIDE RDEPEND RESTRICT SLOT \
985 KEYWORDS HOMEPAGE SRC_URI DESCRIPTION; do
986 [ -n "${!f}" ] && echo $(echo "${!f}" | tr '\n,\r,\t' ' , , ' | sed s/' \+'/' '/g) > ${f}
989 echo "${EAPI:-0}" > EAPI
992 export | sed 's:^declare -rx:declare -x:' >> environment
993 bzip2 -f9 environment
995 cp "${EBUILD}" "${PF}.ebuild"
996 if hasq nostrip ${FEATURES} ${RESTRICT} || hasq strip ${RESTRICT}
1001 [ "$(type -t post_src_compile)" == "function" ] && qa_call post_src_compile
1007 if [ "${EBUILD_FORCE_TEST}" == "1" ] ; then
1008 rm -f "${PORTAGE_BUILDDIR}/.tested"
1009 # If USE came from ${T}/environment then it might not have USE=test
1010 # like it's supposed to here.
1011 ! hasq test ${USE} && export USE="${USE} test"
1013 [ "$(type -t pre_src_test)" == "function" ] && qa_call pre_src_test
1014 if [ "${PORTAGE_BUILDDIR}/.tested" -nt "${WORKDIR}" ]; then
1015 vecho ">>> It appears that ${PN} has already been tested; skipping."
1016 [ "$(type -t post_src_test)" == "function" ] && qa_call post_src_test
1019 trap "abort_test" SIGINT SIGQUIT
1020 if [ -d "${S}" ]; then
1023 if ! hasq test $FEATURES && [ "${EBUILD_FORCE_TEST}" != "1" ]; then
1024 vecho ">>> Test phase [not enabled]: ${CATEGORY}/${PF}"
1025 elif ! hasq test ${USE} && [ "${EBUILD_FORCE_TEST}" != "1" ]; then
1026 ewarn "Skipping make test/check since USE=test is masked."
1027 vecho ">>> Test phase [explicitly disabled]: ${CATEGORY}/${PF}"
1028 elif hasq test $RESTRICT; then
1029 ewarn "Skipping make test/check due to ebuild restriction."
1030 vecho ">>> Test phase [explicitly disabled]: ${CATEGORY}/${PF}"
1034 SANDBOX_PREDICT="${SANDBOX_PREDICT%:/}"
1037 cd "${PORTAGE_BUILDDIR}"
1038 touch .tested || die "Failed to 'touch .tested' in ${PORTAGE_BUILDDIR}"
1039 [ "$(type -t post_src_test)" == "function" ] && qa_call post_src_test
1044 [ -z "$PORTAGE_BUILDDIR" ] && die "${FUNCNAME}: PORTAGE_BUILDDIR is unset"
1045 if hasq noauto $FEATURES ; then
1046 rm -f "${PORTAGE_BUILDDIR}/.installed"
1047 elif [[ ${PORTAGE_BUILDDIR}/.installed -nt ${WORKDIR} ]] ; then
1048 vecho ">>> It appears that '${PF}' is already installed; skipping."
1049 vecho ">>> Remove '${PORTAGE_BUILDDIR}/.installed' to force install."
1052 trap "abort_install" SIGINT SIGQUIT
1053 [ "$(type -t pre_src_install)" == "function" ] && qa_call pre_src_install
1054 rm -rf "${PORTAGE_BUILDDIR}/image"
1055 mkdir "${PORTAGE_BUILDDIR}/image"
1056 if [ -d "${S}" ]; then
1060 vecho ">>> Install ${PF} into ${D} category ${CATEGORY}"
1061 #our custom version of libtool uses $S and $D to fix
1062 #invalid paths in .la files
1064 #some packages uses an alternative to $S to build in, cause
1065 #our libtool to create problematic .la files
1066 export PWORKDIR="$WORKDIR"
1068 touch "${PORTAGE_BUILDDIR}/.installed"
1069 vecho ">>> Completed installing ${PF} into ${D}"
1071 cd ${PORTAGE_BUILDDIR}
1072 [ "$(type -t post_src_install)" == "function" ] && qa_call post_src_install
1077 if [ -z "$IMAGE" ]; then
1078 eerror "${FUNCNAME}: IMAGE is unset"
1082 [ "$(type -t pre_pkg_preinst)" == "function" ] && qa_call pre_pkg_preinst
1084 declare -r D=${IMAGE}
1087 [ "$(type -t post_pkg_preinst)" == "function" ] && qa_call post_pkg_preinst
1093 echo "Copyright 1999-2006 Gentoo Foundation"
1095 echo "How to use the ebuild command:"
1097 echo "The first argument to ebuild should be an existing .ebuild file."
1099 echo "One or more of the following options can then be specified. If more"
1100 echo "than one option is specified, each will be executed in order."
1102 echo " help : show this help screen"
1103 echo " setup : execute package specific setup actions"
1104 echo " fetch : download source archive(s) and patches"
1105 echo " digest : create a digest and a manifest file for the package"
1106 echo " manifest : create a manifest file for the package"
1107 echo " unpack : unpack/patch sources (auto-fetch if needed)"
1108 echo " compile : compile sources (auto-fetch/unpack if needed)"
1109 echo " test : test package (auto-fetch/unpack/compile if needed)"
1110 echo " preinst : execute pre-install instructions"
1111 echo " postinst : execute post-install instructions"
1112 echo " install : install the package to the temporary install directory"
1113 echo " qmerge : merge image into live filesystem, recording files in db"
1114 echo " merge : do fetch, unpack, compile, install and qmerge"
1115 echo " prerm : execute pre-removal instructions"
1116 echo " postrm : execute post-removal instructions"
1117 echo " unmerge : remove package from live filesystem"
1118 echo " config : execute package specific configuration actions"
1119 echo " package : create a tarball package in ${PKGDIR}/All"
1120 echo " rpm : build a RedHat RPM package"
1121 echo " clean : clean up all source and temporary files"
1123 echo "The following settings will be used for the ebuild process:"
1125 echo " package : ${PF}"
1126 echo " slot : ${SLOT}"
1127 echo " category : ${CATEGORY}"
1128 echo " description : ${DESCRIPTION}"
1129 echo " system : ${CHOST}"
1130 echo " c flags : ${CFLAGS}"
1131 echo " c++ flags : ${CXXFLAGS}"
1132 echo " make flags : ${MAKEOPTS}"
1133 echo -n " build mode : "
1134 if hasq nostrip ${FEATURES} ${RESTRICT} || hasq strip ${RESTRICT} ;
1136 echo "debug (large)"
1138 echo "production (stripped)"
1140 echo " merge to : ${ROOT}"
1142 if [ -n "$USE" ]; then
1143 echo "Additionally, support for the following optional features will be enabled:"
1150 # debug-print() gets called from many places with verbose status information useful
1151 # for tracking down problems. The output is in $T/eclass-debug.log.
1152 # You can set ECLASS_DEBUG_OUTPUT to redirect the output somewhere else as well.
1153 # The special "on" setting echoes the information, mixing it with the rest of the
1155 # You can override the setting by exporting a new one from the console, or you can
1156 # set a new default in make.*. Here the default is "" or unset.
1158 # in the future might use e* from /etc/init.d/functions.sh if i feel like it
1160 # if $T isn't defined, we're in dep calculation mode and
1161 # shouldn't do anything
1162 [ ! -d "$T" ] && return 0
1166 # extra user-configurable targets
1167 if [ "$ECLASS_DEBUG_OUTPUT" == "on" ]; then
1169 elif [ -n "$ECLASS_DEBUG_OUTPUT" ]; then
1170 echo "debug: $1" >> $ECLASS_DEBUG_OUTPUT
1174 echo "$1" >> "${T}/eclass-debug.log"
1175 # let the portage user own/write to this file
1176 chmod g+w "${T}/eclass-debug.log" &>/dev/null
1182 # The following 2 functions are debug-print() wrappers
1184 debug-print-function() {
1185 str="$1: entering function"
1187 debug-print "$str, parameters: $*"
1190 debug-print-section() {
1191 debug-print "now in section $*"
1194 # Sources all eclasses in parameters
1195 declare -ix ECLASS_DEPTH=0
1197 ECLASS_DEPTH=$(($ECLASS_DEPTH + 1))
1198 if [[ ${ECLASS_DEPTH} > 1 ]]; then
1199 debug-print "*** Multiple Inheritence (Level: ${ECLASS_DEPTH})"
1211 location="${ECLASSDIR}/${1}.eclass"
1214 # PECLASS is used to restore the ECLASS var after recursion.
1218 if [ "${EBUILD_PHASE}" != "depend" ] && \
1219 [[ ${EBUILD_PHASE} != *rm ]]; then
1220 # This is disabled in the *rm phases because they frequently give
1221 # false alarms due to INHERITED in /var/db/pkg being outdated
1222 # in comparison the the eclasses from the portage tree.
1223 if ! hasq $ECLASS $INHERITED; then
1224 eqawarn "QA Notice: ECLASS '$ECLASS' inherited illegally in $CATEGORY/$PF"
1228 # any future resolution code goes here
1229 if [ -n "$PORTDIR_OVERLAY" ]; then
1231 for overlay in ${PORTDIR_OVERLAY}; do
1232 olocation="${overlay}/eclass/${1}.eclass"
1233 if [ -e "$olocation" ]; then
1234 location="${olocation}"
1235 debug-print " eclass exists: ${location}"
1239 debug-print "inherit: $1 -> $location"
1240 [ ! -e "$location" ] && die "${1}.eclass could not be found by inherit()"
1242 if [ "${location}" == "${olocation}" ] && \
1243 ! hasq "${location}" ${EBUILD_OVERLAY_ECLASSES} ; then
1244 EBUILD_OVERLAY_ECLASSES="${EBUILD_OVERLAY_ECLASSES} ${location}"
1247 #We need to back up the value of DEPEND and RDEPEND to B_DEPEND and B_RDEPEND
1248 #(if set).. and then restore them after the inherit call.
1250 #turn off glob expansion
1253 # Retain the old data and restore it later.
1254 unset B_IUSE B_DEPEND B_RDEPEND B_PDEPEND
1255 [ "${IUSE-unset}" != "unset" ] && B_IUSE="${IUSE}"
1256 [ "${DEPEND-unset}" != "unset" ] && B_DEPEND="${DEPEND}"
1257 [ "${RDEPEND-unset}" != "unset" ] && B_RDEPEND="${RDEPEND}"
1258 [ "${PDEPEND-unset}" != "unset" ] && B_PDEPEND="${PDEPEND}"
1259 unset IUSE DEPEND RDEPEND PDEPEND
1260 #turn on glob expansion
1263 qa_source "$location" || die "died sourcing $location in inherit()"
1265 #turn off glob expansion
1268 # If each var has a value, append it to the global variable E_* to
1269 # be applied after everything is finished. New incremental behavior.
1270 [ "${IUSE-unset}" != "unset" ] && export E_IUSE="${E_IUSE} ${IUSE}"
1271 [ "${DEPEND-unset}" != "unset" ] && export E_DEPEND="${E_DEPEND} ${DEPEND}"
1272 [ "${RDEPEND-unset}" != "unset" ] && export E_RDEPEND="${E_RDEPEND} ${RDEPEND}"
1273 [ "${PDEPEND-unset}" != "unset" ] && export E_PDEPEND="${E_PDEPEND} ${PDEPEND}"
1275 [ "${B_IUSE-unset}" != "unset" ] && IUSE="${B_IUSE}"
1276 [ "${B_IUSE-unset}" != "unset" ] || unset IUSE
1278 [ "${B_DEPEND-unset}" != "unset" ] && DEPEND="${B_DEPEND}"
1279 [ "${B_DEPEND-unset}" != "unset" ] || unset DEPEND
1281 [ "${B_RDEPEND-unset}" != "unset" ] && RDEPEND="${B_RDEPEND}"
1282 [ "${B_RDEPEND-unset}" != "unset" ] || unset RDEPEND
1284 [ "${B_PDEPEND-unset}" != "unset" ] && PDEPEND="${B_PDEPEND}"
1285 [ "${B_PDEPEND-unset}" != "unset" ] || unset PDEPEND
1287 #turn on glob expansion
1290 hasq $1 $INHERITED || export INHERITED="$INHERITED $1"
1292 export ECLASS="$PECLASS"
1296 ((--ECLASS_DEPTH)) # Returns 1 when ECLASS_DEPTH reaches 0.
1300 # Exports stub functions that call the eclass's functions, thereby making them default.
1301 # For example, if ECLASS="base" and you call "EXPORT_FUNCTIONS src_unpack", the following
1302 # code will be eval'd:
1303 # src_unpack() { base_src_unpack; }
1304 EXPORT_FUNCTIONS() {
1305 if [ -z "$ECLASS" ]; then
1306 echo "EXPORT_FUNCTIONS without a defined ECLASS" >&2
1310 debug-print "EXPORT_FUNCTIONS: ${1} -> ${ECLASS}_${1}"
1311 eval "$1() { ${ECLASS}_$1 "\$@" ; }" > /dev/null
1316 # adds all parameters to E_DEPEND and E_RDEPEND, which get added to DEPEND
1317 # and RDEPEND after the ebuild has been processed. This is important to
1318 # allow users to use DEPEND="foo" without frying dependencies added by an
1319 # earlier inherit. It also allows RDEPEND to work properly, since a lot
1320 # of ebuilds assume that an unset RDEPEND gets its value from DEPEND.
1321 # Without eclasses, this is true. But with them, the eclass may set
1322 # RDEPEND itself (or at least used to) which would prevent RDEPEND from
1323 # getting its value from DEPEND. This is a side-effect that made eclasses
1324 # have unreliable dependencies.
1327 debug-print-function newdepend $*
1328 debug-print "newdepend: E_DEPEND=$E_DEPEND E_RDEPEND=$E_RDEPEND"
1330 while [ -n "$1" ]; do
1333 do_newdepend DEPEND sys-devel/autoconf sys-devel/automake sys-devel/make
1336 do_newdepend DEPEND sys-devel/gcc virtual/libc
1337 do_newdepend RDEPEND virtual/libc
1340 do_newdepend DEPEND $1
1348 debug-print-function newrdepend $*
1349 do_newdepend RDEPEND $1
1353 debug-print-function newpdepend $*
1354 do_newdepend PDEPEND $1
1358 # This function does a generic change determining whether we're in an
1359 # eclass or not. If we are, we change the E_* variables for deps.
1360 debug-print-function do_newdepend $*
1361 [ -z "$1" ] && die "do_newdepend without arguments"
1363 # Grab what we're affecting... Figure out if we're affecting eclasses.
1364 [[ ${ECLASS_DEPTH} > 0 ]] && TARGET="E_$1"
1365 [[ ${ECLASS_DEPTH} > 0 ]] || TARGET="$1"
1366 shift # $1 was a variable name.
1368 while [ -n "$1" ]; do
1369 # This bit of evil takes TARGET and uses it to evaluate down to a
1370 # variable. This is a sneaky way to make this infinately expandable.
1371 # The normal translation of this would look something like this:
1372 # E_DEPEND="${E_DEPEND} $1" :::::: Cool, huh? :)
1373 eval export ${TARGET}=\"\${${TARGET}} \$1\"
1378 # this is a function for removing any directory matching a passed in pattern from
1380 remove_path_entry() {
1383 stripped_path="${PATH}"
1384 while [ -n "$1" ]; do
1386 for p in ${stripped_path}; do
1387 if [ "${p/${1}}" == "${p}" ]; then
1388 cur_path="${cur_path}:${p}"
1391 stripped_path="${cur_path#:*}"
1395 PATH="${stripped_path}"
1398 # === === === === === === === === === === === === === === === === === ===
1399 # === === === === === functions end, main part begins === === === === ===
1400 # === === === === === functions end, main part begins === === === === ===
1401 # === === === === === functions end, main part begins === === === === ===
1402 # === === === === === === === === === === === === === === === === === ===
1404 if [[ ${EBUILD_SH_ARGS} != "depend" ]] && [[ ${EBUILD_SH_ARGS} != "clean" ]] && [[ ${EBUILD_SH_ARGS} != "setup" ]]; then
1405 cd ${PORTAGE_TMPDIR} &> /dev/null
1406 cd ${BUILD_PREFIX} &> /dev/null
1408 if [ "$(id -nu)" == "portage" ] ; then
1412 if hasq distcc ${FEATURES} ; then
1413 if [ -d /usr/lib/distcc/bin ]; then
1414 #We can enable distributed compile support
1415 if [ -z "${PATH/*distcc*/}" ]; then
1416 # Remove the other reference.
1417 remove_path_entry "distcc"
1419 export PATH="/usr/lib/distcc/bin:${PATH}"
1420 [ ! -z "${DISTCC_LOG}" ] && addwrite "$(dirname ${DISTCC_LOG})"
1421 elif which distcc &>/dev/null; then
1422 if ! hasq distcc $CC; then
1423 export CC="distcc $CC"
1425 if ! hasq distcc $CXX; then
1426 export CXX="distcc $CXX"
1431 if hasq ccache ${FEATURES} ; then
1432 #We can enable compiler cache support
1433 if [ -z "${PATH/*ccache*/}" ]; then
1434 # Remove the other reference.
1435 remove_path_entry "ccache"
1438 if [ -d /usr/lib/ccache/bin ]; then
1439 export PATH="/usr/lib/ccache/bin:${PATH}"
1440 elif [ -d /usr/bin/ccache ]; then
1441 export PATH="/usr/bin/ccache:${PATH}"
1444 [ -z "${CCACHE_DIR}" ] && export CCACHE_DIR="/var/tmp/ccache"
1446 addread "${CCACHE_DIR}"
1447 addwrite "${CCACHE_DIR}"
1449 [ -n "${CCACHE_SIZE}" ] && ccache -M ${CCACHE_SIZE} &> /dev/null
1451 # Force configure scripts that automatically detect ccache to respect
1452 # FEATURES="-ccache"
1453 export CCACHE_DISABLE=1
1456 # XXX: Load up the helper functions.
1457 # for X in /usr/lib/portage/bin/functions/*.sh; do
1458 # source ${X} || die "Failed to source ${X}"
1465 kill ${PORTAGE_MASTER_PID}
1467 trap "killparent" INT
1469 fi # "$*"!="depend" && "$*"!="clean" && "$*" != "setup"
1471 export SANDBOX_ON="1"
1472 export S=${WORKDIR}/${P}
1474 unset E_IUSE E_DEPEND E_RDEPEND E_PDEPEND
1476 for x in T P PN PV PVR PR CATEGORY A EBUILD EMERGE_FROM O PPID FILESDIR PORTAGE_TMPDIR; do
1477 [[ ${!x-UNSET_VAR} != UNSET_VAR ]] && declare -r ${x}
1479 # Need to be able to change D in dyn_preinst due to the IMAGE stuff
1480 [[ ${EBUILD_SH_ARGS} != "preinst" ]] && declare -r D
1483 # Turn of extended glob matching so that g++ doesn't get incorrectly matched.
1486 QA_INTERCEPTORS="javac java-config python python-config perl grep egrep fgrep sed gcc g++ cc bash awk nawk gawk pkg-config"
1487 # level the QA interceptors if we're in depend
1488 if hasq "depend" "${EBUILD_SH_ARGS}"; then
1489 for BIN in ${QA_INTERCEPTORS}; do
1490 BIN_PATH=$(type -Pf ${BIN})
1491 if [ "$?" != "0" ]; then
1492 BODY="echo \"*** missing command: ${BIN}\" >&2; return 127"
1494 BODY="${BIN_PATH} \"\$@\"; return \$?"
1496 FUNC_SRC="${BIN}() {
1497 if [ \$ECLASS_DEPTH -gt 0 ]; then
1498 eqawarn \"QA Notice: '${BIN}' called in global scope: eclass \${ECLASS}\"
1500 eqawarn \"QA Notice: '${BIN}' called in global scope: \${CATEGORY}/\${PF}\"
1504 eval "$FUNC_SRC" || echo "error creating QA interceptor ${BIN}" >&2
1506 unset BIN_PATH BIN BODY FUNC_SRC
1509 # reset the EBUILD_DEATH_HOOKS so they don't multiple due to stable's re-sourcing of env.
1510 # this can be left out of ebd variants, since they're unaffected.
1511 unset EBUILD_DEATH_HOOKS
1513 # *DEPEND and IUSE will be set during the sourcing of the ebuild. In order to
1514 # ensure correct interaction between ebuilds and eclasses, they need to be
1515 # unset before this process of interaction begins.
1516 unset DEPEND RDEPEND PDEPEND IUSE
1518 source ${EBUILD} || die "error sourcing ebuild"
1519 if ! hasq depend $EBUILD_PHASE; then
1520 RESTRICT="${PORTAGE_RESTRICT}"
1521 unset PORTAGE_RESTRICT
1525 # We need to turn off pathname expansion for -* in KEYWORDS and
1526 # we need to escape ~ to avoid tilde expansion
1528 KEYWORDS=$(eval echo ${KEYWORDS//~/\\~})
1531 if hasq nostrip ${FEATURES} ${RESTRICT} || hasq strip ${RESTRICT}
1536 #a reasonable default for $S
1537 if [ "$S" = "" ]; then
1538 export S=${WORKDIR}/${P}
1541 #wipe the interceptors. we don't want saved.
1542 if hasq "depend" "${EBUILD_SH_ARGS}"; then
1543 unset -f $QA_INTERCEPTORS
1544 unset QA_INTERCEPTORS
1547 #some users have $TMP/$TMPDIR to a custom dir in their home ...
1548 #this will cause sandbox errors with some ./configure
1549 #scripts, so set it to $T.
1551 export TMPDIR="${T}"
1553 # Note: this next line is not the same as export RDEPEND=${RDEPEND:-${DEPEND}}
1554 # That will test for unset *or* NULL (""). We want just to set for unset...
1556 #turn off glob expansion from here on in to prevent *'s and ? in the DEPEND
1557 #syntax from getting expanded :)
1558 #check eclass rdepends also.
1560 if [ "${RDEPEND-unset}" == "unset" ] ; then
1561 export RDEPEND=${DEPEND}
1562 debug-print "RDEPEND: not set... Setting to: ${DEPEND}"
1565 #add in dependency info from eclasses
1566 IUSE="$IUSE $E_IUSE"
1567 DEPEND="$DEPEND $E_DEPEND"
1568 RDEPEND="$RDEPEND $E_RDEPEND"
1569 PDEPEND="$PDEPEND $E_PDEPEND"
1571 unset E_IUSE E_DEPEND E_RDEPEND E_PDEPEND
1573 if [ "${EBUILD_PHASE}" != "depend" ]; then
1574 # Make IUSE defaults backward compatible with all the old shell code.
1576 for x in ${IUSE} ; do
1577 if [[ ${x} == +* ]]; then
1578 iuse_temp="${iuse_temp} ${x:1}"
1580 iuse_temp="${iuse_temp} ${x}"
1583 export IUSE=${iuse_temp}
1585 # Lock the dbkey variables after the global phase
1586 declare -r DEPEND RDEPEND SLOT SRC_URI RESTRICT HOMEPAGE LICENSE DESCRIPTION
1587 declare -r KEYWORDS INHERITED IUSE PDEPEND PROVIDE
1592 for myarg in ${EBUILD_SH_ARGS} ; do
1598 prerm|postrm|postinst|config)
1599 export SANDBOX_ON="0"
1600 if [ "$PORTAGE_DEBUG" != "1" ]; then
1601 [ "$(type -t pre_pkg_${myarg})" == "function" ] && qa_call pre_pkg_${myarg}
1602 qa_call pkg_${myarg}
1603 [ "$(type -t post_pkg_${myarg})" == "function" ] && qa_call post_pkg_${myarg}
1604 #Allow non-zero return codes since they can be caused by &&
1607 [ "$(type -t pre_pkg_${myarg})" == "function" ] && qa_call pre_pkg_${myarg}
1608 qa_call pkg_${myarg}
1609 [ "$(type -t post_pkg_${myarg})" == "function" ] && qa_call post_pkg_${myarg}
1610 #Allow non-zero return codes since they can be caused by &&
1614 unpack|compile|test|clean|install)
1615 if [ "${SANDBOX_DISABLED="0"}" == "0" ]; then
1616 export SANDBOX_ON="1"
1618 export SANDBOX_ON="0"
1620 if [ "$PORTAGE_DEBUG" != "1" ]; then
1622 #Allow non-zero return codes since they can be caused by &&
1626 #Allow non-zero return codes since they can be caused by &&
1629 export SANDBOX_ON="0"
1632 #pkg_setup needs to be out of the sandbox for tmp file creation;
1633 #for example, awking and piping a file in /tmp requires a temp file to be created
1634 #in /etc. If pkg_setup is in the sandbox, both our lilo and apache ebuilds break.
1635 export SANDBOX_ON="0"
1636 if [ "$PORTAGE_DEBUG" != "1" ]; then
1645 export SANDBOX_ON="0"
1648 if [ -n "${dbkey}" ] ; then
1649 if [ ! -d "${dbkey%/*}" ]; then
1650 install -d -g ${PORTAGE_GID} -m2775 "${dbkey%/*}"
1652 # Make it group writable. 666&~002==664
1656 auxdbkeys="DEPEND RDEPEND SLOT SRC_URI RESTRICT HOMEPAGE LICENSE
1657 DESCRIPTION KEYWORDS INHERITED IUSE CDEPEND PDEPEND PROVIDE EAPI
1658 UNUSED_01 UNUSED_02 UNUSED_03 UNUSED_04 UNUSED_05 UNUSED_06
1661 #the extra $(echo) commands remove newlines
1663 [ -n "${EAPI}" ] || EAPI=0
1664 if [ -n "${dbkey}" ] ; then
1666 for f in ${auxdbkeys} ; do
1667 echo $(echo ${!f}) >> "${dbkey}" || exit $?
1670 for f in ${auxdbkeys} ; do
1671 echo $(echo ${!f}) 1>&9 || exit $?
1676 #make sure it is writable by our group:
1680 export SANDBOX_ON="1"
1681 echo "Please specify a valid command."
1688 #if [ $? -ne 0 ]; then
1693 # Save the env only for relevant phases.
1694 if [ -n "${myarg}" ] && \
1695 [ "${myarg}" != "clean" ] && \
1696 [ "${myarg}" != "help" ] ; then
1697 # Do not save myarg in the env, or else the above [ -n "$myarg" ] test will
1698 # give a false positive when ebuild.sh is sourced.
1700 # Save current environment and touch a success file. (echo for success)
1702 set | egrep -v "^SANDBOX_" > "${T}/environment" 2>/dev/null
1703 export | egrep -v "^declare -x SANDBOX_" | \
1704 sed 's:^declare -rx:declare -x:' >> "${T}/environment" 2>/dev/null
1705 chown portage:portage "${T}/environment" &>/dev/null
1706 chmod g+w "${T}/environment" &>/dev/null
1709 # Do not exit when ebuild.sh is sourced by other scripts.