Bug #202748 - When merging a binary package, only clean up
authorZac Medico <zmedico@gentoo.org>
Thu, 20 Dec 2007 04:02:21 +0000 (04:02 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 20 Dec 2007 04:02:21 +0000 (04:02 -0000)
temp files on success. Otherwise, leave the temp files
intact for debugging purposes. (trunk r8971)

svn path=/main/branches/2.1.2/; revision=8972

pym/portage.py

index 1a05a071237c3a81703d2c1b5be1b807cf390009..bf27c1fa57e503fa02db0f5600a7bc443d05587e 100644 (file)
@@ -9439,6 +9439,7 @@ def pkgmerge(mytbz2, myroot, mysettings, mydbapi=None, vartree=None, prev_mtimes
        mycat = None
        mypkg = None
        did_merge_phase = False
+       success = False
        try:
                """ Don't lock the tbz2 file because the filesytem could be readonly or
                shared by a cluster."""
@@ -9516,6 +9517,7 @@ def pkgmerge(mytbz2, myroot, mysettings, mydbapi=None, vartree=None, prev_mtimes
                retval = mylink.merge(pkgloc, infloc, myroot, myebuild, cleanup=0,
                        mydbapi=mydbapi, prev_mtimes=prev_mtimes)
                did_merge_phase = True
+               success = retval == os.EX_OK
                return retval
        finally:
                mysettings.pop("PORTAGE_BINPKG_FILE", None)
@@ -9528,7 +9530,8 @@ def pkgmerge(mytbz2, myroot, mysettings, mydbapi=None, vartree=None, prev_mtimes
                                # so that it's only called once.
                                elog_process(mycat + "/" + mypkg, mysettings)
                        try:
-                               shutil.rmtree(builddir)
+                               if success:
+                                       shutil.rmtree(builddir)
                        except (IOError, OSError), e:
                                if e.errno != errno.ENOENT:
                                        raise