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 1R2sLB-0002xR-DG for garchives@archives.gentoo.org; Sun, 11 Sep 2011 22:17:29 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EA78C21C169; Sun, 11 Sep 2011 22:17:21 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 8332A21C169 for ; Sun, 11 Sep 2011 22:17:21 +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 BF7811B4008 for ; Sun, 11 Sep 2011 22:17:20 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 219B780042 for ; Sun, 11 Sep 2011 22:17:20 +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: Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/ebuild.sh bin/phase-functions.sh X-VCS-Directories: bin/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: fdd2bc1c1fdf8f20732749d44c39c3cab3cc2d52 Date: Sun, 11 Sep 2011 22:17:20 +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: eb6b6fc3070614d9a91540292f27e7fa commit: fdd2bc1c1fdf8f20732749d44c39c3cab3cc2d52 Author: Zac Medico gentoo org> AuthorDate: Sun Sep 11 22:17:09 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Sun Sep 11 22:17:09 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3Dfdd2bc1c ebuild.sh: move ebuild_main to phase-functions.sh --- bin/ebuild.sh | 265 ++++++++----------------------------------= ------ bin/phase-functions.sh | 175 +++++++++++++++++++++++++++++++ 2 files changed, 217 insertions(+), 223 deletions(-) diff --git a/bin/ebuild.sh b/bin/ebuild.sh index ccf84a4..6bcc6b3 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -991,12 +991,41 @@ then export DEBUGBUILD=3D1 fi =20 -#a reasonable default for $S -[[ -z ${S} ]] && export S=3D${WORKDIR}/${P} +if [[ $EBUILD_PHASE =3D depend ]] ; then + export SANDBOX_ON=3D"0" + set -f + + if [ -n "${dbkey}" ] ; then + if [ ! -d "${dbkey%/*}" ]; then + install -d -g ${PORTAGE_GID} -m2775 "${dbkey%/*}" + fi + # Make it group writable. 666&~002=3D=3D664 + umask 002 + fi + + auxdbkeys=3D"DEPEND RDEPEND SLOT SRC_URI RESTRICT HOMEPAGE LICENSE + DESCRIPTION KEYWORDS INHERITED IUSE REQUIRED_USE PDEPEND PROVIDE EAPI + PROPERTIES DEFINED_PHASES UNUSED_05 UNUSED_04 + UNUSED_03 UNUSED_02 UNUSED_01" =20 -# Note: readonly variables interfere with preprocess_ebuild_env(), so -# declare them only after it has already run. -if [ "${EBUILD_PHASE}" !=3D "depend" ] ; then + #the extra $(echo) commands remove newlines + [ -n "${EAPI}" ] || EAPI=3D0 + + if [ -n "${dbkey}" ] ; then + > "${dbkey}" + for f in ${auxdbkeys} ; do + echo $(echo ${!f}) >> "${dbkey}" || exit $? + done + else + for f in ${auxdbkeys} ; do + echo $(echo ${!f}) 1>&9 || exit $? + done + exec 9>&- + fi + set +f +else + # Note: readonly variables interfere with preprocess_ebuild_env(), so + # declare them only after it has already run. declare -r $PORTAGE_READONLY_METADATA $PORTAGE_READONLY_VARS case "$EAPI" in 0|1|2) @@ -1005,227 +1034,17 @@ if [ "${EBUILD_PHASE}" !=3D "depend" ] ; then declare -r ED EPREFIX EROOT ;; esac -fi - -ebuild_main() { - - # Subshell/helper die support (must export for the die helper). - # Since this function is typically executed in a subshell, - # setup EBUILD_MASTER_PID to refer to the current $BASHPID, - # which seems to give the best results when further - # nested subshells call die. - export EBUILD_MASTER_PID=3D$BASHPID - trap 'exit 1' SIGTERM - - if [[ $EBUILD_PHASE !=3D depend ]] ; then - # Force configure scripts that automatically detect ccache to - # respect FEATURES=3D"-ccache". - has ccache $FEATURES || export CCACHE_DISABLE=3D1 - - local phase_func=3D$(_ebuild_arg_to_phase "$EAPI" "$EBUILD_PHASE") - [[ -n $phase_func ]] && _ebuild_phase_funcs "$EAPI" "$phase_func" - unset phase_func - fi - - source_all_bashrcs - - case ${EBUILD_SH_ARGS} in - nofetch) - ebuild_phase_with_hooks pkg_nofetch - ;; - prerm|postrm|postinst|config|info) - if has "$EBUILD_SH_ARGS" config info && \ - ! declare -F "pkg_$EBUILD_SH_ARGS" >/dev/null ; then - ewarn "pkg_${EBUILD_SH_ARGS}() is not defined: '${EBUILD##*/}'" - fi - export SANDBOX_ON=3D"0" - if [ "${PORTAGE_DEBUG}" !=3D "1" ] || [ "${-/x/}" !=3D "$-" ]; then - ebuild_phase_with_hooks pkg_${EBUILD_SH_ARGS} - else - set -x - ebuild_phase_with_hooks pkg_${EBUILD_SH_ARGS} - set +x - fi - if [[ $EBUILD_PHASE =3D=3D postinst ]] && [[ -n $PORTAGE_UPDATE_ENV ]]= ; then - # Update environment.bz2 in case installation phases - # need to pass some variables to uninstallation phases. - save_ebuild_env --exclude-init-phases | \ - filter_readonly_variables --filter-path \ - --filter-sandbox --allow-extra-vars \ - | ${PORTAGE_BZIP2_COMMAND} -c -f9 > "$PORTAGE_UPDATE_ENV" - assert "save_ebuild_env failed" - fi - ;; - unpack|prepare|configure|compile|test|clean|install) - if [[ ${SANDBOX_DISABLED:-0} =3D 0 ]] ; then - export SANDBOX_ON=3D"1" - else - export SANDBOX_ON=3D"0" - fi - - case "$EBUILD_SH_ARGS" in - configure|compile) - - local x - for x in ASFLAGS CCACHE_DIR CCACHE_SIZE \ - CFLAGS CXXFLAGS LDFLAGS LIBCFLAGS LIBCXXFLAGS ; do - [[ ${!x+set} =3D set ]] && export $x - done - unset x - - has distcc $FEATURES && [[ -n $DISTCC_DIR ]] && \ - [[ ${SANDBOX_WRITE/$DISTCC_DIR} =3D $SANDBOX_WRITE ]] && \ - addwrite "$DISTCC_DIR" - - x=3DLIBDIR_$ABI - [ -z "$PKG_CONFIG_PATH" -a -n "$ABI" -a -n "${!x}" ] && \ - export PKG_CONFIG_PATH=3D/usr/${!x}/pkgconfig - - if has noauto $FEATURES && \ - [[ ! -f $PORTAGE_BUILDDIR/.unpacked ]] ; then - echo - echo "!!! We apparently haven't unpacked..." \ - "This is probably not what you" - echo "!!! want to be doing... You are using" \ - "FEATURES=3Dnoauto so I'll assume" - echo "!!! that you know what you are doing..." \ - "You have 5 seconds to abort..." - echo - - local x - for x in 1 2 3 4 5 6 7 8; do - LC_ALL=3DC sleep 0.25 - done - - sleep 3 - fi - - cd "$PORTAGE_BUILDDIR" - if [ ! -d build-info ] ; then - mkdir build-info - cp "$EBUILD" "build-info/$PF.ebuild" - fi - - #our custom version of libtool uses $S and $D to fix - #invalid paths in .la files - export S D =20 - ;; - esac - - if [ "${PORTAGE_DEBUG}" !=3D "1" ] || [ "${-/x/}" !=3D "$-" ]; then - dyn_${EBUILD_SH_ARGS} - else - set -x - dyn_${EBUILD_SH_ARGS} - set +x - fi - export SANDBOX_ON=3D"0" - ;; - help|pretend|setup|preinst) - #pkg_setup needs to be out of the sandbox for tmp file creation; - #for example, awking and piping a file in /tmp requires a temp file to= be created - #in /etc. If pkg_setup is in the sandbox, both our lilo and apache eb= uilds break. - export SANDBOX_ON=3D"0" - if [ "${PORTAGE_DEBUG}" !=3D "1" ] || [ "${-/x/}" !=3D "$-" ]; then - dyn_${EBUILD_SH_ARGS} - else - set -x - dyn_${EBUILD_SH_ARGS} - set +x - fi - ;; - depend) - export SANDBOX_ON=3D"0" - set -f - - if [ -n "${dbkey}" ] ; then - if [ ! -d "${dbkey%/*}" ]; then - install -d -g ${PORTAGE_GID} -m2775 "${dbkey%/*}" - fi - # Make it group writable. 666&~002=3D=3D664 - umask 002 - fi - - auxdbkeys=3D"DEPEND RDEPEND SLOT SRC_URI RESTRICT HOMEPAGE LICENSE - DESCRIPTION KEYWORDS INHERITED IUSE REQUIRED_USE PDEPEND PROVIDE EAPI - PROPERTIES DEFINED_PHASES UNUSED_05 UNUSED_04 - UNUSED_03 UNUSED_02 UNUSED_01" - - #the extra $(echo) commands remove newlines - [ -n "${EAPI}" ] || EAPI=3D0 - - if [ -n "${dbkey}" ] ; then - > "${dbkey}" - for f in ${auxdbkeys} ; do - echo $(echo ${!f}) >> "${dbkey}" || exit $? - done - else - for f in ${auxdbkeys} ; do - echo $(echo ${!f}) 1>&9 || exit $? - done + if [[ -n $EBUILD_SH_ARGS ]] ; then + ( + # Don't allow subprocesses to inherit the pipe which + # emerge uses to monitor ebuild.sh. exec 9>&- - fi - set +f - ;; - _internal_test) - ;; - *) - export SANDBOX_ON=3D"1" - echo "Unrecognized EBUILD_SH_ARGS: '${EBUILD_SH_ARGS}'" - echo - dyn_help - exit 1 - ;; - esac -} - -if [[ -s $SANDBOX_LOG ]] ; then - # We use SANDBOX_LOG to check for sandbox violations, - # so we ensure that there can't be a stale log to - # interfere with our logic. - x=3D - if [[ -n SANDBOX_ON ]] ; then - x=3D$SANDBOX_ON - export SANDBOX_ON=3D0 - fi - - rm -f "$SANDBOX_LOG" || \ - die "failed to remove stale sandbox log: '$SANDBOX_LOG'" - - if [[ -n $x ]] ; then - export SANDBOX_ON=3D$x + ebuild_main ${EBUILD_SH_ARGS} + exit 0 + ) + exit $? fi - unset x -fi - -if [[ $EBUILD_PHASE =3D depend ]] ; then - ebuild_main -elif [[ -n $EBUILD_SH_ARGS ]] ; then - ( - # Don't allow subprocesses to inherit the pipe which - # emerge uses to monitor ebuild.sh. - exec 9>&- - - ebuild_main - - # Save the env only for relevant phases. - if ! has "$EBUILD_SH_ARGS" clean help info nofetch ; then - umask 002 - save_ebuild_env | filter_readonly_variables \ - --filter-features > "$T/environment" - assert "save_ebuild_env failed" - chown portage:portage "$T/environment" &>/dev/null - chmod g+w "$T/environment" &>/dev/null - fi - [[ -n $PORTAGE_EBUILD_EXIT_FILE ]] && > "$PORTAGE_EBUILD_EXIT_FILE" - if [[ -n $PORTAGE_IPC_DAEMON ]] ; then - [[ ! -s $SANDBOX_LOG ]] - "$PORTAGE_BIN_PATH"/ebuild-ipc exit $? - fi - exit 0 - ) - exit $? fi =20 # Do not exit when ebuild.sh is sourced by other scripts. diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh index 5216877..383253d 100644 --- a/bin/phase-functions.sh +++ b/bin/phase-functions.sh @@ -609,3 +609,178 @@ _ebuild_phase_funcs() { ;; esac } + +ebuild_main() { + + # Subshell/helper die support (must export for the die helper). + # Since this function is typically executed in a subshell, + # setup EBUILD_MASTER_PID to refer to the current $BASHPID, + # which seems to give the best results when further + # nested subshells call die. + export EBUILD_MASTER_PID=3D$BASHPID + trap 'exit 1' SIGTERM + + #a reasonable default for $S + [[ -z ${S} ]] && export S=3D${WORKDIR}/${P} + + if [[ -s $SANDBOX_LOG ]] ; then + # We use SANDBOX_LOG to check for sandbox violations, + # so we ensure that there can't be a stale log to + # interfere with our logic. + local x=3D + if [[ -n SANDBOX_ON ]] ; then + x=3D$SANDBOX_ON + export SANDBOX_ON=3D0 + fi + + rm -f "$SANDBOX_LOG" || \ + die "failed to remove stale sandbox log: '$SANDBOX_LOG'" + + if [[ -n $x ]] ; then + export SANDBOX_ON=3D$x + fi + unset x + fi + + # Force configure scripts that automatically detect ccache to + # respect FEATURES=3D"-ccache". + has ccache $FEATURES || export CCACHE_DISABLE=3D1 + + local phase_func=3D$(_ebuild_arg_to_phase "$EAPI" "$EBUILD_PHASE") + [[ -n $phase_func ]] && _ebuild_phase_funcs "$EAPI" "$phase_func" + unset phase_func + + source_all_bashrcs + + case ${1} in + nofetch) + ebuild_phase_with_hooks pkg_nofetch + ;; + prerm|postrm|postinst|config|info) + if has "${1}" config info && \ + ! declare -F "pkg_${1}" >/dev/null ; then + ewarn "pkg_${1}() is not defined: '${EBUILD##*/}'" + fi + export SANDBOX_ON=3D"0" + if [ "${PORTAGE_DEBUG}" !=3D "1" ] || [ "${-/x/}" !=3D "$-" ]; then + ebuild_phase_with_hooks pkg_${1} + else + set -x + ebuild_phase_with_hooks pkg_${1} + set +x + fi + if [[ $EBUILD_PHASE =3D=3D postinst ]] && [[ -n $PORTAGE_UPDATE_ENV ]]= ; then + # Update environment.bz2 in case installation phases + # need to pass some variables to uninstallation phases. + save_ebuild_env --exclude-init-phases | \ + filter_readonly_variables --filter-path \ + --filter-sandbox --allow-extra-vars \ + | ${PORTAGE_BZIP2_COMMAND} -c -f9 > "$PORTAGE_UPDATE_ENV" + assert "save_ebuild_env failed" + fi + ;; + unpack|prepare|configure|compile|test|clean|install) + if [[ ${SANDBOX_DISABLED:-0} =3D 0 ]] ; then + export SANDBOX_ON=3D"1" + else + export SANDBOX_ON=3D"0" + fi + + case "${1}" in + configure|compile) + + local x + for x in ASFLAGS CCACHE_DIR CCACHE_SIZE \ + CFLAGS CXXFLAGS LDFLAGS LIBCFLAGS LIBCXXFLAGS ; do + [[ ${!x+set} =3D set ]] && export $x + done + unset x + + has distcc $FEATURES && [[ -n $DISTCC_DIR ]] && \ + [[ ${SANDBOX_WRITE/$DISTCC_DIR} =3D $SANDBOX_WRITE ]] && \ + addwrite "$DISTCC_DIR" + + x=3DLIBDIR_$ABI + [ -z "$PKG_CONFIG_PATH" -a -n "$ABI" -a -n "${!x}" ] && \ + export PKG_CONFIG_PATH=3D/usr/${!x}/pkgconfig + + if has noauto $FEATURES && \ + [[ ! -f $PORTAGE_BUILDDIR/.unpacked ]] ; then + echo + echo "!!! We apparently haven't unpacked..." \ + "This is probably not what you" + echo "!!! want to be doing... You are using" \ + "FEATURES=3Dnoauto so I'll assume" + echo "!!! that you know what you are doing..." \ + "You have 5 seconds to abort..." + echo + + local x + for x in 1 2 3 4 5 6 7 8; do + LC_ALL=3DC sleep 0.25 + done + + sleep 3 + fi + + cd "$PORTAGE_BUILDDIR" + if [ ! -d build-info ] ; then + mkdir build-info + cp "$EBUILD" "build-info/$PF.ebuild" + fi + + #our custom version of libtool uses $S and $D to fix + #invalid paths in .la files + export S D + + ;; + esac + + if [ "${PORTAGE_DEBUG}" !=3D "1" ] || [ "${-/x/}" !=3D "$-" ]; then + dyn_${1} + else + set -x + dyn_${1} + set +x + fi + export SANDBOX_ON=3D"0" + ;; + help|pretend|setup|preinst) + #pkg_setup needs to be out of the sandbox for tmp file creation; + #for example, awking and piping a file in /tmp requires a temp file to= be created + #in /etc. If pkg_setup is in the sandbox, both our lilo and apache eb= uilds break. + export SANDBOX_ON=3D"0" + if [ "${PORTAGE_DEBUG}" !=3D "1" ] || [ "${-/x/}" !=3D "$-" ]; then + dyn_${1} + else + set -x + dyn_${1} + set +x + fi + ;; + _internal_test) + ;; + *) + export SANDBOX_ON=3D"1" + echo "Unrecognized arg '${1}'" + echo + dyn_help + exit 1 + ;; + esac + + # Save the env only for relevant phases. + if ! has "${1}" clean help info nofetch ; then + umask 002 + save_ebuild_env | filter_readonly_variables \ + --filter-features > "$T/environment" + assert "save_ebuild_env failed" + chown portage:portage "$T/environment" &>/dev/null + chmod g+w "$T/environment" &>/dev/null + fi + [[ -n $PORTAGE_EBUILD_EXIT_FILE ]] && > "$PORTAGE_EBUILD_EXIT_FILE" + if [[ -n $PORTAGE_IPC_DAEMON ]] ; then + [[ ! -s $SANDBOX_LOG ]] + "$PORTAGE_BIN_PATH"/ebuild-ipc exit $? + fi +}