Code review comment for lp:~lasall/update-notifier/compare-verobj-id

Dominique Lasserre (lasall) wrote :

I run into this issue that depcache.keep_count was one item higher than my own cache iterations with depcache.marked_keep (see following code snippet):

[...]
tmpkeep = []
for pkg in keep: # keep is a list with all depcache.marked_keep package objects
  ver = pkg.current_ver
  if ver is None:
    continue
  cand = depcache.get_candidate_ver(pkg)
  if not cand.id == ver.id: # version objects compared by id
    if cand == ver: # version objects compared with ==
      print(cand)
      print(ver)
    tmpkeep.append(pkg)
keep = tmpkeep
[...]

I get exactly one package object from this code snippet:
<apt_pkg.Version object: Pkg:'libexiv2-11' Ver:'0.22-2' Section:'libs' Arch:'amd64' Size:769732 ISize:2281472 Hash:30169 ID:103107 Priority:4>
<apt_pkg.Version object: Pkg:'libexiv2-11' Ver:'0.22-2' Section:'libs' Arch:'amd64' Size:0 ISize:2314240 Hash:62916 ID:219590 Priority:4>

$ apt-cache policy libexiv2-11
libexiv2-11:
  Installed: 0.22-2
  Candidate: 0.22-2
  Version table:
     0.22-2 0
        112 http://archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
 *** 0.22-2 0
        100 /var/lib/dpkg/status

It took me a while to figure that out. I looked up how oher software (including update-notifier) implemented this piece of code and because update-notifier would run into same issue I did this merge request.

« Back to merge proposal