2 # Copyright 1999-2013 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
5 PORTAGE_BIN_PATH="${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"
6 PORTAGE_PYM_PATH="${PORTAGE_PYM_PATH:-/usr/lib/portage/pym}"
8 # Prevent aliases from causing portage to act inappropriately.
9 # Make sure it's before everything so we don't mess aliases that follow.
12 source "${PORTAGE_BIN_PATH}/isolated-functions.sh" || exit 1
14 if [[ $EBUILD_PHASE != depend ]] ; then
15 source "${PORTAGE_BIN_PATH}/phase-functions.sh" || die
16 source "${PORTAGE_BIN_PATH}/save-ebuild-env.sh" || die
17 source "${PORTAGE_BIN_PATH}/phase-helpers.sh" || die
18 source "${PORTAGE_BIN_PATH}/bashrc-functions.sh" || die
20 # These dummy functions are for things that are likely to be called
21 # in global scope, even though they are completely useless during
23 for x in diropts docompress exeopts get_KV insopts \
24 KV_major KV_micro KV_minor KV_to_int \
25 libopts register_die_hook register_success_hook \
26 __strip_duplicate_slashes \
27 use_with use_enable ; do
29 if ___eapi_disallows_helpers_in_global_scope; then
30 die \"\${FUNCNAME}() calls are not allowed in global scope\"
34 # These dummy functions return false in non-strict EAPIs, in order to ensure that
35 # `use multislot` is false for the "depend" phase.
37 ___eapi_has_usex && funcs+=" usex"
38 for x in ${funcs} ; do
40 if ___eapi_disallows_helpers_in_global_scope; then
41 die \"\${FUNCNAME}() calls are not allowed in global scope\"
47 # These functions die because calls to them during the "depend" phase
48 # are considered to be severe QA violations.
49 funcs="best_version has_version portageq"
50 ___eapi_has_master_repositories && funcs+=" master_repositories"
51 ___eapi_has_repository_path && funcs+=" repository_path"
52 ___eapi_has_available_eclasses && funcs+=" available_eclasses"
53 ___eapi_has_eclass_path && funcs+=" eclass_path"
54 ___eapi_has_license_path && funcs+=" license_path"
55 for x in ${funcs} ; do
56 eval "${x}() { die \"\${FUNCNAME}() calls are not allowed in global scope\"; }"
61 # Don't use sandbox's BASH_ENV for new shells because it does
62 # 'source /etc/profile' which can interfere with the build
63 # environment by modifying our PATH.
66 # This is just a temporary workaround for portage-9999 users since
67 # earlier portage versions do not detect a version change in this case
68 # (9999 to 9999) and therefore they try execute an incompatible version of
69 # ebuild.sh during the upgrade.
70 export PORTAGE_BZIP2_COMMAND=${PORTAGE_BZIP2_COMMAND:-bzip2}
72 # These two functions wrap sourcing and calling respectively. At present they
73 # perform a qa check to make sure eclasses and ebuilds and profiles don't mess
74 # with shell opts (shopts). Ebuilds/eclasses changing shopts should reset them
78 local shopts=$(shopt) OLDIFS="$IFS"
83 [[ $shopts != $(shopt) ]] &&
84 eqawarn "QA Notice: Global shell options changed and were not restored while sourcing '$*'"
85 [[ "$IFS" != "$OLDIFS" ]] &&
86 eqawarn "QA Notice: Global IFS changed and was not restored while sourcing '$*'"
91 local shopts=$(shopt) OLDIFS="$IFS"
96 [[ $shopts != $(shopt) ]] &&
97 eqawarn "QA Notice: Global shell options changed and were not restored while calling '$*'"
98 [[ "$IFS" != "$OLDIFS" ]] &&
99 eqawarn "QA Notice: Global IFS changed and was not restored while calling '$*'"
107 # Unset some variables that break things.
108 unset GZIP BZIP BZIP2 CDPATH GREP_OPTIONS GREP_COLOR GLOBIGNORE
110 [[ $PORTAGE_QUIET != "" ]] && export PORTAGE_QUIET
112 # sandbox support functions; defined prior to profile.bashrc srcing, since the profile might need to add a default exception (/usr/lib64/conftest fex)
115 local var="SANDBOX_${_v}"
116 [[ -z $1 || -n $2 ]] && die "Usage: add$(LC_ALL=C tr "[:upper:]" "[:lower:]" <<< "${_v}") <colon-delimited list of paths>"
117 export ${var}="${!var:+${!var}:}$1"
120 # local var="SANDBOX_${1^^}"
121 # addread() { __sb_append_var ${0#add} "$@" ; }
122 addread() { __sb_append_var READ "$@" ; }
123 addwrite() { __sb_append_var WRITE "$@" ; }
124 adddeny() { __sb_append_var DENY "$@" ; }
125 addpredict() { __sb_append_var PREDICT "$@" ; }
127 addwrite "${PORTAGE_TMPDIR}"
128 addread "/:${PORTAGE_TMPDIR}"
129 [[ -n ${PORTAGE_GPG_DIR} ]] && addpredict "${PORTAGE_GPG_DIR}"
131 # Avoid sandbox violations in temporary directories.
132 if [[ -w $T ]] ; then
136 elif [[ $SANDBOX_ON = 1 ]] ; then
137 for x in TEMP TMP TMPDIR ; do
138 [[ -n ${!x} ]] && addwrite "${!x}"
143 # the sandbox is disabled by default except when overridden in the relevant stages
146 # Ensure that $PWD is sane whenever possible, to protect against
147 # exploitation of insecure search path for python -c in ebuilds.
148 # See bug #239560 and bug #469338.
149 cd "${PORTAGE_PYM_PATH}" || \
150 die "PORTAGE_PYM_PATH does not exist: '${PORTAGE_PYM_PATH}'"
152 #if no perms are specified, dirs/files will have decent defaults
153 #(not secretive, but not stupid)
156 # debug-print() gets called from many places with verbose status information useful
157 # for tracking down problems. The output is in $T/eclass-debug.log.
158 # You can set ECLASS_DEBUG_OUTPUT to redirect the output somewhere else as well.
159 # The special "on" setting echoes the information, mixing it with the rest of the
161 # You can override the setting by exporting a new one from the console, or you can
162 # set a new default in make.*. Here the default is "" or unset.
164 # in the future might use e* from /etc/init.d/functions.sh if i feel like it
166 # if $T isn't defined, we're in dep calculation mode and
167 # shouldn't do anything
168 [[ $EBUILD_PHASE = depend || ! -d ${T} || ${#} -eq 0 ]] && return 0
170 if [[ ${ECLASS_DEBUG_OUTPUT} == on ]]; then
171 printf 'debug: %s\n' "${@}" >&2
172 elif [[ -n ${ECLASS_DEBUG_OUTPUT} ]]; then
173 printf 'debug: %s\n' "${@}" >> "${ECLASS_DEBUG_OUTPUT}"
176 if [[ -w $T ]] ; then
178 printf '%s\n' "${@}" >> "${T}/eclass-debug.log"
179 # let the portage user own/write to this file
180 chgrp "${PORTAGE_GRPNAME:-portage}" "${T}/eclass-debug.log"
181 chmod g+w "${T}/eclass-debug.log"
185 # The following 2 functions are debug-print() wrappers
187 debug-print-function() {
188 debug-print "${1}: entering function, parameters: ${*:2}"
191 debug-print-section() {
192 debug-print "now in section ${*}"
195 # Sources all eclasses in parameters
196 declare -ix ECLASS_DEPTH=0
198 ECLASS_DEPTH=$(($ECLASS_DEPTH + 1))
199 if [[ ${ECLASS_DEPTH} > 1 ]]; then
200 debug-print "*** Multiple Inheritence (Level: ${ECLASS_DEPTH})"
203 if [[ -n $ECLASS && -n ${!__export_funcs_var} ]] ; then
204 echo "QA Notice: EXPORT_FUNCTIONS is called before inherit in" \
205 "$ECLASS.eclass. For compatibility with <=portage-2.1.6.7," \
206 "only call EXPORT_FUNCTIONS after inherit(s)." \
207 | fmt -w 75 | while read -r ; do eqawarn "$REPLY" ; done
212 local potential_location
215 # These variables must be restored before returning.
216 local PECLASS=$ECLASS
217 local prev_export_funcs_var=$__export_funcs_var
227 potential_location=""
230 __export_funcs_var=__export_functions_$ECLASS_DEPTH
231 unset $__export_funcs_var
233 if [ "${EBUILD_PHASE}" != "depend" ] && \
234 [ "${EBUILD_PHASE}" != "nofetch" ] && \
235 [[ ${EBUILD_PHASE} != *rm ]] && \
236 [[ ${EMERGE_FROM} != "binary" ]] ; then
237 # This is disabled in the *rm phases because they frequently give
238 # false alarms due to INHERITED in /var/db/pkg being outdated
239 # in comparison the the eclasses from the portage tree. It's
240 # disabled for nofetch, since that can be called by repoman and
241 # that triggers bug #407449 due to repoman not exporting
242 # non-essential variables such as INHERITED.
243 if ! has $ECLASS $INHERITED $__INHERITED_QA_CACHE ; then
244 eqawarn "QA Notice: ECLASS '$ECLASS' inherited illegally in $CATEGORY/$PF $EBUILD_PHASE"
248 for repo_location in "${PORTAGE_ECLASS_LOCATIONS[@]}"; do
249 potential_location="${repo_location}/eclass/${1}.eclass"
250 if [[ -f ${potential_location} ]]; then
251 location="${potential_location}"
252 debug-print " eclass exists: ${location}"
256 debug-print "inherit: $1 -> $location"
257 [[ -z ${location} ]] && die "${1}.eclass could not be found by inherit()"
259 #We need to back up the values of *DEPEND to B_*DEPEND
260 #(if set).. and then restore them after the inherit call.
262 #turn off glob expansion
265 # Retain the old data and restore it later.
266 unset B_IUSE B_REQUIRED_USE B_DEPEND B_RDEPEND B_PDEPEND B_HDEPEND
267 [ "${IUSE+set}" = set ] && B_IUSE="${IUSE}"
268 [ "${REQUIRED_USE+set}" = set ] && B_REQUIRED_USE="${REQUIRED_USE}"
269 [ "${DEPEND+set}" = set ] && B_DEPEND="${DEPEND}"
270 [ "${RDEPEND+set}" = set ] && B_RDEPEND="${RDEPEND}"
271 [ "${PDEPEND+set}" = set ] && B_PDEPEND="${PDEPEND}"
272 [ "${HDEPEND+set}" = set ] && B_HDEPEND="${HDEPEND}"
273 unset IUSE REQUIRED_USE DEPEND RDEPEND PDEPEND HDEPEND
274 #turn on glob expansion
277 __qa_source "$location" || die "died sourcing $location in inherit()"
279 #turn off glob expansion
282 # If each var has a value, append it to the global variable E_* to
283 # be applied after everything is finished. New incremental behavior.
284 [ "${IUSE+set}" = set ] && E_IUSE+="${E_IUSE:+ }${IUSE}"
285 [ "${REQUIRED_USE+set}" = set ] && E_REQUIRED_USE+="${E_REQUIRED_USE:+ }${REQUIRED_USE}"
286 [ "${DEPEND+set}" = set ] && E_DEPEND+="${E_DEPEND:+ }${DEPEND}"
287 [ "${RDEPEND+set}" = set ] && E_RDEPEND+="${E_RDEPEND:+ }${RDEPEND}"
288 [ "${PDEPEND+set}" = set ] && E_PDEPEND+="${E_PDEPEND:+ }${PDEPEND}"
289 [ "${HDEPEND+set}" = set ] && E_HDEPEND+="${E_HDEPEND:+ }${HDEPEND}"
291 [ "${B_IUSE+set}" = set ] && IUSE="${B_IUSE}"
292 [ "${B_IUSE+set}" = set ] || unset IUSE
294 [ "${B_REQUIRED_USE+set}" = set ] && REQUIRED_USE="${B_REQUIRED_USE}"
295 [ "${B_REQUIRED_USE+set}" = set ] || unset REQUIRED_USE
297 [ "${B_DEPEND+set}" = set ] && DEPEND="${B_DEPEND}"
298 [ "${B_DEPEND+set}" = set ] || unset DEPEND
300 [ "${B_RDEPEND+set}" = set ] && RDEPEND="${B_RDEPEND}"
301 [ "${B_RDEPEND+set}" = set ] || unset RDEPEND
303 [ "${B_PDEPEND+set}" = set ] && PDEPEND="${B_PDEPEND}"
304 [ "${B_PDEPEND+set}" = set ] || unset PDEPEND
306 [ "${B_HDEPEND+set}" = set ] && HDEPEND="${B_HDEPEND}"
307 [ "${B_HDEPEND+set}" = set ] || unset HDEPEND
309 #turn on glob expansion
312 if [[ -n ${!__export_funcs_var} ]] ; then
313 for x in ${!__export_funcs_var} ; do
314 debug-print "EXPORT_FUNCTIONS: $x -> ${ECLASS}_$x"
315 declare -F "${ECLASS}_$x" >/dev/null || \
316 die "EXPORT_FUNCTIONS: ${ECLASS}_$x is not defined"
317 eval "$x() { ${ECLASS}_$x \"\$@\" ; }" > /dev/null
320 unset $__export_funcs_var
322 has $1 $INHERITED || export INHERITED="$INHERITED $1"
326 ((--ECLASS_DEPTH)) # Returns 1 when ECLASS_DEPTH reaches 0.
327 if (( ECLASS_DEPTH > 0 )) ; then
328 export ECLASS=$PECLASS
329 __export_funcs_var=$prev_export_funcs_var
331 unset ECLASS __export_funcs_var
336 # Exports stub functions that call the eclass's functions, thereby making them default.
337 # For example, if ECLASS="base" and you call "EXPORT_FUNCTIONS src_unpack", the following
338 # code will be eval'd:
339 # src_unpack() { base_src_unpack; }
341 if [ -z "$ECLASS" ]; then
342 die "EXPORT_FUNCTIONS without a defined ECLASS"
344 eval $__export_funcs_var+=\" $*\"
347 PORTAGE_BASHRCS_SOURCED=0
349 # @FUNCTION: __source_all_bashrcs
351 # Source a relevant bashrc files and perform other miscellaneous
352 # environment initialization when appropriate.
354 # If EAPI is set then define functions provided by the current EAPI:
356 # * default_* aliases for the current EAPI phase functions
357 # * A "default" function which is an alias for the default phase
358 # function for the current phase.
360 __source_all_bashrcs() {
361 [[ $PORTAGE_BASHRCS_SOURCED = 1 ]] && return 0
362 PORTAGE_BASHRCS_SOURCED=1
365 local OCC="${CC}" OCXX="${CXX}"
367 if [[ $EBUILD_PHASE != depend ]] ; then
368 # source the existing profile.bashrcs.
371 local path_array=($PROFILE_PATHS)
373 for x in "${path_array[@]}" ; do
374 [ -f "$x/profile.bashrc" ] && __qa_source "$x/profile.bashrc"
378 if [ -r "${PORTAGE_BASHRC}" ] ; then
379 if [ "$PORTAGE_DEBUG" != "1" ] || [ "${-/x/}" != "$-" ]; then
380 source "${PORTAGE_BASHRC}"
383 source "${PORTAGE_BASHRC}"
388 if [[ $EBUILD_PHASE != depend ]] ; then
389 # The user's bashrc is the ONLY non-portage bit of code that can
390 # change shopts without a QA violation.
391 for x in "${PM_EBUILD_HOOK_DIR}"/${CATEGORY}/{${PN},${PN}:${SLOT%/*},${P},${PF}}; do
392 if [ -r "${x}" ]; then
393 # If $- contains x, then tracing has already been enabled
394 # elsewhere for some reason. We preserve it's state so as
396 if [ "$PORTAGE_DEBUG" != "1" ] || [ "${-/x/}" != "$-" ]; then
407 [ ! -z "${OCC}" ] && export CC="${OCC}"
408 [ ! -z "${OCXX}" ] && export CXX="${OCXX}"
411 # === === === === === === === === === === === === === === === === === ===
412 # === === === === === functions end, main part begins === === === === ===
413 # === === === === === === === === === === === === === === === === === ===
415 export SANDBOX_ON="1"
416 export S=${WORKDIR}/${P}
418 # Turn of extended glob matching so that g++ doesn't get incorrectly matched.
421 if [[ ${EBUILD_PHASE} == depend ]] ; then
422 QA_INTERCEPTORS="awk bash cc egrep equery fgrep g++
423 gawk gcc grep javac java-config nawk perl
424 pkg-config python python-config sed"
425 elif [[ ${EBUILD_PHASE} == clean* ]] ; then
426 unset QA_INTERCEPTORS
428 QA_INTERCEPTORS="autoconf automake aclocal libtoolize"
430 # level the QA interceptors if we're in depend
431 if [[ -n ${QA_INTERCEPTORS} ]] ; then
432 for BIN in ${QA_INTERCEPTORS}; do
433 BIN_PATH=$(type -Pf ${BIN})
434 if [ "$?" != "0" ]; then
435 BODY="echo \"*** missing command: ${BIN}\" >&2; return 127"
437 BODY="${BIN_PATH} \"\$@\"; return \$?"
439 if [[ ${EBUILD_PHASE} == depend ]] ; then
441 if [ \$ECLASS_DEPTH -gt 0 ]; then
442 eqawarn \"QA Notice: '${BIN}' called in global scope: eclass \${ECLASS}\"
444 eqawarn \"QA Notice: '${BIN}' called in global scope: \${CATEGORY}/\${PF}\"
448 elif has ${BIN} autoconf automake aclocal libtoolize ; then
450 if ! has \${FUNCNAME[1]} eautoreconf eaclocal _elibtoolize \\
451 eautoheader eautoconf eautomake autotools_run_tool \\
452 autotools_check_macro autotools_get_subdirs \\
453 autotools_get_auxdir ; then
454 eqawarn \"QA Notice: '${BIN}' called by \${FUNCNAME[1]}: \${CATEGORY}/\${PF}\"
455 eqawarn \"Use autotools.eclass instead of calling '${BIN}' directly.\"
461 eqawarn \"QA Notice: '${BIN}' called by \${FUNCNAME[1]}: \${CATEGORY}/\${PF}\"
465 eval "$FUNC_SRC" || echo "error creating QA interceptor ${BIN}" >&2
467 unset BIN_PATH BIN BODY FUNC_SRC
470 # Subshell/helper die support (must export for the die helper).
471 export EBUILD_MASTER_PID=${BASHPID:-$(__bashpid)}
472 trap 'exit 1' SIGTERM
474 if ! has "$EBUILD_PHASE" clean cleanrm depend && \
475 [ -f "${T}"/environment ] ; then
476 # The environment may have been extracted from environment.bz2 or
477 # may have come from another version of ebuild.sh or something.
478 # In any case, preprocess it to prevent any potential interference.
479 # NOTE: export ${FOO}=... requires quoting, unlike normal exports
480 __preprocess_ebuild_env || \
481 die "error processing environment"
482 # Colon separated SANDBOX_* variables need to be cumulative.
483 for x in SANDBOX_DENY SANDBOX_READ SANDBOX_PREDICT SANDBOX_WRITE ; do
484 export PORTAGE_${x}="${!x}"
486 PORTAGE_SANDBOX_ON=${SANDBOX_ON}
488 source "${T}"/environment || \
489 die "error sourcing environment"
490 # We have to temporarily disable sandbox since the
491 # SANDBOX_{DENY,READ,PREDICT,WRITE} values we've just loaded
492 # may be unusable (triggering in spurious sandbox violations)
493 # until we've merged them with our current values.
495 for x in SANDBOX_DENY SANDBOX_PREDICT SANDBOX_READ SANDBOX_WRITE ; do
497 if [ -z "${!x}" ] ; then
499 elif [ -n "${!y}" ] && [ "${!y}" != "${!x}" ] ; then
501 export ${x}="$(printf "${!y}:${!x}" | tr ":" "\0" | \
502 sort -z -u | tr "\0" ":")"
504 export ${x}="${!x%:}"
508 export SANDBOX_ON=${PORTAGE_SANDBOX_ON}
509 unset PORTAGE_SANDBOX_ON
510 [[ -n $EAPI ]] || EAPI=0
513 if ___eapi_enables_globstar; then
517 # Convert quoted paths to array.
518 eval "PORTAGE_ECLASS_LOCATIONS=(${PORTAGE_ECLASS_LOCATIONS})"
520 # Source the ebuild every time for FEATURES=noauto, so that ebuild
521 # modifications take effect immediately.
522 if ! has "$EBUILD_PHASE" clean cleanrm ; then
523 if [[ $EBUILD_PHASE = depend || ! -f $T/environment || \
524 -f $PORTAGE_BUILDDIR/.ebuild_changed || \
525 " ${FEATURES} " == *" noauto "* ]] ; then
526 # The bashrcs get an opportunity here to set aliases that will be expanded
527 # during sourcing of ebuilds and eclasses.
530 # When EBUILD_PHASE != depend, INHERITED comes pre-initialized
531 # from cache. In order to make INHERITED content independent of
532 # EBUILD_PHASE during inherit() calls, we unset INHERITED after
533 # we make a backup copy for QA checks.
534 __INHERITED_QA_CACHE=$INHERITED
536 # *DEPEND and IUSE will be set during the sourcing of the ebuild.
537 # In order to ensure correct interaction between ebuilds and
538 # eclasses, they need to be unset before this process of
539 # interaction begins.
540 unset EAPI DEPEND RDEPEND PDEPEND HDEPEND INHERITED IUSE REQUIRED_USE \
541 ECLASS E_IUSE E_REQUIRED_USE E_DEPEND E_RDEPEND E_PDEPEND \
544 if [[ $PORTAGE_DEBUG != 1 || ${-/x/} != $- ]] ; then
545 source "$EBUILD" || die "error sourcing ebuild"
548 source "$EBUILD" || die "error sourcing ebuild"
552 if [[ "${EBUILD_PHASE}" != "depend" ]] ; then
553 RESTRICT=${PORTAGE_RESTRICT}
554 [[ -e $PORTAGE_BUILDDIR/.ebuild_changed ]] && \
555 rm "$PORTAGE_BUILDDIR/.ebuild_changed"
558 [ "${EAPI+set}" = set ] || EAPI=0
560 # export EAPI for helpers (especially since we unset it above)
563 if ___eapi_has_RDEPEND_DEPEND_fallback; then
564 export RDEPEND=${RDEPEND-${DEPEND}}
565 debug-print "RDEPEND: not set... Setting to: ${DEPEND}"
568 # add in dependency info from eclasses
569 IUSE+="${IUSE:+ }${E_IUSE}"
570 DEPEND+="${DEPEND:+ }${E_DEPEND}"
571 RDEPEND+="${RDEPEND:+ }${E_RDEPEND}"
572 PDEPEND+="${PDEPEND:+ }${E_PDEPEND}"
573 HDEPEND+="${HDEPEND:+ }${E_HDEPEND}"
574 REQUIRED_USE+="${REQUIRED_USE:+ }${E_REQUIRED_USE}"
576 unset ECLASS E_IUSE E_REQUIRED_USE E_DEPEND E_RDEPEND E_PDEPEND E_HDEPEND \
579 # alphabetically ordered by $EBUILD_PHASE value
582 _valid_phases="src_compile pkg_config pkg_info src_install
583 pkg_nofetch pkg_postinst pkg_postrm pkg_preinst pkg_prerm
584 pkg_setup src_test src_unpack"
587 _valid_phases="src_compile pkg_config src_configure pkg_info
588 src_install pkg_nofetch pkg_postinst pkg_postrm pkg_preinst
589 src_prepare pkg_prerm pkg_setup src_test src_unpack"
592 _valid_phases="src_compile pkg_config src_configure pkg_info
593 src_install pkg_nofetch pkg_postinst pkg_postrm pkg_preinst
594 src_prepare pkg_prerm pkg_pretend pkg_setup src_test src_unpack"
599 for _f in $_valid_phases ; do
600 if declare -F $_f >/dev/null ; then
602 DEFINED_PHASES+=" ${_f#src_}"
605 [[ -n $DEFINED_PHASES ]] || DEFINED_PHASES=-
607 unset _f _valid_phases
609 if [[ $EBUILD_PHASE != depend ]] ; then
611 if has distcc $FEATURES ; then
612 [[ -n $DISTCC_LOG ]] && addwrite "${DISTCC_LOG%/*}"
615 if has ccache $FEATURES ; then
617 if [[ -n $CCACHE_DIR ]] ; then
618 addread "$CCACHE_DIR"
619 addwrite "$CCACHE_DIR"
622 [[ -n $CCACHE_SIZE ]] && ccache -M $CCACHE_SIZE &> /dev/null
625 if [[ -n $QA_PREBUILT ]] ; then
627 # these ones support fnmatch patterns
628 QA_EXECSTACK+=" $QA_PREBUILT"
629 QA_TEXTRELS+=" $QA_PREBUILT"
630 QA_WX_LOAD+=" $QA_PREBUILT"
632 # these ones support regular expressions, so translate
633 # fnmatch patterns to regular expressions
634 for x in QA_DT_NEEDED QA_FLAGS_IGNORED QA_PRESTRIPPED QA_SONAME ; do
635 if [[ $(declare -p $x 2>/dev/null) = declare\ -a* ]] ; then
636 eval "$x=(\"\${$x[@]}\" ${QA_PREBUILT//\*/.*})"
638 eval "$x+=\" ${QA_PREBUILT//\*/.*}\""
645 # This needs to be exported since prepstrip is a separate shell script.
646 [[ -n $QA_PRESTRIPPED ]] && export QA_PRESTRIPPED
647 eval "[[ -n \$QA_PRESTRIPPED_${ARCH/-/_} ]] && \
648 export QA_PRESTRIPPED_${ARCH/-/_}"
653 # unset USE_EXPAND variables that contain only the special "*" token
654 for x in ${USE_EXPAND} ; do
655 [ "${!x}" == "*" ] && unset ${x}
659 if has nostrip ${FEATURES} ${RESTRICT} || has strip ${RESTRICT}
664 if [[ $EBUILD_PHASE = depend ]] ; then
665 export SANDBOX_ON="0"
668 if [ -n "${dbkey}" ] ; then
669 if [ ! -d "${dbkey%/*}" ]; then
670 install -d -g ${PORTAGE_GID} -m2775 "${dbkey%/*}"
672 # Make it group writable. 666&~002==664
676 auxdbkeys="DEPEND RDEPEND SLOT SRC_URI RESTRICT HOMEPAGE LICENSE
677 DESCRIPTION KEYWORDS INHERITED IUSE REQUIRED_USE PDEPEND PROVIDE EAPI
678 PROPERTIES DEFINED_PHASES HDEPEND UNUSED_04
679 UNUSED_03 UNUSED_02 UNUSED_01"
681 if ! ___eapi_has_HDEPEND; then
685 # The extra $(echo) commands remove newlines.
686 if [ -n "${dbkey}" ] ; then
688 for f in ${auxdbkeys} ; do
689 echo $(echo ${!f}) >> "${dbkey}" || exit $?
692 for f in ${auxdbkeys} ; do
693 eval "echo \$(echo \${!f}) 1>&${PORTAGE_PIPE_FD}" || exit $?
695 eval "exec ${PORTAGE_PIPE_FD}>&-"
699 # Note: readonly variables interfere with __preprocess_ebuild_env(), so
700 # declare them only after it has already run.
701 declare -r $PORTAGE_READONLY_METADATA $PORTAGE_READONLY_VARS
702 if ___eapi_has_prefix_variables; then
703 declare -r ED EPREFIX EROOT
706 if [[ -n $EBUILD_SH_ARGS ]] ; then
708 # Don't allow subprocesses to inherit the pipe which
709 # emerge uses to monitor ebuild.sh.
710 if [[ -n ${PORTAGE_PIPE_FD} ]] ; then
711 eval "exec ${PORTAGE_PIPE_FD}>&-"
712 unset PORTAGE_PIPE_FD
714 __ebuild_main ${EBUILD_SH_ARGS}
721 # Do not exit when ebuild.sh is sourced by other scripts.