Send the ebuild die message through eerror and make sure that elog_process() gets...
authorZac Medico <zmedico@gentoo.org>
Wed, 27 Jun 2007 01:20:56 +0000 (01:20 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 27 Jun 2007 01:20:56 +0000 (01:20 -0000)
svn path=/main/trunk/; revision=7047

bin/isolated-functions.sh
pym/emerge/__init__.py
pym/portage/__init__.py
pym/portage/dbapi/vartree.py

index e6517af74d3b97a558b833f89e0d1ba46b2283db..161937734821da02d6b1cdae657aeb4a4e5c6275 100755 (executable)
@@ -23,7 +23,7 @@ dump_trace() {
                 strip=$(( $1 ))
         fi
 
-        echo "Call stack:"
+        eerror "Call stack:"
         for (( n = ${#FUNCNAME[@]} - 1, p = ${#BASH_ARGV[@]} ; n > $strip ; n-- )) ; do
                 funcname=${FUNCNAME[${n} - 1]}
                 sourcefile=$(basename ${BASH_SOURCE[${n}]})
@@ -37,31 +37,32 @@ dump_trace() {
                         done
                         (( p -= ${BASH_ARGC[${n} - 1]} ))
                 fi
-                echo "  ${sourcefile}, line ${lineno}:   Called ${funcname}${args:+ ${args}}"
+                eerror "${sourcefile}, line ${lineno}: Called ${funcname}${args:+ ${args}}"
         done
 }
 
 diefunc() {
         local funcname="$1" lineno="$2" exitcode="$3"
         shift 3
-        echo >&2
-        echo "!!! ERROR: $CATEGORY/$PF failed." >&2
-        dump_trace 2 1>&2
-        echo "  $(basename "${BASH_SOURCE[1]}"), line ${BASH_LINENO[0]}:   Called die" 1>&2
-        echo >&2
-        echo "!!! ${*:-(no error message)}" >&2
-        echo "!!! If you need support, post the topmost build error, and the call stack if relevant." >&2
+        eerror
+        eerror "ERROR: $CATEGORY/$PF failed."
+        dump_trace 2
+        eerror "$(basename "${BASH_SOURCE[1]}"), line ${BASH_LINENO[0]}:   Called die"
+        eerror
+        eerror "${*:-(no error message)}"
+        eerror "If you need support, post the topmost build error, and the call stack if relevant."
         [ -n "${PORTAGE_LOG_FILE}" ] && \
-            echo "!!! A complete build log is located at '${PORTAGE_LOG_FILE}'." >&2
-        echo >&2
+            eerror "A complete build log is located at '${PORTAGE_LOG_FILE}'."
         if [ -n "${EBUILD_OVERLAY_ECLASSES}" ] ; then
-                echo "This ebuild used the following eclasses from overlays:" >&2
-                echo >&2
-                for x in ${EBUILD_OVERLAY_ECLASSES} ; do
-                        echo "  ${x}" >&2
-                done
-                echo >&2
+                eerror "This ebuild used eclasses from overlays: ${EBUILD_OVERLAY_ECLASSES}"
+        fi
+        if [ ${EBUILD#${PORTDIR}/} == ${EBUILD} ] ; then
+            local overlay=${EBUILD%/*}
+            overlay=${overlay%/*}
+            overlay=${overlay%/*}
+            eerror "This ebuild is from an overlay: '${overlay}/'"
         fi
+        eerror
 
         if [ "${EBUILD_PHASE/depend}" == "${EBUILD_PHASE}" ]; then
                 local x
index 57447e8f1b63867ad4a4528dabd4eb155d6b8ba5..1a084b602555c1504a331d2d98813dd5aa7bebde 100644 (file)
@@ -3229,7 +3229,8 @@ class MergeTask(object):
                                                        pkgsettings, self.edebug, mydbapi=portdb,
                                                        tree="porttree")
                                                del pkgsettings["PORTAGE_BINPKG_TMPFILE"]
-                                               if "--buildpkgonly" in self.myopts:
+                                               if retval != os.EX_OK or \
+                                                       "--buildpkgonly" in self.myopts:
                                                        elog_process(pkg_key, pkgsettings)
                                                if retval != os.EX_OK:
                                                        return retval
index cbe55475c1ec5db3dd5658be3077df34bdbb6858..2f9c8ee3cfcae505e7ccbf1392ab70503ee2de82 100644 (file)
@@ -3254,6 +3254,7 @@ def doebuild_environment(myebuild, mydo, myroot, mysettings, debug, use_cache, m
        mysettings["FILESDIR"] = pkg_dir+"/files"
        mysettings["PF"]       = mypv
 
+       mysettings["PORTDIR"] = os.path.realpath(mysettings["PORTDIR"])
        mysettings["ECLASSDIR"]   = mysettings["PORTDIR"]+"/eclass"
        mysettings["SANDBOX_LOG"] = mycpv.replace("/", "_-_")
 
@@ -4000,19 +4001,6 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
                        print "!!! Unknown mydo:",mydo
                        return 1
 
-               if retval != os.EX_OK and tree == "porttree":
-                       for i in xrange(len(mydbapi.porttrees)-1):
-                               t = mydbapi.porttrees[i+1]
-                               if myebuild.startswith(t):
-                                       # Display the non-cannonical path, in case it's different, to
-                                       # prevent confusion.
-                                       overlays = mysettings["PORTDIR_OVERLAY"].split()
-                                       try:
-                                               writemsg("!!! This ebuild is from an overlay: '%s'\n" % \
-                                                       overlays[i], noiselevel=-1)
-                                       except IndexError:
-                                               pass
-                                       break
                return retval
 
        finally:
index eac509b968d033232ead58df01bc9cf947e94457..61a80a1d0a28241cc4c60faae21db28649e3141c 100644 (file)
@@ -20,7 +20,7 @@ from portage.util import apply_secpass_permissions, ConfigProtect, ensure_dirs,
        grabfile, grabdict, normalize_path, new_protect_filename
 from portage.versions import pkgsplit, catpkgsplit, catsplit, best, pkgcmp
 
-from portage import listdir, dep_expand, config, flatten, key_expand, \
+from portage import listdir, dep_expand, flatten, key_expand, \
        doebuild_environment, doebuild, env_update, \
        abssymlink, movefile, _movefile, bsd_chflags
 
@@ -650,6 +650,7 @@ class vartree(object):
                        self.root = clone.root[:]
                        self.dbapi = copy.deepcopy(clone.dbapi)
                        self.populated = 1
+                       from portage import config
                        self.settings = config(clone=clone.settings)
                else:
                        self.root = root[:]
@@ -1058,6 +1059,7 @@ class dblink(object):
                                uid=portage_uid, gid=portage_gid, mode=070, mask=0)
                builddir_lock = None
                catdir_lock = None
+               retval = -1
                try:
                        if myebuildpath:
                                catdir_lock = lockdir(catdir)
@@ -1090,23 +1092,27 @@ class dblink(object):
                                         self.settings, use_cache=0, tree="vartree",
                                         mydbapi=self.vartree.dbapi, vartree=self.vartree)
 
-                               # process logs created during pre/postrm
-                               elog_process(self.mycpv, self.settings)
-
                                # XXX: Decide how to handle failures here.
                                if retval != os.EX_OK:
                                        writemsg("!!! FAILED postrm: %s\n" % retval, noiselevel=-1)
                                        return retval
-                               doebuild(myebuildpath, "cleanrm", self.myroot, self.settings,
-                                       tree="vartree", mydbapi=self.vartree.dbapi,
-                                       vartree=self.vartree)
-                       
+
                        # regenerate reverse NEEDED map
                        self.vartree.dbapi.libmap.update()
 
                finally:
                        if builddir_lock:
-                               unlockdir(builddir_lock)
+                               try:
+                                       if myebuildpath:
+                                               # process logs created during pre/postrm
+                                               elog_process(self.mycpv, self.settings)
+                                               if retval == os.EX_OK:
+                                                       doebuild(myebuildpath, "cleanrm", self.myroot,
+                                                               self.settings, tree="vartree",
+                                                               mydbapi=self.vartree.dbapi,
+                                                               vartree=self.vartree)
+                               finally:
+                                       unlockdir(builddir_lock)
                        try:
                                if myebuildpath and not catdir_lock:
                                        # Lock catdir for removal if empty.
@@ -1609,9 +1615,12 @@ class dblink(object):
                        slot_matches.append(self.mycpv)
 
                others_in_slot = []
+               from portage import config
                for cur_cpv in slot_matches:
+                       # Clone the config in case one of these has to be unmerged since
+                       # we need it to have private ${T} etc... for things like elog.
                        others_in_slot.append(dblink(self.cat, catsplit(cur_cpv)[1],
-                               self.vartree.root, self.settings,
+                               self.vartree.root, config(clone=self.settings),
                                vartree=self.vartree))
                retval = self._security_check(others_in_slot)
                if retval:
@@ -1806,12 +1815,6 @@ class dblink(object):
                        contents=contents, env=self.settings.environ())
 
                writemsg_stdout(">>> %s %s\n" % (self.mycpv,"merged."))
-
-               # Process ebuild logfiles
-               elog_process(self.mycpv, self.settings)
-               if "noclean" not in self.settings.features:
-                       doebuild(myebuild, "clean", destroot, self.settings,
-                               tree=self.treetype, mydbapi=mydbapi, vartree=self.vartree)
                return os.EX_OK
 
        def mergeme(self, srcroot, destroot, outfile, secondhand, stufftomerge, cfgfiledict, thismtime):
@@ -2083,12 +2086,21 @@ class dblink(object):
 
        def merge(self, mergeroot, inforoot, myroot, myebuild=None, cleanup=0,
                mydbapi=None, prev_mtimes=None):
+               retval = -1
+               self.lockdb()
                try:
-                       self.lockdb()
-                       return self.treewalk(mergeroot, myroot, inforoot, myebuild,
+                       retval = self.treewalk(mergeroot, myroot, inforoot, myebuild,
                                cleanup=cleanup, mydbapi=mydbapi, prev_mtimes=prev_mtimes)
+                       # Process ebuild logfiles
+                       elog_process(self.mycpv, self.settings)
+                       if retval == os.EX_OK and "noclean" not in self.settings.features:
+                               if myebuild is None:
+                                       myebuild = os.path.join(inforoot, self.pkg + ".ebuild")
+                               doebuild(myebuild, "clean", myroot, self.settings,
+                                       tree=self.treetype, mydbapi=mydbapi, vartree=self.vartree)
                finally:
                        self.unlockdb()
+               return retval
 
        def getstring(self,name):
                "returns contents of a file with whitespace converted to spaces"