severity 629563 important
merge 629563 634174
retitle 629563 apt-listchanges: only shows changes for packages that
will be configured early
tags 629563 patch
quit

It turns out that this bug has nothing to do with apt-listbugs; I just
happened to install apt-listbugs around the same time apt was changed
in a way that broke apt-listchanges' parser for "Version 2"
Pre-Install-Pkgs stdin.  (I'm not sure precisely when this happened;
there is nothing obvious about it in apt's changelog.)  When run as a
Pre-Install-Pkgs program, apt-listchanges assumes that there will be a
**CONFIGURE** line on its stdin for every package that is going to be
upgraded, but apt now only provides such lines for packages that have
to be configured early (before other packages can be unpacked).
Therefore, apt-listchanges doesn't show changelogs (or news) anymore
for any package that doesn't have to be configured early.

Patch attached.  The important part is the lower half of the changes
to read_apt_pipeline; I also added a bunch of debugging messages (only
shown if --debug is on the command line) to make it easier to figure
out similar problems in the future.

zw
--- apt-listchanges.py	2011-05-31 02:58:07.000000000 -0700
+++ apt-listchanges.py	2011-10-15 09:46:15.627926518 -0700
@@ -47,6 +47,11 @@
         # stdin is a pipe
         debs = apt_listchanges.read_apt_pipeline(config)
 
+    if config.debug:
+        sys.stderr.write("To list:\n")
+        for d in debs: sys.stderr.write("\t%s\n" % d)
+        sys.stderr.write("\n")
+
     try:
         # Give any forked processes (eg. lynx) a normal stdin;
         # See Debian Bug #343423
--- apt-listchanges/apt_listchanges.py	2011-05-31 02:58:07.000000000 -0700
+++ apt-listchanges/apt_listchanges.py	2011-10-15 10:29:59.554819445 -0700
@@ -40,7 +40,9 @@
 # keep track of tar/dpkg-deb errors like in pre-2.0
 
 def read_apt_pipeline(config):
+    if config.debug: sys.stderr.write("APT pipeline messages:\n")
     version = sys.stdin.readline().rstrip()
+    if config.debug: sys.stderr.write("\t%s\n" % version)
     if version != "VERSION 2":
         sys.stderr.write(_('''Wrong or missing VERSION from apt pipeline
 (is Dpkg::Tools::Options::/usr/bin/apt-listchanges::Version set to 2?)
@@ -49,15 +51,19 @@
 
     while 1:
         line = sys.stdin.readline().rstrip()
+        if config.debug: sys.stderr.write("\t%s\n" % line)
         if not line:
             break
-
         if line.startswith('quiet='):
             config.quiet = int(line[len('quiet='):])
 
     filenames = {}
-    order = []
+    toconfig = []
+    toremove = []
+
     for pkgline in sys.stdin.readlines():
+        pkgline = pkgline.rstrip()
+        if config.debug: sys.stderr.write("\t%s\n" % pkgline)
         if not pkgline:
             break
 
@@ -66,9 +72,9 @@
             continue
 
         if filename == '**CONFIGURE**':
-            order.append(pkgname)
-        elif filename == '**REMOVE**':
-            continue
+            toconfig.append(pkgname)
+        elif filename == '**REMOVE**' or filename == '**ERROR**':
+            toremove.append(pkgname)
         else:
             filenames[pkgname] = filename
 
@@ -80,7 +86,20 @@
     # native, this allows things to work, since Y will always be
     # configured first.
 
-    return map(lambda pkg: filenames[pkg], order)
+    # apt doesn't explicitly configure everything anymore, so sort
+    # the things to be configured first, and then do everything else
+    # in alphabetical order.  Also, drop from the list everything
+    # that's to be removed.
+    for pkg in toremove:
+        del filenames[pkg]
+
+    ordered_filenames = []
+    for pkg in toconfig:
+        ordered_filenames.append(filenames[pkg])
+        del filenames[pkg]
+
+    ordered_filenames.extend(sorted(filenames.values()))
+    return ordered_filenames
 
 def mail_changes(address, changes, subject):
     print "apt-listchanges: " + _("Mailing %s: %s") % (address, subject)

Reply via email to