I found another case in which a package is not shown as "kept back":
If a upgradeable package fails the first sanity check (if 
check_changes_for_sanity(...), ca. line 195), its name is added to 
pkgs_kept_back.
If it passes the first, but fails the second sanity check (for example if it 
depends on a package with conffile changes), its name is not added to 
pkgs_kept_back.
The attached patch fixes this and the previously described problems.

The patch I sent first can now be ignored.

Thanks

Max Gaukler
--- /tmp/usr/bin/unattended-upgrade	2009-03-03 08:48:55.000000000 +0100
+++ unattended-upgrade2	2009-05-01 18:30:06.000000000 +0200
@@ -198,12 +198,12 @@
                 else:
                     logging.debug("sanity check failed")
                     rewind_cache(cache, pkgs_to_upgrade)
-                    pkgs_kept_back.append(pkg)
+                    pkgs_kept_back.append(pkg.name)
             except SystemError, e:
                 # can't upgrade
                 logging.warning(_("package '%s' upgradable but fails to be marked for upgrade (%s)") % e)
                 rewind_cache(cache, pkgs_to_ugprade)
-                pkgs_kept_back.append(pkg)
+                pkgs_kept_back.append(pkg.name)
                 
 
     pkgs = "\n".join([pkg.name for pkg in pkgs_to_upgrade])
@@ -244,6 +244,7 @@
                 # some other package again!
                 logging.warning(_("Package '%s' has conffile prompt and needs to be upgraded manually") % pkgname_from_deb(item.DestFile))
                 blacklisted_pkgs.append(pkgname_from_deb(item.DestFile))
+                pkgs_kept_back.append(pkgname_from_deb(item.DestFile))
 
 
         # redo the selection about the packages to upgrade based on the new
@@ -261,6 +262,8 @@
                                             blacklisted_pkgs):
                      pkgs_to_upgrade.append(pkg)
                 else:
+                    if not (pkg.name in pkgs_kept_back):
+                        pkgs_kept_back.append(pkg.name)
                     logging.info(_("package '%s' not upgraded") % pkg.name)
                     cache.clear()
                     for pkg2 in pkgs_to_upgrade:
@@ -270,8 +273,8 @@
 
     logging.debug("InstCount=%i DelCount=%i BrokenCout=%i" % (cache._depcache.InstCount, cache._depcache.DelCount, cache._depcache.BrokenCount))
 
-    # check what we have
-    if len(pkgs_to_upgrade) == 0:
+    # exit if there is nothing to do and nothing to report
+    if (len(pkgs_to_upgrade) == 0) and (len(pkgs_kept_back) == 0):
         logging.info(_("No packages found that can be upgraded unattended"))
         sys.exit(0)    
 
@@ -338,7 +341,7 @@
         s += "\n"
         if pkgs_kept_back:
             s += _("Packages with upgradable origin but kept back:\n")
-            s += " " + wrap(" ".join([pkg.name for pkg in pkgs_kept_back]), 70, " ")
+            s += " " + wrap(" ".join(pkgs_kept_back), 70, " ")
             s += "\n"
         s += "\n"
         s += _("Package installation log:")

Reply via email to