tags 672230 + patch
thanks

Hi!

I saw the same situation where apt had bombed out leaving packages unpacked 
but not configured. (I filled / ... oops.) I figured this was an opportunity to 
understand and fix this bug:


# apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following extra packages will be installed:
  mysql-server-5.5
Suggested packages:
  tinyca
The following packages will be upgraded:
  mysql-server-5.5
1 upgraded, 0 newly installed, 0 to remove and 42 not upgraded.
2 not fully installed or removed.
Need to get 0 B/8,818 kB of archives.
After this operation, 481 kB disk space will be freed.
Do you want to continue [Y/n]?
Traceback (most recent call last):
  File "/usr/bin/apt-listchanges", line 238, in <module>
    main()
  File "/usr/bin/apt-listchanges", line 48, in main
    debs = apt_listchanges.read_apt_pipeline(config)
  File "/usr/share/apt-listchanges/apt_listchanges.py", line 83, in 
read_apt_pipeline
    return map(lambda pkg: filenames[pkg], order)
  File "/usr/share/apt-listchanges/apt_listchanges.py", line 83, in <lambda>
    return map(lambda pkg: filenames[pkg], order)
KeyError: 'mysql-server-5.5'
dpkg: dependency problems prevent configuration of mysql-server-5.5:
 mysql-server-5.5 depends on mysql-server-core-5.5 (= 5.5.24+dfsg-3); however:
  Version of mysql-server-core-5.5 on system is 5.5.24+dfsg-4.
dpkg: error processing mysql-server-5.5 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.5; however:
  Package mysql-server-5.5 is not configured yet.
dpkg: error processing mysql-server (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 mysql-server-5.5
 mysql-server


The actual messages that are being sent to apt-listchanges are (excluding the 
version header and the config information):

  mysql-server-5.5 5.5.24+dfsg-3 < 5.5.24+dfsg-4 **CONFIGURE**
  mysql-server 5.5.24+dfsg-4 = 5.5.24+dfsg-4 **CONFIGURE**

which means that because apt is only trying to configure packages and not 
install them, there are no filenames for binary packages listed anywhere for 
this package. By way of contrast, a successful run would generate messages 
like:

  sl 3.03-16 < 3.03-17 /var/cache/apt/archives/sl_3.03-17_i386.deb
  sl 3.03-16 < 3.03-17 **CONFIGURE**

meaning that there is both a filename record and then an action record.

Looking at apt_listchanges/apt_listchanges.py around line 83, the filename 
never being set leaves us with:

  filenames = {}
  order = [b'mysql-server-5.5']
  return map(lambda pkg: filenames[pkg], order)

which is clearly going to give us the KeyError that we're seeing.

Changing that map to something that checks that the there is actually a 
filename specified for the given binary package prevents this key error. If the 
package is only being configured, then the user should have already seen the 
changelog in a previous apt run when the package was unpacked, so it's not a 
problem to only look for packages where both the filename and action were 
transmitted to apt-listchanges:

  return [filenames[pkg] for pkg in order if pkg in filenames]

A patch to do this is attached.

cheers
Stuart

-- 
Stuart Prescott    http://www.nanonanonano.net/   stu...@nanonanonano.net
Debian Developer   http://www.debian.org/         stu...@debian.org
GPG fingerprint    BE65 FD1E F4EA 08F3 23D4 3C6D 9FE8 B8CD 71C5 D1A8
diff --git a/apt-listchanges/apt_listchanges.py b/apt-listchanges/apt_listchanges.py
index 180a3dc..e6db888 100644
--- a/apt-listchanges/apt_listchanges.py
+++ b/apt-listchanges/apt_listchanges.py
@@ -80,7 +80,7 @@ def read_apt_pipeline(config):
     # native, this allows things to work, since Y will always be
     # configured first.
 
-    return map(lambda pkg: filenames[pkg], order)
+    return [filenames[pkg] for pkg in order if pkg in filenames]
 
 def mail_changes(address, changes, subject):
     print "apt-listchanges: " + _("Mailing %s: %s") % (address, subject)

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to