Move stale elog cleanup code from ebuild.sh to _doebuild_spawn(), so
authorZac Medico <zmedico@gentoo.org>
Tue, 7 Sep 2010 19:51:08 +0000 (12:51 -0700)
committerZac Medico <zmedico@gentoo.org>
Tue, 7 Sep 2010 19:51:08 +0000 (12:51 -0700)
that elog messages generated by bashrc are preserved when appropriate.

bin/ebuild.sh
pym/portage/package/ebuild/doebuild.py

index e976bd114c6d1bdf65cdf382401923ab59d8473f..d49259bd703eeafd78acefac699edaa07f935a3c 100755 (executable)
@@ -687,7 +687,6 @@ ebuild_phase() {
 
 ebuild_phase_with_hooks() {
        local x phase_name=${1}
-       [ -n "$EBUILD_PHASE" ] && rm -f "$T/logging/$EBUILD_PHASE"
        for x in {pre_,,post_}${phase_name} ; do
                ebuild_phase ${x}
        done
@@ -698,7 +697,15 @@ dyn_pretend() {
 }
 
 dyn_setup() {
-       ebuild_phase_with_hooks pkg_setup
+       if [[ -e $PORTAGE_BUILDDIR/.setuped ]] ; then
+               vecho ">>> It appears that '$PF' is already setup; skipping."
+               vecho ">>> Remove '$PORTAGE_BUILDDIR/.setuped' to force prepare."
+               return 0
+       fi
+       ebuild_phase pre_pkg_setup
+       ebuild_phase pkg_setup
+       > "$PORTAGE_BUILDDIR"/.setuped
+       ebuild_phase post_pkg_setup
 }
 
 dyn_unpack() {
@@ -721,7 +728,7 @@ dyn_unpack() {
        fi
        if [ "${newstuff}" == "yes" ]; then
                # We don't necessarily have privileges to do a full dyn_clean here.
-               rm -rf "${PORTAGE_BUILDDIR}"/{.unpacked,.prepared,.configured,.compiled,.tested,.installed,.packaged,build-info}
+               rm -rf "${PORTAGE_BUILDDIR}"/{.setuped,.unpacked,.prepared,.configured,.compiled,.tested,.installed,.packaged,build-info}
                if ! hasq keepwork $FEATURES ; then
                        rm -rf "${WORKDIR}"
                fi
@@ -740,7 +747,6 @@ dyn_unpack() {
        if [ ! -d "${WORKDIR}" ]; then
                install -m${PORTAGE_WORKDIR_MODE:-0700} -d "${WORKDIR}" || die "Failed to create dir '${WORKDIR}'"
        fi
-       [ -n "$EBUILD_PHASE" ] && rm -f "$T/logging/$EBUILD_PHASE"
        cd "${WORKDIR}" || die "Directory change failed: \`cd '${WORKDIR}'\`"
        ebuild_phase pre_src_unpack
        vecho ">>> Unpacking source..."
@@ -771,7 +777,7 @@ dyn_clean() {
        fi
 
        if [[ $EMERGE_FROM = binary ]] || ! hasq keepwork $FEATURES; then
-               rm -f "$PORTAGE_BUILDDIR"/.{ebuild_changed,logid,unpacked,prepared} \
+               rm -f "$PORTAGE_BUILDDIR"/.{ebuild_changed,logid,setuped,unpacked,prepared} \
                        "$PORTAGE_BUILDDIR"/.{configured,compiled,tested,packaged} \
                        "$PORTAGE_BUILDDIR"/.die_hooks \
                        "$PORTAGE_BUILDDIR"/.ipc_{in,out,lock} \
@@ -987,7 +993,6 @@ dyn_prepare() {
 
        trap abort_prepare SIGINT SIGQUIT
 
-       [ -n "$EBUILD_PHASE" ] && rm -f "$T/logging/$EBUILD_PHASE"
        ebuild_phase pre_src_prepare
        vecho ">>> Preparing source in $PWD ..."
        ebuild_phase src_prepare
@@ -1018,7 +1023,6 @@ dyn_configure() {
 
        trap abort_configure SIGINT SIGQUIT
 
-       [ -n "$EBUILD_PHASE" ] && rm -f "$T/logging/$EBUILD_PHASE"
        ebuild_phase pre_src_configure
 
        vecho ">>> Configuring source in $PWD ..."
@@ -1051,7 +1055,6 @@ dyn_compile() {
 
        trap abort_compile SIGINT SIGQUIT
 
-       [ -n "$EBUILD_PHASE" ] && rm -f "$T/logging/$EBUILD_PHASE"
        ebuild_phase pre_src_compile
 
        vecho ">>> Compiling source in $PWD ..."
@@ -1093,7 +1096,6 @@ dyn_test() {
        else
                local save_sp=${SANDBOX_PREDICT}
                addpredict /
-               [ -n "$EBUILD_PHASE" ] && rm -f "$T/logging/$EBUILD_PHASE"
                ebuild_phase pre_src_test
                ebuild_phase src_test
                touch "$PORTAGE_BUILDDIR/.tested" || \
@@ -1115,7 +1117,6 @@ dyn_install() {
                return 0
        fi
        trap "abort_install" SIGINT SIGQUIT
-       [ -n "$EBUILD_PHASE" ] && rm -f "$T/logging/$EBUILD_PHASE"
        ebuild_phase pre_src_install
        rm -rf "${PORTAGE_BUILDDIR}/image"
        mkdir "${PORTAGE_BUILDDIR}/image"
index 696b65eb7b9fea241ef1eb75bb2efbbd80116524..a61a5668752766ab9a797282c19206754b9afea8 100644 (file)
@@ -92,6 +92,18 @@ def _doebuild_spawn(phase, settings, actionmap=None, **kwargs):
                        os.path.basename(EBUILD_SH_BINARY))),
                        ebuild_sh_arg)
 
+       if phase not in EbuildSpawnProcess._phases_without_builddir:
+               phase_completed_file = os.path.join(settings['PORTAGE_BUILDIR'],
+                       phase.rstrip('e') + 'ed')
+               if not os.path.exists(phase_completed_file):
+                       # If the phase is really going to run then we want
+                       # to eliminate any stale elog messages that may
+                       # exist from a previous run.
+                       try:
+                               os.unlink(os.path.join(settings['T'], 'logging', phase))
+                       except OSError:
+                               pass
+
        settings['EBUILD_PHASE'] = phase
        try:
                return spawn(cmd, settings, **kwargs)