FEATURES=unmerge-logs
authorZac Medico <zmedico@gentoo.org>
Mon, 20 Jul 2009 22:43:41 +0000 (22:43 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 20 Jul 2009 22:43:41 +0000 (22:43 -0000)
Keep logs from successful unmerge phases. This is relevant only when
PORT_LOGDIR is set.

Thanks to Diego Pettenò <flameeyes@gentoo.org> for the suggestion.

svn path=/main/trunk/; revision=13844

cnf/make.globals
man/make.conf.5
pym/portage/dbapi/vartree.py

index 167f61d53567046a65d1660b0f262fa4ac62c5e5..4693e20621938e86806cf26136a827a64041fbb9 100644 (file)
@@ -39,7 +39,7 @@ RESUMECOMMAND="/usr/bin/wget -c -t 5 -T 60 --passive-ftp -O \"\${DISTDIR}/\${FIL
 
 # Default user options
 FEATURES="assume-digests distlocks fixpackages parallel-fetch protect-owned
-          sandbox sfperms strict unmerge-orphans userfetch"
+          sandbox sfperms strict unmerge-logs unmerge-orphans userfetch"
 
 # Ignore file collisions in /lib/modules since files inside this directory
 # are never unmerged, and therefore collisions must be ignored in order for
index 2b5a7645f470bb1ff84589e97a2acdf658b6b1f9..229e50b3fb49b470ccc76bd202dd721bb7043fa5 100644 (file)
@@ -373,6 +373,10 @@ continue to execute the remaining phases as if the failure had not occurred.
 Note that the test phase for a specific package may be disabled by masking
 the "test" \fBUSE\fR flag in \fBpackage.use.mask\fR (see \fBportage\fR(5)).
 .TP
+.B unmerge\-logs
+Keep logs from successful unmerge phases. This is relevant only when
+\fBPORT_LOGDIR\fR is set.
+.TP
 .B unmerge\-orphans
 If a file is not claimed by another package in the same slot and it is not
 protected by \fICONFIG_PROTECT\fR, unmerge it even if the modification time or
index fe9e8e67f517fe55c72f3f05135386f856b76cff..88ec7b3c7b60e4942ab28dbd3588cdd4106d55fa 100644 (file)
@@ -2038,6 +2038,7 @@ class dblink(object):
                catdir_lock = None
                scheduler = self._scheduler
                retval = -1
+               failures = 0
                try:
                        if myebuildpath:
                                catdir_lock = lockdir(catdir)
@@ -2065,6 +2066,7 @@ class dblink(object):
 
                                # XXX: Decide how to handle failures here.
                                if retval != os.EX_OK:
+                                       failures += 1
                                        writemsg(_("!!! FAILED prerm: %s\n") % retval, noiselevel=-1)
 
                        self._unmerge_pkgfiles(pkgfiles, others_in_slot)
@@ -2087,6 +2089,7 @@ class dblink(object):
 
                                # XXX: Decide how to handle failures here.
                                if retval != os.EX_OK:
+                                       failures += 1
                                        writemsg(_("!!! FAILED postrm: %s\n") % retval, noiselevel=-1)
 
                        # Skip this if another package in the same slot has just been
@@ -2188,6 +2191,13 @@ class dblink(object):
                                        unlockdir(catdir_lock)
 
                if log_path is not None:
+
+                       if not failures and 'unmerge-logs' not in self.settings.features:
+                               try:
+                                       os.unlink(log_path)
+                               except OSError:
+                                       pass
+
                        try:
                                st = os.stat(log_path)
                        except OSError: