From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1R2YD2-00051M-Fg for garchives@archives.gentoo.org; Sun, 11 Sep 2011 00:47:44 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5542421C02B; Sun, 11 Sep 2011 00:47:35 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id D0EF021C02B for ; Sun, 11 Sep 2011 00:47:34 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 38E721B4007 for ; Sun, 11 Sep 2011 00:47:34 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 5125C80042 for ; Sun, 11 Sep 2011 00:47:33 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <88438656a7b3b5824369043792ce27e63eb76f46.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/ebuild.sh bin/phase-helpers.sh X-VCS-Directories: bin/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 88438656a7b3b5824369043792ce27e63eb76f46 Date: Sun, 11 Sep 2011 00:47:33 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 2290d1ae07bce2a5c2121a318ddeaf99 commit: 88438656a7b3b5824369043792ce27e63eb76f46 Author: Zac Medico gentoo org> AuthorDate: Sun Sep 11 00:47:07 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Sun Sep 11 00:47:07 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D88438656 ebuild.sh: split out phase-helpers.sh This relocates phase helper functions that are needed for execution of regular phases, but not for the "depend" phase. It reduces the size of ebuild.sh by 25%, so there's less code to be sourced during the "depend" phase. --- bin/ebuild.sh | 524 +-------------------------------------------= ------ bin/phase-helpers.sh | 524 ++++++++++++++++++++++++++++++++++++++++++++= ++++++ 2 files changed, 528 insertions(+), 520 deletions(-) diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 8df5eef..a5cc5ef 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -238,50 +238,6 @@ best_version() { esac } =20 -use_with() { - if [ -z "$1" ]; then - echo "!!! use_with() called without a parameter." >&2 - echo "!!! use_with [ [value]]" >&2 - return 1 - fi - - if ! has "${EAPI:-0}" 0 1 2 3 ; then - local UW_SUFFIX=3D${3+=3D$3} - else - local UW_SUFFIX=3D${3:+=3D$3} - fi - local UWORD=3D${2:-$1} - - if use $1; then - echo "--with-${UWORD}${UW_SUFFIX}" - else - echo "--without-${UWORD}" - fi - return 0 -} - -use_enable() { - if [ -z "$1" ]; then - echo "!!! use_enable() called without a parameter." >&2 - echo "!!! use_enable [ [value]]" >&2 - return 1 - fi - - if ! has "${EAPI:-0}" 0 1 2 3 ; then - local UE_SUFFIX=3D${3+=3D$3} - else - local UE_SUFFIX=3D${3:+=3D$3} - fi - local UWORD=3D${2:-$1} - - if use $1; then - echo "--enable-${UWORD}${UE_SUFFIX}" - else - echo "--disable-${UWORD}" - fi - return 0 -} - register_die_hook() { local x for x in $* ; do @@ -309,161 +265,6 @@ fi #if no perms are specified, dirs/files will have decent defaults #(not secretive, but not stupid) umask 022 -export DESTTREE=3D/usr -export INSDESTTREE=3D"" -export _E_EXEDESTTREE_=3D"" -export _E_DOCDESTTREE_=3D"" -export INSOPTIONS=3D"-m0644" -export EXEOPTIONS=3D"-m0755" -export LIBOPTIONS=3D"-m0644" -export DIROPTIONS=3D"-m0755" -export MOPREFIX=3D${PN} -declare -a PORTAGE_DOCOMPRESS=3D( /usr/share/{doc,info,man} ) -declare -a PORTAGE_DOCOMPRESS_SKIP=3D( /usr/share/doc/${PF}/html ) - -# adds ".keep" files so that dirs aren't auto-cleaned -keepdir() { - dodir "$@" - local x - if [ "$1" =3D=3D "-R" ] || [ "$1" =3D=3D "-r" ]; then - shift - find "$@" -type d -printf "${D}%p/.keep_${CATEGORY}_${PN}-${SLOT}\n" \ - | tr "\n" "\0" | \ - while read -r -d $'\0' ; do - >> "$REPLY" || \ - die "Failed to recursively create .keep files" - done - else - for x in "$@"; do - >> "${D}${x}/.keep_${CATEGORY}_${PN}-${SLOT}" || \ - die "Failed to create .keep in ${D}${x}" - done - fi -} - -unpack() { - local srcdir - local x - local y - local myfail - local eapi=3D${EAPI:-0} - [ -z "$*" ] && die "Nothing passed to the 'unpack' command" - - for x in "$@"; do - vecho ">>> Unpacking ${x} to ${PWD}" - y=3D${x%.*} - y=3D${y##*.} - - if [[ ${x} =3D=3D "./"* ]] ; then - srcdir=3D"" - elif [[ ${x} =3D=3D ${DISTDIR%/}/* ]] ; then - die "Arguments to unpack() cannot begin with \${DISTDIR}." - elif [[ ${x} =3D=3D "/"* ]] ; then - die "Arguments to unpack() cannot be absolute" - else - srcdir=3D"${DISTDIR}/" - fi - [[ ! -s ${srcdir}${x} ]] && die "${x} does not exist" - - _unpack_tar() { - if [ "${y}" =3D=3D "tar" ]; then - $1 -c -- "$srcdir$x" | tar xof - - assert_sigpipe_ok "$myfail" - else - local cwd_dest=3D${x##*/} - cwd_dest=3D${cwd_dest%.*} - $1 -c -- "${srcdir}${x}" > "${cwd_dest}" || die "$myfail" - fi - } - - myfail=3D"failure unpacking ${x}" - case "${x##*.}" in - tar) - tar xof "$srcdir$x" || die "$myfail" - ;; - tgz) - tar xozf "$srcdir$x" || die "$myfail" - ;; - tbz|tbz2) - ${PORTAGE_BUNZIP2_COMMAND:-${PORTAGE_BZIP2_COMMAND} -d} -c -- "$srcd= ir$x" | tar xof - - assert_sigpipe_ok "$myfail" - ;; - ZIP|zip|jar) - # unzip will interactively prompt under some error conditions, - # as reported in bug #336285 - ( while true ; do echo n || break ; done ) | \ - unzip -qo "${srcdir}${x}" || die "$myfail" - ;; - gz|Z|z) - _unpack_tar "gzip -d" - ;; - bz2|bz) - _unpack_tar "${PORTAGE_BUNZIP2_COMMAND:-${PORTAGE_BZIP2_COMMAND} -d}= " - ;; - 7Z|7z) - local my_output - my_output=3D"$(7z x -y "${srcdir}${x}")" - if [ $? -ne 0 ]; then - echo "${my_output}" >&2 - die "$myfail" - fi - ;; - RAR|rar) - unrar x -idq -o+ "${srcdir}${x}" || die "$myfail" - ;; - LHa|LHA|lha|lzh) - lha xfq "${srcdir}${x}" || die "$myfail" - ;; - a) - ar x "${srcdir}${x}" || die "$myfail" - ;; - deb) - # Unpacking .deb archives can not always be done with - # `ar`. For instance on AIX this doesn't work out. If - # we have `deb2targz` installed, prefer it over `ar` for - # that reason. We just make sure on AIX `deb2targz` is - # installed. - if type -P deb2targz > /dev/null; then - y=3D${x##*/} - local created_symlink=3D0 - if [ ! "$srcdir$x" -ef "$y" ] ; then - # deb2targz always extracts into the same directory as - # the source file, so create a symlink in the current - # working directory if necessary. - ln -sf "$srcdir$x" "$y" || die "$myfail" - created_symlink=3D1 - fi - deb2targz "$y" || die "$myfail" - if [ $created_symlink =3D 1 ] ; then - # Clean up the symlink so the ebuild - # doesn't inadvertently install it. - rm -f "$y" - fi - mv -f "${y%.deb}".tar.gz data.tar.gz || die "$myfail" - else - ar x "$srcdir$x" || die "$myfail" - fi - ;; - lzma) - _unpack_tar "lzma -d" - ;; - xz) - if has $eapi 0 1 2 ; then - vecho "unpack ${x}: file format not recognized. Ignoring." - else - _unpack_tar "xz -d" - fi - ;; - *) - vecho "unpack ${x}: file format not recognized. Ignoring." - ;; - esac - done - # Do not chmod '.' since it's probably ${WORKDIR} and PORTAGE_WORKDIR_M= ODE - # should be preserved. - find . -mindepth 1 -maxdepth 1 ! -type l -print0 | \ - ${XARGS} -0 chmod -fR a+rX,u+w,g-w,o-w -} =20 strip_duplicate_slashes() { if [[ -n $1 ]] ; then @@ -482,326 +283,6 @@ hasg() { return 1 } hasgq() { hasg "$@" >/dev/null ; } -econf() { - local x - - local phase_func=3D$(_ebuild_arg_to_phase "$EAPI" "$EBUILD_PHASE") - if [[ -n $phase_func ]] ; then - if has "$EAPI" 0 1 ; then - [[ $phase_func !=3D src_compile ]] && \ - eqawarn "QA Notice: econf called in" \ - "$phase_func instead of src_compile" - else - [[ $phase_func !=3D src_configure ]] && \ - eqawarn "QA Notice: econf called in" \ - "$phase_func instead of src_configure" - fi - fi - - : ${ECONF_SOURCE:=3D.} - if [ -x "${ECONF_SOURCE}/configure" ]; then - if [[ -n $CONFIG_SHELL && \ - "$(head -n1 "$ECONF_SOURCE/configure")" =3D~ ^'#!'[[:space:]]*/bin/sh= ([[:space:]]|$) ]] ; then - sed -e "1s:^#![[:space:]]*/bin/sh:#!$CONFIG_SHELL:" -i "$ECONF_SOURCE= /configure" || \ - die "Substition of shebang in '$ECONF_SOURCE/configure' failed" - fi - if [ -e /usr/share/gnuconfig/ ]; then - find "${WORKDIR}" -type f '(' \ - -name config.guess -o -name config.sub ')' -print0 | \ - while read -r -d $'\0' x ; do - vecho " * econf: updating ${x/${WORKDIR}\/} with /usr/share/gnuconfi= g/${x##*/}" - cp -f /usr/share/gnuconfig/"${x##*/}" "${x}" - done - fi - - # EAPI=3D4 adds --disable-dependency-tracking to econf - if ! has "$EAPI" 0 1 2 3 3_pre2 && \ - "${ECONF_SOURCE}/configure" --help 2>/dev/null | \ - grep -q disable-dependency-tracking ; then - set -- --disable-dependency-tracking "$@" - fi - - # if the profile defines a location to install libs to aside from defa= ult, pass it on. - # if the ebuild passes in --libdir, they're responsible for the conf_l= ibdir fun. - local CONF_LIBDIR LIBDIR_VAR=3D"LIBDIR_${ABI}" - if [[ -n ${ABI} && -n ${!LIBDIR_VAR} ]] ; then - CONF_LIBDIR=3D${!LIBDIR_VAR} - fi - if [[ -n ${CONF_LIBDIR} ]] && ! hasgq --libdir=3D\* "$@" ; then - export CONF_PREFIX=3D$(hasg --exec-prefix=3D\* "$@") - [[ -z ${CONF_PREFIX} ]] && CONF_PREFIX=3D$(hasg --prefix=3D\* "$@") - : ${CONF_PREFIX:=3D/usr} - CONF_PREFIX=3D${CONF_PREFIX#*=3D} - [[ ${CONF_PREFIX} !=3D /* ]] && CONF_PREFIX=3D"/${CONF_PREFIX}" - [[ ${CONF_LIBDIR} !=3D /* ]] && CONF_LIBDIR=3D"/${CONF_LIBDIR}" - set -- --libdir=3D"$(strip_duplicate_slashes ${CONF_PREFIX}${CONF_LIB= DIR})" "$@" - fi - - set -- \ - --prefix=3D/usr \ - ${CBUILD:+--build=3D${CBUILD}} \ - --host=3D${CHOST} \ - ${CTARGET:+--target=3D${CTARGET}} \ - --mandir=3D/usr/share/man \ - --infodir=3D/usr/share/info \ - --datadir=3D/usr/share \ - --sysconfdir=3D/etc \ - --localstatedir=3D/var/lib \ - "$@" \ - ${EXTRA_ECONF} - vecho "${ECONF_SOURCE}/configure" "$@" - - if ! "${ECONF_SOURCE}/configure" "$@" ; then - - if [ -s config.log ]; then - echo - echo "!!! Please attach the following file when seeking support:" - echo "!!! ${PWD}/config.log" - fi - die "econf failed" - fi - elif [ -f "${ECONF_SOURCE}/configure" ]; then - die "configure is not executable" - else - die "no configure script found" - fi -} - -einstall() { - # CONF_PREFIX is only set if they didn't pass in libdir above. - local LOCAL_EXTRA_EINSTALL=3D"${EXTRA_EINSTALL}" - LIBDIR_VAR=3D"LIBDIR_${ABI}" - if [ -n "${ABI}" -a -n "${!LIBDIR_VAR}" ]; then - CONF_LIBDIR=3D"${!LIBDIR_VAR}" - fi - unset LIBDIR_VAR - if [ -n "${CONF_LIBDIR}" ] && [ "${CONF_PREFIX:+set}" =3D set ]; then - EI_DESTLIBDIR=3D"${D}/${CONF_PREFIX}/${CONF_LIBDIR}" - EI_DESTLIBDIR=3D"$(strip_duplicate_slashes ${EI_DESTLIBDIR})" - LOCAL_EXTRA_EINSTALL=3D"libdir=3D${EI_DESTLIBDIR} ${LOCAL_EXTRA_EINSTA= LL}" - unset EI_DESTLIBDIR - fi - - if [ -f ./[mM]akefile -o -f ./GNUmakefile ] ; then - if [ "${PORTAGE_DEBUG}" =3D=3D "1" ]; then - ${MAKE:-make} -n prefix=3D"${D}usr" \ - datadir=3D"${D}usr/share" \ - infodir=3D"${D}usr/share/info" \ - localstatedir=3D"${D}var/lib" \ - mandir=3D"${D}usr/share/man" \ - sysconfdir=3D"${D}etc" \ - ${LOCAL_EXTRA_EINSTALL} \ - ${MAKEOPTS} ${EXTRA_EMAKE} -j1 \ - "$@" install - fi - ${MAKE:-make} prefix=3D"${D}usr" \ - datadir=3D"${D}usr/share" \ - infodir=3D"${D}usr/share/info" \ - localstatedir=3D"${D}var/lib" \ - mandir=3D"${D}usr/share/man" \ - sysconfdir=3D"${D}etc" \ - ${LOCAL_EXTRA_EINSTALL} \ - ${MAKEOPTS} ${EXTRA_EMAKE} -j1 \ - "$@" install || die "einstall failed" - else - die "no Makefile found" - fi -} - -_eapi0_pkg_nofetch() { - [ -z "${SRC_URI}" ] && return - - elog "The following are listed in SRC_URI for ${PN}:" - local x - for x in $(echo ${SRC_URI}); do - elog " ${x}" - done -} - -_eapi0_src_unpack() { - [[ -n ${A} ]] && unpack ${A} -} - -_eapi0_src_compile() { - if [ -x ./configure ] ; then - econf - fi - _eapi2_src_compile -} - -_eapi0_src_test() { - # Since we don't want emake's automatic die - # support (EAPI 4 and later), and we also don't - # want the warning messages that it produces if - # we call it in 'nonfatal' mode, we use emake_cmd - # to emulate the desired parts of emake behavior. - local emake_cmd=3D"${MAKE:-make} ${MAKEOPTS} ${EXTRA_EMAKE}" - if $emake_cmd -j1 check -n &> /dev/null; then - vecho ">>> Test phase [check]: ${CATEGORY}/${PF}" - if ! $emake_cmd -j1 check; then - has test $FEATURES && die "Make check failed. See above for details." - has test $FEATURES || eerror "Make check failed. See above for detail= s." - fi - elif $emake_cmd -j1 test -n &> /dev/null; then - vecho ">>> Test phase [test]: ${CATEGORY}/${PF}" - if ! $emake_cmd -j1 test; then - has test $FEATURES && die "Make test failed. See above for details." - has test $FEATURES || eerror "Make test failed. See above for details= ." - fi - else - vecho ">>> Test phase [none]: ${CATEGORY}/${PF}" - fi -} - -_eapi1_src_compile() { - _eapi2_src_configure - _eapi2_src_compile -} - -_eapi2_src_configure() { - if [[ -x ${ECONF_SOURCE:-.}/configure ]] ; then - econf - fi -} - -_eapi2_src_compile() { - if [ -f Makefile ] || [ -f GNUmakefile ] || [ -f makefile ]; then - emake || die "emake failed" - fi -} - -_eapi4_src_install() { - if [[ -f Makefile || -f GNUmakefile || -f makefile ]] ; then - emake DESTDIR=3D"${D}" install - fi - - if ! declare -p DOCS &>/dev/null ; then - local d - for d in README* ChangeLog AUTHORS NEWS TODO CHANGES \ - THANKS BUGS FAQ CREDITS CHANGELOG ; do - [[ -s "${d}" ]] && dodoc "${d}" - done - elif [[ $(declare -p DOCS) =3D=3D "declare -a "* ]] ; then - dodoc "${DOCS[@]}" - else - dodoc ${DOCS} - fi -} - -into() { - if [ "$1" =3D=3D "/" ]; then - export DESTTREE=3D"" - else - export DESTTREE=3D$1 - if [ ! -d "${D}${DESTTREE}" ]; then - install -d "${D}${DESTTREE}" - local ret=3D$? - if [[ $ret -ne 0 ]] ; then - helpers_die "${FUNCNAME[0]} failed" - return $ret - fi - fi - fi -} - -insinto() { - if [ "$1" =3D=3D "/" ]; then - export INSDESTTREE=3D"" - else - export INSDESTTREE=3D$1 - if [ ! -d "${D}${INSDESTTREE}" ]; then - install -d "${D}${INSDESTTREE}" - local ret=3D$? - if [[ $ret -ne 0 ]] ; then - helpers_die "${FUNCNAME[0]} failed" - return $ret - fi - fi - fi -} - -exeinto() { - if [ "$1" =3D=3D "/" ]; then - export _E_EXEDESTTREE_=3D"" - else - export _E_EXEDESTTREE_=3D"$1" - if [ ! -d "${D}${_E_EXEDESTTREE_}" ]; then - install -d "${D}${_E_EXEDESTTREE_}" - local ret=3D$? - if [[ $ret -ne 0 ]] ; then - helpers_die "${FUNCNAME[0]} failed" - return $ret - fi - fi - fi -} - -docinto() { - if [ "$1" =3D=3D "/" ]; then - export _E_DOCDESTTREE_=3D"" - else - export _E_DOCDESTTREE_=3D"$1" - if [ ! -d "${D}usr/share/doc/${PF}/${_E_DOCDESTTREE_}" ]; then - install -d "${D}usr/share/doc/${PF}/${_E_DOCDESTTREE_}" - local ret=3D$? - if [[ $ret -ne 0 ]] ; then - helpers_die "${FUNCNAME[0]} failed" - return $ret - fi - fi - fi -} - -insopts() { - export INSOPTIONS=3D"$@" - - # `install` should never be called with '-s' ... - has -s ${INSOPTIONS} && die "Never call insopts() with -s" -} - -diropts() { - export DIROPTIONS=3D"$@" -} - -exeopts() { - export EXEOPTIONS=3D"$@" - - # `install` should never be called with '-s' ... - has -s ${EXEOPTIONS} && die "Never call exeopts() with -s" -} - -libopts() { - export LIBOPTIONS=3D"$@" - - # `install` should never be called with '-s' ... - has -s ${LIBOPTIONS} && die "Never call libopts() with -s" -} - -docompress() { - has "${EAPI}" 0 1 2 3 && die "'docompress' not supported in this EAPI" - - local f g - if [[ $1 =3D "-x" ]]; then - shift - for f; do - f=3D$(strip_duplicate_slashes "${f}"); f=3D${f%/} - [[ ${f:0:1} =3D / ]] || f=3D"/${f}" - for g in "${PORTAGE_DOCOMPRESS_SKIP[@]}"; do - [[ ${f} =3D "${g}" ]] && continue 2 - done - PORTAGE_DOCOMPRESS_SKIP[${#PORTAGE_DOCOMPRESS_SKIP[@]}]=3D${f} - done - else - for f; do - f=3D$(strip_duplicate_slashes "${f}"); f=3D${f%/} - [[ ${f:0:1} =3D / ]] || f=3D"/${f}" - for g in "${PORTAGE_DOCOMPRESS[@]}"; do - [[ ${f} =3D "${g}" ]] && continue 2 - done - PORTAGE_DOCOMPRESS[${#PORTAGE_DOCOMPRESS[@]}]=3D${f} - done - fi -} =20 # debug-print() gets called from many places with verbose status informa= tion useful # for tracking down problems. The output is in $T/eclass-debug.log. @@ -1349,7 +830,10 @@ fi export EBUILD_MASTER_PID=3D$BASHPID trap 'exit 1' SIGTERM =20 -[[ $EBUILD_PHASE =3D=3D depend ]] || source "${PORTAGE_BIN_PATH}/phase-f= unctions.sh" +if [[ $EBUILD_PHASE !=3D depend ]] ; then + source "${PORTAGE_BIN_PATH}/phase-functions.sh" + source "${PORTAGE_BIN_PATH}/phase-helpers.sh" +fi =20 if ! has "$EBUILD_PHASE" clean cleanrm depend && \ [ -f "${T}"/environment ] ; then diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh new file mode 100644 index 0000000..337639f --- /dev/null +++ b/bin/phase-helpers.sh @@ -0,0 +1,524 @@ +#!/bin/bash +# Copyright 1999-2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +export DESTTREE=3D/usr +export INSDESTTREE=3D"" +export _E_EXEDESTTREE_=3D"" +export _E_DOCDESTTREE_=3D"" +export INSOPTIONS=3D"-m0644" +export EXEOPTIONS=3D"-m0755" +export LIBOPTIONS=3D"-m0644" +export DIROPTIONS=3D"-m0755" +export MOPREFIX=3D${PN} +declare -a PORTAGE_DOCOMPRESS=3D( /usr/share/{doc,info,man} ) +declare -a PORTAGE_DOCOMPRESS_SKIP=3D( /usr/share/doc/${PF}/html ) + +into() { + if [ "$1" =3D=3D "/" ]; then + export DESTTREE=3D"" + else + export DESTTREE=3D$1 + if [ ! -d "${D}${DESTTREE}" ]; then + install -d "${D}${DESTTREE}" + local ret=3D$? + if [[ $ret -ne 0 ]] ; then + helpers_die "${FUNCNAME[0]} failed" + return $ret + fi + fi + fi +} + +insinto() { + if [ "$1" =3D=3D "/" ]; then + export INSDESTTREE=3D"" + else + export INSDESTTREE=3D$1 + if [ ! -d "${D}${INSDESTTREE}" ]; then + install -d "${D}${INSDESTTREE}" + local ret=3D$? + if [[ $ret -ne 0 ]] ; then + helpers_die "${FUNCNAME[0]} failed" + return $ret + fi + fi + fi +} + +exeinto() { + if [ "$1" =3D=3D "/" ]; then + export _E_EXEDESTTREE_=3D"" + else + export _E_EXEDESTTREE_=3D"$1" + if [ ! -d "${D}${_E_EXEDESTTREE_}" ]; then + install -d "${D}${_E_EXEDESTTREE_}" + local ret=3D$? + if [[ $ret -ne 0 ]] ; then + helpers_die "${FUNCNAME[0]} failed" + return $ret + fi + fi + fi +} + +docinto() { + if [ "$1" =3D=3D "/" ]; then + export _E_DOCDESTTREE_=3D"" + else + export _E_DOCDESTTREE_=3D"$1" + if [ ! -d "${D}usr/share/doc/${PF}/${_E_DOCDESTTREE_}" ]; then + install -d "${D}usr/share/doc/${PF}/${_E_DOCDESTTREE_}" + local ret=3D$? + if [[ $ret -ne 0 ]] ; then + helpers_die "${FUNCNAME[0]} failed" + return $ret + fi + fi + fi +} + +insopts() { + export INSOPTIONS=3D"$@" + + # `install` should never be called with '-s' ... + has -s ${INSOPTIONS} && die "Never call insopts() with -s" +} + +diropts() { + export DIROPTIONS=3D"$@" +} + +exeopts() { + export EXEOPTIONS=3D"$@" + + # `install` should never be called with '-s' ... + has -s ${EXEOPTIONS} && die "Never call exeopts() with -s" +} + +libopts() { + export LIBOPTIONS=3D"$@" + + # `install` should never be called with '-s' ... + has -s ${LIBOPTIONS} && die "Never call libopts() with -s" +} + +docompress() { + has "${EAPI}" 0 1 2 3 && die "'docompress' not supported in this EAPI" + + local f g + if [[ $1 =3D "-x" ]]; then + shift + for f; do + f=3D$(strip_duplicate_slashes "${f}"); f=3D${f%/} + [[ ${f:0:1} =3D / ]] || f=3D"/${f}" + for g in "${PORTAGE_DOCOMPRESS_SKIP[@]}"; do + [[ ${f} =3D "${g}" ]] && continue 2 + done + PORTAGE_DOCOMPRESS_SKIP[${#PORTAGE_DOCOMPRESS_SKIP[@]}]=3D${f} + done + else + for f; do + f=3D$(strip_duplicate_slashes "${f}"); f=3D${f%/} + [[ ${f:0:1} =3D / ]] || f=3D"/${f}" + for g in "${PORTAGE_DOCOMPRESS[@]}"; do + [[ ${f} =3D "${g}" ]] && continue 2 + done + PORTAGE_DOCOMPRESS[${#PORTAGE_DOCOMPRESS[@]}]=3D${f} + done + fi +} + +# adds ".keep" files so that dirs aren't auto-cleaned +keepdir() { + dodir "$@" + local x + if [ "$1" =3D=3D "-R" ] || [ "$1" =3D=3D "-r" ]; then + shift + find "$@" -type d -printf "${D}%p/.keep_${CATEGORY}_${PN}-${SLOT}\n" \ + | tr "\n" "\0" | \ + while read -r -d $'\0' ; do + >> "$REPLY" || \ + die "Failed to recursively create .keep files" + done + else + for x in "$@"; do + >> "${D}${x}/.keep_${CATEGORY}_${PN}-${SLOT}" || \ + die "Failed to create .keep in ${D}${x}" + done + fi +} + +use_with() { + if [ -z "$1" ]; then + echo "!!! use_with() called without a parameter." >&2 + echo "!!! use_with [ [value]]" >&2 + return 1 + fi + + if ! has "${EAPI:-0}" 0 1 2 3 ; then + local UW_SUFFIX=3D${3+=3D$3} + else + local UW_SUFFIX=3D${3:+=3D$3} + fi + local UWORD=3D${2:-$1} + + if use $1; then + echo "--with-${UWORD}${UW_SUFFIX}" + else + echo "--without-${UWORD}" + fi + return 0 +} + +use_enable() { + if [ -z "$1" ]; then + echo "!!! use_enable() called without a parameter." >&2 + echo "!!! use_enable [ [value]]" >&2 + return 1 + fi + + if ! has "${EAPI:-0}" 0 1 2 3 ; then + local UE_SUFFIX=3D${3+=3D$3} + else + local UE_SUFFIX=3D${3:+=3D$3} + fi + local UWORD=3D${2:-$1} + + if use $1; then + echo "--enable-${UWORD}${UE_SUFFIX}" + else + echo "--disable-${UWORD}" + fi + return 0 +} + +unpack() { + local srcdir + local x + local y + local myfail + local eapi=3D${EAPI:-0} + [ -z "$*" ] && die "Nothing passed to the 'unpack' command" + + for x in "$@"; do + vecho ">>> Unpacking ${x} to ${PWD}" + y=3D${x%.*} + y=3D${y##*.} + + if [[ ${x} =3D=3D "./"* ]] ; then + srcdir=3D"" + elif [[ ${x} =3D=3D ${DISTDIR%/}/* ]] ; then + die "Arguments to unpack() cannot begin with \${DISTDIR}." + elif [[ ${x} =3D=3D "/"* ]] ; then + die "Arguments to unpack() cannot be absolute" + else + srcdir=3D"${DISTDIR}/" + fi + [[ ! -s ${srcdir}${x} ]] && die "${x} does not exist" + + _unpack_tar() { + if [ "${y}" =3D=3D "tar" ]; then + $1 -c -- "$srcdir$x" | tar xof - + assert_sigpipe_ok "$myfail" + else + local cwd_dest=3D${x##*/} + cwd_dest=3D${cwd_dest%.*} + $1 -c -- "${srcdir}${x}" > "${cwd_dest}" || die "$myfail" + fi + } + + myfail=3D"failure unpacking ${x}" + case "${x##*.}" in + tar) + tar xof "$srcdir$x" || die "$myfail" + ;; + tgz) + tar xozf "$srcdir$x" || die "$myfail" + ;; + tbz|tbz2) + ${PORTAGE_BUNZIP2_COMMAND:-${PORTAGE_BZIP2_COMMAND} -d} -c -- "$srcd= ir$x" | tar xof - + assert_sigpipe_ok "$myfail" + ;; + ZIP|zip|jar) + # unzip will interactively prompt under some error conditions, + # as reported in bug #336285 + ( while true ; do echo n || break ; done ) | \ + unzip -qo "${srcdir}${x}" || die "$myfail" + ;; + gz|Z|z) + _unpack_tar "gzip -d" + ;; + bz2|bz) + _unpack_tar "${PORTAGE_BUNZIP2_COMMAND:-${PORTAGE_BZIP2_COMMAND} -d}= " + ;; + 7Z|7z) + local my_output + my_output=3D"$(7z x -y "${srcdir}${x}")" + if [ $? -ne 0 ]; then + echo "${my_output}" >&2 + die "$myfail" + fi + ;; + RAR|rar) + unrar x -idq -o+ "${srcdir}${x}" || die "$myfail" + ;; + LHa|LHA|lha|lzh) + lha xfq "${srcdir}${x}" || die "$myfail" + ;; + a) + ar x "${srcdir}${x}" || die "$myfail" + ;; + deb) + # Unpacking .deb archives can not always be done with + # `ar`. For instance on AIX this doesn't work out. If + # we have `deb2targz` installed, prefer it over `ar` for + # that reason. We just make sure on AIX `deb2targz` is + # installed. + if type -P deb2targz > /dev/null; then + y=3D${x##*/} + local created_symlink=3D0 + if [ ! "$srcdir$x" -ef "$y" ] ; then + # deb2targz always extracts into the same directory as + # the source file, so create a symlink in the current + # working directory if necessary. + ln -sf "$srcdir$x" "$y" || die "$myfail" + created_symlink=3D1 + fi + deb2targz "$y" || die "$myfail" + if [ $created_symlink =3D 1 ] ; then + # Clean up the symlink so the ebuild + # doesn't inadvertently install it. + rm -f "$y" + fi + mv -f "${y%.deb}".tar.gz data.tar.gz || die "$myfail" + else + ar x "$srcdir$x" || die "$myfail" + fi + ;; + lzma) + _unpack_tar "lzma -d" + ;; + xz) + if has $eapi 0 1 2 ; then + vecho "unpack ${x}: file format not recognized. Ignoring." + else + _unpack_tar "xz -d" + fi + ;; + *) + vecho "unpack ${x}: file format not recognized. Ignoring." + ;; + esac + done + # Do not chmod '.' since it's probably ${WORKDIR} and PORTAGE_WORKDIR_M= ODE + # should be preserved. + find . -mindepth 1 -maxdepth 1 ! -type l -print0 | \ + ${XARGS} -0 chmod -fR a+rX,u+w,g-w,o-w +} + +econf() { + local x + + local phase_func=3D$(_ebuild_arg_to_phase "$EAPI" "$EBUILD_PHASE") + if [[ -n $phase_func ]] ; then + if has "$EAPI" 0 1 ; then + [[ $phase_func !=3D src_compile ]] && \ + eqawarn "QA Notice: econf called in" \ + "$phase_func instead of src_compile" + else + [[ $phase_func !=3D src_configure ]] && \ + eqawarn "QA Notice: econf called in" \ + "$phase_func instead of src_configure" + fi + fi + + : ${ECONF_SOURCE:=3D.} + if [ -x "${ECONF_SOURCE}/configure" ]; then + if [[ -n $CONFIG_SHELL && \ + "$(head -n1 "$ECONF_SOURCE/configure")" =3D~ ^'#!'[[:space:]]*/bin/sh= ([[:space:]]|$) ]] ; then + sed -e "1s:^#![[:space:]]*/bin/sh:#!$CONFIG_SHELL:" -i "$ECONF_SOURCE= /configure" || \ + die "Substition of shebang in '$ECONF_SOURCE/configure' failed" + fi + if [ -e /usr/share/gnuconfig/ ]; then + find "${WORKDIR}" -type f '(' \ + -name config.guess -o -name config.sub ')' -print0 | \ + while read -r -d $'\0' x ; do + vecho " * econf: updating ${x/${WORKDIR}\/} with /usr/share/gnuconfi= g/${x##*/}" + cp -f /usr/share/gnuconfig/"${x##*/}" "${x}" + done + fi + + # EAPI=3D4 adds --disable-dependency-tracking to econf + if ! has "$EAPI" 0 1 2 3 3_pre2 && \ + "${ECONF_SOURCE}/configure" --help 2>/dev/null | \ + grep -q disable-dependency-tracking ; then + set -- --disable-dependency-tracking "$@" + fi + + # if the profile defines a location to install libs to aside from defa= ult, pass it on. + # if the ebuild passes in --libdir, they're responsible for the conf_l= ibdir fun. + local CONF_LIBDIR LIBDIR_VAR=3D"LIBDIR_${ABI}" + if [[ -n ${ABI} && -n ${!LIBDIR_VAR} ]] ; then + CONF_LIBDIR=3D${!LIBDIR_VAR} + fi + if [[ -n ${CONF_LIBDIR} ]] && ! hasgq --libdir=3D\* "$@" ; then + export CONF_PREFIX=3D$(hasg --exec-prefix=3D\* "$@") + [[ -z ${CONF_PREFIX} ]] && CONF_PREFIX=3D$(hasg --prefix=3D\* "$@") + : ${CONF_PREFIX:=3D/usr} + CONF_PREFIX=3D${CONF_PREFIX#*=3D} + [[ ${CONF_PREFIX} !=3D /* ]] && CONF_PREFIX=3D"/${CONF_PREFIX}" + [[ ${CONF_LIBDIR} !=3D /* ]] && CONF_LIBDIR=3D"/${CONF_LIBDIR}" + set -- --libdir=3D"$(strip_duplicate_slashes ${CONF_PREFIX}${CONF_LIB= DIR})" "$@" + fi + + set -- \ + --prefix=3D/usr \ + ${CBUILD:+--build=3D${CBUILD}} \ + --host=3D${CHOST} \ + ${CTARGET:+--target=3D${CTARGET}} \ + --mandir=3D/usr/share/man \ + --infodir=3D/usr/share/info \ + --datadir=3D/usr/share \ + --sysconfdir=3D/etc \ + --localstatedir=3D/var/lib \ + "$@" \ + ${EXTRA_ECONF} + vecho "${ECONF_SOURCE}/configure" "$@" + + if ! "${ECONF_SOURCE}/configure" "$@" ; then + + if [ -s config.log ]; then + echo + echo "!!! Please attach the following file when seeking support:" + echo "!!! ${PWD}/config.log" + fi + die "econf failed" + fi + elif [ -f "${ECONF_SOURCE}/configure" ]; then + die "configure is not executable" + else + die "no configure script found" + fi +} + +einstall() { + # CONF_PREFIX is only set if they didn't pass in libdir above. + local LOCAL_EXTRA_EINSTALL=3D"${EXTRA_EINSTALL}" + LIBDIR_VAR=3D"LIBDIR_${ABI}" + if [ -n "${ABI}" -a -n "${!LIBDIR_VAR}" ]; then + CONF_LIBDIR=3D"${!LIBDIR_VAR}" + fi + unset LIBDIR_VAR + if [ -n "${CONF_LIBDIR}" ] && [ "${CONF_PREFIX:+set}" =3D set ]; then + EI_DESTLIBDIR=3D"${D}/${CONF_PREFIX}/${CONF_LIBDIR}" + EI_DESTLIBDIR=3D"$(strip_duplicate_slashes ${EI_DESTLIBDIR})" + LOCAL_EXTRA_EINSTALL=3D"libdir=3D${EI_DESTLIBDIR} ${LOCAL_EXTRA_EINSTA= LL}" + unset EI_DESTLIBDIR + fi + + if [ -f ./[mM]akefile -o -f ./GNUmakefile ] ; then + if [ "${PORTAGE_DEBUG}" =3D=3D "1" ]; then + ${MAKE:-make} -n prefix=3D"${D}usr" \ + datadir=3D"${D}usr/share" \ + infodir=3D"${D}usr/share/info" \ + localstatedir=3D"${D}var/lib" \ + mandir=3D"${D}usr/share/man" \ + sysconfdir=3D"${D}etc" \ + ${LOCAL_EXTRA_EINSTALL} \ + ${MAKEOPTS} ${EXTRA_EMAKE} -j1 \ + "$@" install + fi + ${MAKE:-make} prefix=3D"${D}usr" \ + datadir=3D"${D}usr/share" \ + infodir=3D"${D}usr/share/info" \ + localstatedir=3D"${D}var/lib" \ + mandir=3D"${D}usr/share/man" \ + sysconfdir=3D"${D}etc" \ + ${LOCAL_EXTRA_EINSTALL} \ + ${MAKEOPTS} ${EXTRA_EMAKE} -j1 \ + "$@" install || die "einstall failed" + else + die "no Makefile found" + fi +} + +_eapi0_pkg_nofetch() { + [ -z "${SRC_URI}" ] && return + + elog "The following are listed in SRC_URI for ${PN}:" + local x + for x in $(echo ${SRC_URI}); do + elog " ${x}" + done +} + +_eapi0_src_unpack() { + [[ -n ${A} ]] && unpack ${A} +} + +_eapi0_src_compile() { + if [ -x ./configure ] ; then + econf + fi + _eapi2_src_compile +} + +_eapi0_src_test() { + # Since we don't want emake's automatic die + # support (EAPI 4 and later), and we also don't + # want the warning messages that it produces if + # we call it in 'nonfatal' mode, we use emake_cmd + # to emulate the desired parts of emake behavior. + local emake_cmd=3D"${MAKE:-make} ${MAKEOPTS} ${EXTRA_EMAKE}" + if $emake_cmd -j1 check -n &> /dev/null; then + vecho ">>> Test phase [check]: ${CATEGORY}/${PF}" + if ! $emake_cmd -j1 check; then + has test $FEATURES && die "Make check failed. See above for details." + has test $FEATURES || eerror "Make check failed. See above for detail= s." + fi + elif $emake_cmd -j1 test -n &> /dev/null; then + vecho ">>> Test phase [test]: ${CATEGORY}/${PF}" + if ! $emake_cmd -j1 test; then + has test $FEATURES && die "Make test failed. See above for details." + has test $FEATURES || eerror "Make test failed. See above for details= ." + fi + else + vecho ">>> Test phase [none]: ${CATEGORY}/${PF}" + fi +} + +_eapi1_src_compile() { + _eapi2_src_configure + _eapi2_src_compile +} + +_eapi2_src_configure() { + if [[ -x ${ECONF_SOURCE:-.}/configure ]] ; then + econf + fi +} + +_eapi2_src_compile() { + if [ -f Makefile ] || [ -f GNUmakefile ] || [ -f makefile ]; then + emake || die "emake failed" + fi +} + +_eapi4_src_install() { + if [[ -f Makefile || -f GNUmakefile || -f makefile ]] ; then + emake DESTDIR=3D"${D}" install + fi + + if ! declare -p DOCS &>/dev/null ; then + local d + for d in README* ChangeLog AUTHORS NEWS TODO CHANGES \ + THANKS BUGS FAQ CREDITS CHANGELOG ; do + [[ -s "${d}" ]] && dodoc "${d}" + done + elif [[ $(declare -p DOCS) =3D=3D "declare -a "* ]] ; then + dodoc "${DOCS[@]}" + else + dodoc ${DOCS} + fi +}