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

bin/ebuild.sh
bin/emerge
pym/portage.py

index 30b929957feeefa010c75fa3313e4c6bf103bef2..2dbe7cf9f163792a73b18c670a0facf8d17957f7 100755 (executable)
@@ -284,24 +284,25 @@ register_die_hook() {
 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
@@ -328,7 +329,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}]})
@@ -342,7 +343,7 @@ 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
 }
 
index 5aa826c931de9dfafb14a55240532bb64d608d0b..5d75db69b821b1422a2488aecf3ffcf47ae16919 100755 (executable)
@@ -3192,7 +3192,8 @@ class MergeTask(object):
                                                retval = portage.doebuild(y, "package", myroot,
                                                        pkgsettings, self.edebug, mydbapi=portdb,
                                                        tree="porttree")
-                                               if "--buildpkgonly" in self.myopts:
+                                               if retval != os.EX_OK or \
+                                                       "--buildpkgonly" in self.myopts:
                                                        portage.elog_process(pkg_key, pkgsettings)
                                                if retval != os.EX_OK:
                                                        return retval
index 361e8b1a7c37b85c224db0f1caf5372b5a641cef..db7ddcabdbe59343dd261f785fa6495fe5b7ee2f 100644 (file)
@@ -3144,6 +3144,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("/", "_-_")
 
@@ -3895,19 +3896,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:
@@ -7131,6 +7119,7 @@ class dblink:
                                uid=portage_uid, gid=portage_gid, mode=070, mask=0)
                builddir_lock = None
                catdir_lock = None
+               retval = -1
                try:
                        if myebuildpath:
                                catdir_lock = portage_locks.lockdir(catdir)
@@ -7160,20 +7149,24 @@ class dblink:
                                         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)
 
                finally:
                        if builddir_lock:
-                               portage_locks.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.
@@ -7507,8 +7500,10 @@ class dblink:
 
                others_in_slot = []
                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:
@@ -7782,12 +7777,6 @@ class dblink:
                        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):
@@ -8058,12 +8047,21 @@ class dblink:
 
        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"