try to be more forgiving if unlinking fails, because we end up in an unknown state...
authorFabian Groffen <grobian@gentoo.org>
Thu, 11 Feb 2010 18:36:10 +0000 (18:36 -0000)
committerFabian Groffen <grobian@gentoo.org>
Thu, 11 Feb 2010 18:36:10 +0000 (18:36 -0000)
svn path=/main/branches/prefix/; revision=15337

pym/portage/dbapi/vartree.py

index 6d2c74ae1d22f0f75565b412fed585e10c4045a0..f82fc0374c5e7af2cc4e6bfc6f6913881570cd86 100644 (file)
@@ -3445,6 +3445,18 @@ class dblink(object):
                                                # suid/sgid files are rendered harmless.
                                                os.chmod(file_name, 0)
                                        os.unlink(file_name)
+                               except OSError as ose:
+                                       # If the chmod or unlink fails, you are in trouble.
+                                       # With Prefix this can be because the file is owned
+                                       # by someone else (a screwup by root?), on a normal
+                                       # system maybe filesystem corruption.  In any case,
+                                       # if we backtrace and die here, we leave the system
+                                       # in a totally undefined state, hence we just bleed
+                                       # like hell and continue to hopefully finish all our
+                                       # administrative and pkg_postinst stuff.
+                                       showMessage(colorize("WARN", _("WARNING:"))
+                                                       + " Could not chmod or unlink %s: %s\n" % (file_name, ose),
+                                                       level=logging.WARN, noiselevel=-1)
                                finally:
                                        if bsd_chflags and pflags != 0:
                                                # Restore the parent flags we saved before unlinking