2 # Copyright 1999-2013 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
7 export _E_EXEDESTTREE_=""
8 export _E_DOCDESTTREE_=""
9 export INSOPTIONS="-m0644"
10 export EXEOPTIONS="-m0755"
11 export LIBOPTIONS="-m0644"
12 export DIROPTIONS="-m0755"
14 # Do not compress files which are smaller than this (in bytes). #169260
15 export PORTAGE_DOCOMPRESS_SIZE_LIMIT="128"
16 declare -a PORTAGE_DOCOMPRESS=( /usr/share/{doc,info,man} )
17 declare -a PORTAGE_DOCOMPRESS_SKIP=( /usr/share/doc/${PF}/html )
20 if [ "$1" == "/" ]; then
24 if ! ___eapi_has_prefix_variables; then
27 if [ ! -d "${ED}${DESTTREE}" ]; then
28 install -d "${ED}${DESTTREE}"
30 if [[ $ret -ne 0 ]] ; then
31 __helpers_die "${FUNCNAME[0]} failed"
39 if [ "$1" == "/" ]; then
43 if ! ___eapi_has_prefix_variables; then
46 if [ ! -d "${ED}${INSDESTTREE}" ]; then
47 install -d "${ED}${INSDESTTREE}"
49 if [[ $ret -ne 0 ]] ; then
50 __helpers_die "${FUNCNAME[0]} failed"
58 if [ "$1" == "/" ]; then
59 export _E_EXEDESTTREE_=""
61 export _E_EXEDESTTREE_="$1"
62 if ! ___eapi_has_prefix_variables; then
65 if [ ! -d "${ED}${_E_EXEDESTTREE_}" ]; then
66 install -d "${ED}${_E_EXEDESTTREE_}"
68 if [[ $ret -ne 0 ]] ; then
69 __helpers_die "${FUNCNAME[0]} failed"
77 if [ "$1" == "/" ]; then
78 export _E_DOCDESTTREE_=""
80 export _E_DOCDESTTREE_="$1"
81 if ! ___eapi_has_prefix_variables; then
84 if [ ! -d "${ED}usr/share/doc/${PF}/${_E_DOCDESTTREE_}" ]; then
85 install -d "${ED}usr/share/doc/${PF}/${_E_DOCDESTTREE_}"
87 if [[ $ret -ne 0 ]] ; then
88 __helpers_die "${FUNCNAME[0]} failed"
96 export INSOPTIONS="$@"
98 # `install` should never be called with '-s' ...
99 has -s ${INSOPTIONS} && die "Never call insopts() with -s"
103 export DIROPTIONS="$@"
107 export EXEOPTIONS="$@"
109 # `install` should never be called with '-s' ...
110 has -s ${EXEOPTIONS} && die "Never call exeopts() with -s"
114 export LIBOPTIONS="$@"
116 # `install` should never be called with '-s' ...
117 has -s ${LIBOPTIONS} && die "Never call libopts() with -s"
121 ___eapi_has_docompress || die "'docompress' not supported in this EAPI"
124 if [[ $1 = "-x" ]]; then
127 f=$(__strip_duplicate_slashes "${f}"); f=${f%/}
128 [[ ${f:0:1} = / ]] || f="/${f}"
129 for g in "${PORTAGE_DOCOMPRESS_SKIP[@]}"; do
130 [[ ${f} = "${g}" ]] && continue 2
132 PORTAGE_DOCOMPRESS_SKIP[${#PORTAGE_DOCOMPRESS_SKIP[@]}]=${f}
136 f=$(__strip_duplicate_slashes "${f}"); f=${f%/}
137 [[ ${f:0:1} = / ]] || f="/${f}"
138 for g in "${PORTAGE_DOCOMPRESS[@]}"; do
139 [[ ${f} = "${g}" ]] && continue 2
141 PORTAGE_DOCOMPRESS[${#PORTAGE_DOCOMPRESS[@]}]=${f}
147 has $EBUILD_PHASE prerm postrm || eqawarn \
148 "QA Notice: The 'useq' function is deprecated (replaced by 'use')"
160 if ___eapi_has_usex; then
175 # if we got something like '!flag', then invert the return value
176 if [[ ${u:0:1} == "!" ]] ; then
181 if [[ $EBUILD_PHASE = depend ]] ; then
182 # TODO: Add a registration interface for eclasses to register
183 # any number of phase hooks, so that global scope eclass
184 # initialization can by migrated to phase hooks in new EAPIs.
185 # Example: add_phase_hook before pkg_setup $ECLASS_pre_pkg_setup
186 #if [[ -n $EAPI ]] && ! has "$EAPI" 0 1 2 3 ; then
187 # die "use() called during invalid phase: $EBUILD_PHASE"
191 # Make sure we have this USE flag in IUSE, but exempt binary
192 # packages for API consumers like Entropy which do not require
193 # a full profile with IUSE_IMPLICIT and stuff (see bug #456830).
194 elif [[ -n $PORTAGE_IUSE && -n $EBUILD_PHASE &&
195 -n $PORTAGE_INTERNAL_CALLER ]] ; then
196 if [[ ! $u =~ $PORTAGE_IUSE ]] ; then
197 if [[ ! ${EAPI} =~ ^(0|1|2|3|4|4-python|4-slot-abi)$ ]] ; then
198 # This is only strict starting with EAPI 5, since implicit IUSE
199 # is not well defined for earlier EAPIs (see bug #449708).
200 die "USE Flag '${u}' not in IUSE for ${CATEGORY}/${PF}"
202 eqawarn "QA Notice: USE Flag '${u}' not" \
203 "in IUSE for ${CATEGORY}/${PF}"
207 local IFS=$' \t\n' prev_shopts=$- ret
209 if has ${u} ${USE} ; then
214 [[ ${prev_shopts} == *f* ]] || set +f
220 echo "!!! use_with() called without a parameter." >&2
221 echo "!!! use_with <USEFLAG> [<flagname> [value]]" >&2
225 if ___eapi_use_enable_and_use_with_support_empty_third_argument; then
226 local UW_SUFFIX=${3+=$3}
228 local UW_SUFFIX=${3:+=$3}
233 echo "--with-${UWORD}${UW_SUFFIX}"
235 echo "--without-${UWORD}"
242 echo "!!! use_enable() called without a parameter." >&2
243 echo "!!! use_enable <USEFLAG> [<flagname> [value]]" >&2
247 if ___eapi_use_enable_and_use_with_support_empty_third_argument; then
248 local UE_SUFFIX=${3+=$3}
250 local UE_SUFFIX=${3:+=$3}
255 echo "--enable-${UWORD}${UE_SUFFIX}"
257 echo "--disable-${UWORD}"
265 local y y_insensitive
266 local suffix suffix_insensitive
268 local eapi=${EAPI:-0}
269 [ -z "$*" ] && die "Nothing passed to the 'unpack' command"
272 __vecho ">>> Unpacking ${x} to ${PWD}"
274 suffix_insensitive=$(LC_ALL=C tr "[:upper:]" "[:lower:]" <<< "${suffix}")
277 y_insensitive=$(LC_ALL=C tr "[:upper:]" "[:lower:]" <<< "${y}")
279 if [[ ${x} == "./"* ]] ; then
281 elif [[ ${x} == ${DISTDIR%/}/* ]] ; then
282 die "Arguments to unpack() cannot begin with \${DISTDIR}."
283 elif [[ ${x} == "/"* ]] ; then
284 die "Arguments to unpack() cannot be absolute"
288 [[ ! -s ${srcdir}${x} ]] && die "${x} does not exist"
291 if [[ ${y_insensitive} == tar ]] ; then
292 if ___eapi_unpack_is_case_sensitive && \
293 [[ tar != ${y} ]] ; then
294 eqawarn "QA Notice: unpack called with" \
295 "secondary suffix '${y}' which is unofficially" \
296 "supported with EAPI '${EAPI}'. Instead use 'tar'."
298 $1 -c -- "$srcdir$x" | tar xof -
299 __assert_sigpipe_ok "$myfail"
301 local cwd_dest=${x##*/}
302 cwd_dest=${cwd_dest%.*}
303 $1 -c -- "${srcdir}${x}" > "${cwd_dest}" || die "$myfail"
307 myfail="failure unpacking ${x}"
308 case "${suffix_insensitive}" in
310 if ___eapi_unpack_is_case_sensitive && \
311 [[ tar != ${suffix} ]] ; then
312 eqawarn "QA Notice: unpack called with" \
313 "suffix '${suffix}' which is unofficially supported" \
314 "with EAPI '${EAPI}'. Instead use 'tar'."
316 tar xof "$srcdir$x" || die "$myfail"
319 if ___eapi_unpack_is_case_sensitive && \
320 [[ tgz != ${suffix} ]] ; then
321 eqawarn "QA Notice: unpack called with" \
322 "suffix '${suffix}' which is unofficially supported" \
323 "with EAPI '${EAPI}'. Instead use 'tgz'."
325 tar xozf "$srcdir$x" || die "$myfail"
328 if ___eapi_unpack_is_case_sensitive && \
329 [[ " tbz tbz2 " != *" ${suffix} "* ]] ; then
330 eqawarn "QA Notice: unpack called with" \
331 "suffix '${suffix}' which is unofficially supported" \
332 "with EAPI '${EAPI}'. Instead use 'tbz' or 'tbz2'."
334 ${PORTAGE_BUNZIP2_COMMAND:-${PORTAGE_BZIP2_COMMAND} -d} -c -- "$srcdir$x" | tar xof -
335 __assert_sigpipe_ok "$myfail"
338 if ___eapi_unpack_is_case_sensitive && \
339 [[ " ZIP zip jar " != *" ${suffix} "* ]] ; then
340 eqawarn "QA Notice: unpack called with" \
341 "suffix '${suffix}' which is unofficially supported" \
342 "with EAPI '${EAPI}'." \
343 "Instead use 'ZIP', 'zip', or 'jar'."
345 # unzip will interactively prompt under some error conditions,
346 # as reported in bug #336285
347 ( set +x ; while true ; do echo n || break ; done ) | \
348 unzip -qo "${srcdir}${x}" || die "$myfail"
351 if ___eapi_unpack_is_case_sensitive && \
352 [[ " gz z Z " != *" ${suffix} "* ]] ; then
353 eqawarn "QA Notice: unpack called with" \
354 "suffix '${suffix}' which is unofficially supported" \
355 "with EAPI '${EAPI}'. Instead use 'gz', 'z', or 'Z'."
357 __unpack_tar "gzip -d"
360 if ___eapi_unpack_is_case_sensitive && \
361 [[ " bz bz2 " != *" ${suffix} "* ]] ; then
362 eqawarn "QA Notice: unpack called with" \
363 "suffix '${suffix}' which is unofficially supported" \
364 "with EAPI '${EAPI}'. Instead use 'bz' or 'bz2'."
366 __unpack_tar "${PORTAGE_BUNZIP2_COMMAND:-${PORTAGE_BZIP2_COMMAND} -d}"
370 my_output="$(7z x -y "${srcdir}${x}")"
371 if [ $? -ne 0 ]; then
372 echo "${my_output}" >&2
377 if ___eapi_unpack_is_case_sensitive && \
378 [[ " rar RAR " != *" ${suffix} "* ]] ; then
379 eqawarn "QA Notice: unpack called with" \
380 "suffix '${suffix}' which is unofficially supported" \
381 "with EAPI '${EAPI}'. Instead use 'rar' or 'RAR'."
383 unrar x -idq -o+ "${srcdir}${x}" || die "$myfail"
386 if ___eapi_unpack_is_case_sensitive && \
387 [[ " LHA LHa lha lzh " != *" ${suffix} "* ]] ; then
388 eqawarn "QA Notice: unpack called with" \
389 "suffix '${suffix}' which is unofficially supported" \
390 "with EAPI '${EAPI}'." \
391 "Instead use 'LHA', 'LHa', 'lha', or 'lzh'."
393 lha xfq "${srcdir}${x}" || die "$myfail"
396 if ___eapi_unpack_is_case_sensitive && \
397 [[ " a " != *" ${suffix} "* ]] ; then
398 eqawarn "QA Notice: unpack called with" \
399 "suffix '${suffix}' which is unofficially supported" \
400 "with EAPI '${EAPI}'. Instead use 'a'."
402 ar x "${srcdir}${x}" || die "$myfail"
405 if ___eapi_unpack_is_case_sensitive && \
406 [[ " deb " != *" ${suffix} "* ]] ; then
407 eqawarn "QA Notice: unpack called with" \
408 "suffix '${suffix}' which is unofficially supported" \
409 "with EAPI '${EAPI}'. Instead use 'deb'."
411 # Unpacking .deb archives can not always be done with
412 # `ar`. For instance on AIX this doesn't work out. If
413 # we have `deb2targz` installed, prefer it over `ar` for
414 # that reason. We just make sure on AIX `deb2targz` is
416 if type -P deb2targz > /dev/null; then
418 local created_symlink=0
419 if [ ! "$srcdir$x" -ef "$y" ] ; then
420 # deb2targz always extracts into the same directory as
421 # the source file, so create a symlink in the current
422 # working directory if necessary.
423 ln -sf "$srcdir$x" "$y" || die "$myfail"
426 deb2targz "$y" || die "$myfail"
427 if [ $created_symlink = 1 ] ; then
428 # Clean up the symlink so the ebuild
429 # doesn't inadvertently install it.
432 mv -f "${y%.deb}".tar.gz data.tar.gz || die "$myfail"
434 ar x "$srcdir$x" || die "$myfail"
438 if ___eapi_unpack_is_case_sensitive && \
439 [[ " lzma " != *" ${suffix} "* ]] ; then
440 eqawarn "QA Notice: unpack called with" \
441 "suffix '${suffix}' which is unofficially supported" \
442 "with EAPI '${EAPI}'. Instead use 'lzma'."
444 __unpack_tar "lzma -d"
447 if ___eapi_unpack_is_case_sensitive && \
448 [[ " xz " != *" ${suffix} "* ]] ; then
449 eqawarn "QA Notice: unpack called with" \
450 "suffix '${suffix}' which is unofficially supported" \
451 "with EAPI '${EAPI}'. Instead use 'xz'."
453 if ___eapi_unpack_supports_xz; then
456 __vecho "unpack ${x}: file format not recognized. Ignoring."
460 __vecho "unpack ${x}: file format not recognized. Ignoring."
464 # Do not chmod '.' since it's probably ${WORKDIR} and PORTAGE_WORKDIR_MODE
465 # should be preserved.
466 find . -mindepth 1 -maxdepth 1 ! -type l -print0 | \
467 ${XARGS} -0 chmod -fR a+rX,u+w,g-w,o-w
472 local pid=${BASHPID:-$(__bashpid)}
474 if ! ___eapi_has_prefix_variables; then
481 for x ; do [[ ${x} == ${s} ]] && echo "${x}" && return 0 ; done
485 __hasgq() { __hasg "$@" >/dev/null ; }
487 local phase_func=$(__ebuild_arg_to_phase "$EBUILD_PHASE")
488 if [[ -n $phase_func ]] ; then
489 if ! ___eapi_has_src_configure; then
490 [[ $phase_func != src_compile ]] && \
491 eqawarn "QA Notice: econf called in" \
492 "$phase_func instead of src_compile"
494 [[ $phase_func != src_configure ]] && \
495 eqawarn "QA Notice: econf called in" \
496 "$phase_func instead of src_configure"
501 if [ -x "${ECONF_SOURCE}/configure" ]; then
502 if [[ -n $CONFIG_SHELL && \
503 "$(head -n1 "$ECONF_SOURCE/configure")" =~ ^'#!'[[:space:]]*/bin/sh([[:space:]]|$) ]] ; then
504 # preserve timestamp, see bug #440304
505 touch -r "${ECONF_SOURCE}/configure" "${ECONF_SOURCE}/configure._portage_tmp_.${pid}" || die
507 -e "1s:^#![[:space:]]*/bin/sh:#!$CONFIG_SHELL:" \
508 "${ECONF_SOURCE}/configure" \
509 || die "Substition of shebang in '${ECONF_SOURCE}/configure' failed"
510 touch -r "${ECONF_SOURCE}/configure._portage_tmp_.${pid}" "${ECONF_SOURCE}/configure" || die
511 rm -f "${ECONF_SOURCE}/configure._portage_tmp_.${pid}"
513 if [ -e "${EPREFIX}"/usr/share/gnuconfig/ ]; then
514 find "${WORKDIR}" -type f '(' \
515 -name config.guess -o -name config.sub ')' -print0 | \
516 while read -r -d $'\0' x ; do
517 __vecho " * econf: updating ${x/${WORKDIR}\/} with ${EPREFIX}/usr/share/gnuconfig/${x##*/}"
518 # Make sure we do this atomically incase we're run in parallel. #487478
519 cp -f "${EPREFIX}"/usr/share/gnuconfig/"${x##*/}" "${x}.${pid}"
520 mv -f "${x}.${pid}" "${x}"
524 if ___eapi_econf_passes_--disable-dependency-tracking || ___eapi_econf_passes_--disable-silent-rules; then
525 local conf_help=$("${ECONF_SOURCE}/configure" --help 2>/dev/null)
527 if ___eapi_econf_passes_--disable-dependency-tracking; then
528 case "${conf_help}" in
529 *--disable-dependency-tracking*)
530 set -- --disable-dependency-tracking "$@"
535 if ___eapi_econf_passes_--disable-silent-rules; then
536 case "${conf_help}" in
537 *--disable-silent-rules*)
538 set -- --disable-silent-rules "$@"
544 # if the profile defines a location to install libs to aside from default, pass it on.
545 # if the ebuild passes in --libdir, they're responsible for the conf_libdir fun.
546 local CONF_LIBDIR LIBDIR_VAR="LIBDIR_${ABI}"
547 if [[ -n ${ABI} && -n ${!LIBDIR_VAR} ]] ; then
548 CONF_LIBDIR=${!LIBDIR_VAR}
550 if [[ -n ${CONF_LIBDIR} ]] && ! __hasgq --libdir=\* "$@" ; then
551 export CONF_PREFIX=$(__hasg --exec-prefix=\* "$@")
552 [[ -z ${CONF_PREFIX} ]] && CONF_PREFIX=$(__hasg --prefix=\* "$@")
553 : ${CONF_PREFIX:=${EPREFIX}/usr}
554 CONF_PREFIX=${CONF_PREFIX#*=}
555 [[ ${CONF_PREFIX} != /* ]] && CONF_PREFIX="/${CONF_PREFIX}"
556 [[ ${CONF_LIBDIR} != /* ]] && CONF_LIBDIR="/${CONF_LIBDIR}"
557 set -- --libdir="$(__strip_duplicate_slashes "${CONF_PREFIX}${CONF_LIBDIR}")" "$@"
560 # Handle arguments containing quoted whitespace (see bug #457136).
561 eval "local -a EXTRA_ECONF=(${EXTRA_ECONF})"
564 --prefix="${EPREFIX}"/usr \
565 ${CBUILD:+--build=${CBUILD}} \
567 ${CTARGET:+--target=${CTARGET}} \
568 --mandir="${EPREFIX}"/usr/share/man \
569 --infodir="${EPREFIX}"/usr/share/info \
570 --datadir="${EPREFIX}"/usr/share \
571 --sysconfdir="${EPREFIX}"/etc \
572 --localstatedir="${EPREFIX}"/var/lib \
575 __vecho "${ECONF_SOURCE}/configure" "$@"
577 if ! "${ECONF_SOURCE}/configure" "$@" ; then
579 if [ -s config.log ]; then
581 echo "!!! Please attach the following file when seeking support:"
582 echo "!!! ${PWD}/config.log"
586 elif [ -f "${ECONF_SOURCE}/configure" ]; then
587 die "configure is not executable"
589 die "no configure script found"
594 # CONF_PREFIX is only set if they didn't pass in libdir above.
595 local LOCAL_EXTRA_EINSTALL="${EXTRA_EINSTALL}"
596 if ! ___eapi_has_prefix_variables; then
599 LIBDIR_VAR="LIBDIR_${ABI}"
600 if [ -n "${ABI}" -a -n "${!LIBDIR_VAR}" ]; then
601 CONF_LIBDIR="${!LIBDIR_VAR}"
604 if [ -n "${CONF_LIBDIR}" ] && [ "${CONF_PREFIX:+set}" = set ]; then
605 EI_DESTLIBDIR="${D}/${CONF_PREFIX}/${CONF_LIBDIR}"
606 EI_DESTLIBDIR="$(__strip_duplicate_slashes "${EI_DESTLIBDIR}")"
607 LOCAL_EXTRA_EINSTALL="libdir=${EI_DESTLIBDIR} ${LOCAL_EXTRA_EINSTALL}"
611 if [ -f ./[mM]akefile -o -f ./GNUmakefile ] ; then
612 if [ "${PORTAGE_DEBUG}" == "1" ]; then
613 ${MAKE:-make} -n prefix="${ED}usr" \
614 datadir="${ED}usr/share" \
615 infodir="${ED}usr/share/info" \
616 localstatedir="${ED}var/lib" \
617 mandir="${ED}usr/share/man" \
618 sysconfdir="${ED}etc" \
619 ${LOCAL_EXTRA_EINSTALL} \
620 ${MAKEOPTS} ${EXTRA_EMAKE} -j1 \
623 ${MAKE:-make} prefix="${ED}usr" \
624 datadir="${ED}usr/share" \
625 infodir="${ED}usr/share/info" \
626 localstatedir="${ED}var/lib" \
627 mandir="${ED}usr/share/man" \
628 sysconfdir="${ED}etc" \
629 ${LOCAL_EXTRA_EINSTALL} \
630 ${MAKEOPTS} ${EXTRA_EMAKE} -j1 \
631 "$@" install || die "einstall failed"
633 die "no Makefile found"
637 __eapi0_pkg_nofetch() {
638 [ -z "${SRC_URI}" ] && return
640 elog "The following are listed in SRC_URI for ${PN}:"
642 for x in $(echo ${SRC_URI}); do
647 __eapi0_src_unpack() {
648 [[ -n ${A} ]] && unpack ${A}
651 __eapi0_src_compile() {
652 if [ -x ./configure ] ; then
659 # Since we don't want emake's automatic die
660 # support (EAPI 4 and later), and we also don't
661 # want the warning messages that it produces if
662 # we call it in 'nonfatal' mode, we use emake_cmd
663 # to emulate the desired parts of emake behavior.
664 local emake_cmd="${MAKE:-make} ${MAKEOPTS} ${EXTRA_EMAKE}"
666 if ___eapi_default_src_test_disables_parallel_jobs; then
667 internal_opts+=" -j1"
669 if $emake_cmd ${internal_opts} check -n &> /dev/null; then
670 __vecho ">>> Test phase [check]: ${CATEGORY}/${PF}"
671 $emake_cmd ${internal_opts} check || \
672 die "Make check failed. See above for details."
673 elif $emake_cmd ${internal_opts} test -n &> /dev/null; then
674 __vecho ">>> Test phase [test]: ${CATEGORY}/${PF}"
675 $emake_cmd ${internal_opts} test || \
676 die "Make test failed. See above for details."
678 __vecho ">>> Test phase [none]: ${CATEGORY}/${PF}"
682 __eapi1_src_compile() {
683 __eapi2_src_configure
687 __eapi2_src_configure() {
688 if [[ -x ${ECONF_SOURCE:-.}/configure ]] ; then
693 __eapi2_src_compile() {
694 if [ -f Makefile ] || [ -f GNUmakefile ] || [ -f makefile ]; then
695 emake || die "emake failed"
699 __eapi4_src_install() {
700 if [[ -f Makefile || -f GNUmakefile || -f makefile ]] ; then
701 emake DESTDIR="${D}" install
704 if ! declare -p DOCS &>/dev/null ; then
706 for d in README* ChangeLog AUTHORS NEWS TODO CHANGES \
707 THANKS BUGS FAQ CREDITS CHANGELOG ; do
708 [[ -s "${d}" ]] && dodoc "${d}"
710 elif [[ $(declare -p DOCS) == "declare -a "* ]] ; then
717 # @FUNCTION: has_version
718 # @USAGE: [--host-root] <DEPEND ATOM>
720 # Return true if given package is installed. Otherwise return false.
721 # Callers may override the ROOT variable in order to match packages from an
725 local atom eroot host_root=false root=${ROOT}
726 if [[ $1 == --host-root ]] ; then
732 [ $# -gt 0 ] && die "${FUNCNAME[0]}: unused argument(s): $*"
734 if ${host_root} ; then
735 if ! ___eapi_best_version_and_has_version_support_--host-root; then
736 die "${FUNCNAME[0]}: option --host-root is not supported with EAPI ${EAPI}"
741 if ___eapi_has_prefix_variables; then
742 # [[ ${root} == / ]] would be ambiguous here,
743 # since both prefixes can share root=/ while
744 # having different EPREFIX offsets.
745 if ${host_root} ; then
746 eroot=${root%/}${PORTAGE_OVERRIDE_EPREFIX}/
748 eroot=${root%/}${EPREFIX}/
753 if [[ -n $PORTAGE_IPC_DAEMON ]] ; then
754 "$PORTAGE_BIN_PATH"/ebuild-ipc has_version "${eroot}" "${atom}"
756 "${PORTAGE_BIN_PATH}/ebuild-helpers/portageq" has_version "${eroot}" "${atom}"
764 die "${FUNCNAME[0]}: invalid atom: ${atom}"
767 if [[ -n ${PORTAGE_IPC_DAEMON} ]]; then
768 die "${FUNCNAME[0]}: unexpected ebuild-ipc exit code: ${retval}"
770 die "${FUNCNAME[0]}: unexpected portageq exit code: ${retval}"
776 # @FUNCTION: best_version
777 # @USAGE: [--host-root] <DEPEND ATOM>
779 # Returns the best/most-current match.
780 # Callers may override the ROOT variable in order to match packages from an
784 local atom eroot host_root=false root=${ROOT}
785 if [[ $1 == --host-root ]] ; then
791 [ $# -gt 0 ] && die "${FUNCNAME[0]}: unused argument(s): $*"
793 if ${host_root} ; then
794 if ! ___eapi_best_version_and_has_version_support_--host-root; then
795 die "${FUNCNAME[0]}: option --host-root is not supported with EAPI ${EAPI}"
800 if ___eapi_has_prefix_variables; then
801 # [[ ${root} == / ]] would be ambiguous here,
802 # since both prefixes can share root=/ while
803 # having different EPREFIX offsets.
804 if ${host_root} ; then
805 eroot=${root%/}${PORTAGE_OVERRIDE_EPREFIX}/
807 eroot=${root%/}${EPREFIX}/
812 if [[ -n $PORTAGE_IPC_DAEMON ]] ; then
813 "$PORTAGE_BIN_PATH"/ebuild-ipc best_version "${eroot}" "${atom}"
815 "${PORTAGE_BIN_PATH}/ebuild-helpers/portageq" best_version "${eroot}" "${atom}"
823 die "${FUNCNAME[0]}: invalid atom: ${atom}"
826 if [[ -n ${PORTAGE_IPC_DAEMON} ]]; then
827 die "${FUNCNAME[0]}: unexpected ebuild-ipc exit code: ${retval}"
829 die "${FUNCNAME[0]}: unexpected portageq exit code: ${retval}"
835 if ___eapi_has_master_repositories; then
836 master_repositories() {
837 local output repository=$1 retval
839 [[ $# -gt 0 ]] && die "${FUNCNAME[0]}: unused argument(s): $*"
841 if [[ -n ${PORTAGE_IPC_DAEMON} ]]; then
842 "${PORTAGE_BIN_PATH}/ebuild-ipc" master_repositories "${EROOT}" "${repository}"
844 output=$("${PORTAGE_BIN_PATH}/ebuild-helpers/portageq" master_repositories "${EROOT}" "${repository}")
847 [[ -n ${output} ]] && echo "${output}"
853 die "${FUNCNAME[0]}: invalid repository: ${repository}"
856 if [[ -n ${PORTAGE_IPC_DAEMON} ]]; then
857 die "${FUNCNAME[0]}: unexpected ebuild-ipc exit code: ${retval}"
859 die "${FUNCNAME[0]}: unexpected portageq exit code: ${retval}"
866 if ___eapi_has_repository_path; then
868 local output repository=$1 retval
870 [[ $# -gt 0 ]] && die "${FUNCNAME[0]}: unused argument(s): $*"
872 if [[ -n ${PORTAGE_IPC_DAEMON} ]]; then
873 "${PORTAGE_BIN_PATH}/ebuild-ipc" repository_path "${EROOT}" "${repository}"
875 output=$("${PORTAGE_BIN_PATH}/ebuild-helpers/portageq" get_repo_path "${EROOT}" "${repository}")
878 [[ -n ${output} ]] && echo "${output}"
884 die "${FUNCNAME[0]}: invalid repository: ${repository}"
887 if [[ -n ${PORTAGE_IPC_DAEMON} ]]; then
888 die "${FUNCNAME[0]}: unexpected ebuild-ipc exit code: ${retval}"
890 die "${FUNCNAME[0]}: unexpected portageq exit code: ${retval}"
897 if ___eapi_has_available_eclasses; then
898 available_eclasses() {
899 local output repository=${PORTAGE_REPO_NAME} retval
900 [[ $# -gt 0 ]] && die "${FUNCNAME[0]}: unused argument(s): $*"
902 if [[ -n ${PORTAGE_IPC_DAEMON} ]]; then
903 "${PORTAGE_BIN_PATH}/ebuild-ipc" available_eclasses "${EROOT}" "${repository}"
905 output=$("${PORTAGE_BIN_PATH}/ebuild-helpers/portageq" available_eclasses "${EROOT}" "${repository}")
908 [[ -n ${output} ]] && echo "${output}"
914 die "${FUNCNAME[0]}: invalid repository: ${repository}"
917 if [[ -n ${PORTAGE_IPC_DAEMON} ]]; then
918 die "${FUNCNAME[0]}: unexpected ebuild-ipc exit code: ${retval}"
920 die "${FUNCNAME[0]}: unexpected portageq exit code: ${retval}"
927 if ___eapi_has_eclass_path; then
929 local eclass=$1 output repository=${PORTAGE_REPO_NAME} retval
931 [[ $# -gt 0 ]] && die "${FUNCNAME[0]}: unused argument(s): $*"
933 if [[ -n ${PORTAGE_IPC_DAEMON} ]]; then
934 "${PORTAGE_BIN_PATH}/ebuild-ipc" eclass_path "${EROOT}" "${repository}" "${eclass}"
936 output=$("${PORTAGE_BIN_PATH}/ebuild-helpers/portageq" eclass_path "${EROOT}" "${repository}" "${eclass}")
939 [[ -n ${output} ]] && echo "${output}"
945 die "${FUNCNAME[0]}: invalid repository: ${repository}"
948 if [[ -n ${PORTAGE_IPC_DAEMON} ]]; then
949 die "${FUNCNAME[0]}: unexpected ebuild-ipc exit code: ${retval}"
951 die "${FUNCNAME[0]}: unexpected portageq exit code: ${retval}"
958 if ___eapi_has_license_path; then
960 local license=$1 output repository=${PORTAGE_REPO_NAME} retval
962 [[ $# -gt 0 ]] && die "${FUNCNAME[0]}: unused argument(s): $*"
964 if [[ -n ${PORTAGE_IPC_DAEMON} ]]; then
965 "${PORTAGE_BIN_PATH}/ebuild-ipc" license_path "${EROOT}" "${repository}" "${license}"
967 output=$("${PORTAGE_BIN_PATH}/ebuild-helpers/portageq" license_path "${EROOT}" "${repository}" "${license}")
970 [[ -n ${output} ]] && echo "${output}"
976 die "${FUNCNAME[0]}: invalid repository: ${repository}"
979 if [[ -n ${PORTAGE_IPC_DAEMON} ]]; then
980 die "${FUNCNAME[0]}: unexpected ebuild-ipc exit code: ${retval}"
982 die "${FUNCNAME[0]}: unexpected portageq exit code: ${retval}"
989 if ___eapi_has_package_manager_build_user; then
990 package_manager_build_user() {
991 echo "${PORTAGE_BUILD_USER}"
995 if ___eapi_has_package_manager_build_group; then
996 package_manager_build_group() {
997 echo "${PORTAGE_BUILD_GROUP}"