Does not correctly interpretes "<"

Bug #535667 reported by Luca Falavigna
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-apt (Debian)
Fix Released
Undecided
Unassigned
python-apt (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: python-apt

I realized apt_pkg.check_dep does not correctly interpretes "<" as strictly minor, while apt_pkg.Dependency.comp_type returns that in case of strictly minor dependency.

I attached a test case showing that, here's its output:
comparison type is <
0.9.9-2 < 0.9.9-1 : False
0.9.9-0 < 0.9.9-1 : True
0.9.9-1 < 0.9.9-1 : True (!!!)
0.9.9-1 << 0.9.9-1 : False

As you can see, it says 0.9.9-1 is minor than itself, which is false. It behaves correctly if comparison type is set to "<<".

I think apt_pkg.Dependency.comp_type should return "<<", or apt_pkg.check_dep should be able to parse "<" as well, as of today there is a discrepancy in that which can cause weird bugs (see bug #484097).

Revision history for this message
Luca Falavigna (dktrkranz) wrote :
description: updated
Revision history for this message
Julian Andres Klode (juliank) wrote :

You know that the Ubuntu version does not have the new API yet. But I guess we can at least change the new API one without breaking much compatibility; because most programs have not been updated yet (and there are not much using this part of the API anyway).

The problem lies in the fact that some things use CompType which returns the standard comparison operators '<' and '>'; whereas others use CompTypeDeb which returns Debian operators '<<' and '>>' defined in the Policy.

I could
  (a) change apt_pkg.check_dep to convert '>'/'<' to '>>' / '<<'; while adding a parameter 'debianized' which accepts
       '<' and '>' in their Debian meaning (le; ge).
  (b) change all other places to return '<<' / '>>'.

For GDebi in Ubuntu, you should fix the program instead. Dependency.CompType has always returned '<' and '>>', and never the CompTypeDeb one.

Revision history for this message
Julian Andres Klode (juliank) wrote :

Fixed in debian-sid revision 370:
  http://bzr.debian.org/loggerhead/apt/python-apt/debian-sid/revision/370

Also added a test case for check_dep and parse_depends.

Changed in python-apt (Debian):
status: New → Fix Committed
Revision history for this message
Luca Falavigna (dktrkranz) wrote :

Yes, I used new APIs to provide my test case to avoid being flooded with DeprecationWarnings on Debian, anyway I checked it produces the same output.

This is really a corner case, it's not very frequent to match the same version with a "<" comparison type, but it can be annoying as this issue revealed. As long as CompTypeDeb remains in 0.8 APIs, I think you can avoid fixing CompType (and thus risking to break some more applications) eventually asking software developers to use CompTypeDeb instead. I'll leave that to to your decision.

Revision history for this message
Julian Andres Klode (juliank) wrote :

> Yes, I used new APIs to provide my test case to avoid being flooded with DeprecationWarnings
> on Debian, anyway I checked it produces the same output.
Well, the problem here was that apt_pkg.check_dep and apt_pkg.CheckDep did the same, although they should do different things (check_dep should treat '<' as less-than, whereas CheckDep should treat it as 'less-equal').

> As long as CompTypeDeb remains in 0.8 APIs
CompTypeDeb was never exported in python-apt, it's just part of the apt-pkg C++ API.

In summary, this means that the following things will do what you want:

  (a) wait for python-apt 0.7.94 and use apt_pkg.check_dep.
OR
  (b) replace '>' and '<' by '>>' and '<<' before passing them to apt_pkg.CheckDep.

Revision history for this message
Luca Falavigna (dktrkranz) wrote :

Yes, I noticed it was not available shortafter I commented on the bug. I'll adopt method (b) for now, eventually dropping it when gdebi adopts new APIs. Thanks!

Revision history for this message
Julian Andres Klode (juliank) wrote :

This bug was fixed in the package python-apt - 0.7.94

---------------
python-apt (0.7.94) unstable; urgency=low

  * Move documentation into python-apt-doc (Closes: #572617)
  * Build documentation only once on the default Python version.
  * python/acquire-item.cc:
    - Add AcquireItem.partialsize member.
  * python/apt_pkgmodule.cc:
    - Treat '>>' and '>', '<<' and '<' as identical in check_dep (LP: #535667).
  * python/generic.cc:
    - Map UntranslatedDepType to dep_type_untranslated.
  * python/tag.cc:
    - Hack the TagFile iterator to not use shared storage (Closes: #572596):
      Scan once, duplicate the section data, and scan again.
  * apt/package.py:
    - Create a string class BaseDependency.__dstr which makes '>' equal to
      '>>' and '<' equal to '<<' (compatibility).
    - Use the binary package version in Version.fetch_source() if the
      source version is not specified (i.e. in the normal case).
    - Always return unicode strings in Package.get_changelog (Closes: #572998).
  * apt/progress/text.py:
    - Drop InstallProgress, it's useless to keep this alias around.
  * apt/progress/old.py:
    - Let the new method call the old one; e.g. status_update() now calls
      self.statusUpdate(). This improves compatibility for sub classes.
  * Merge with Ubuntu:
    - util/get_ubuntu_mirrors_from_lp.py:
      + rewritten to use +archivemirrors-rss and feedburner
    - pre-build.sh: update ubuntu mirrors on bzr-buildpackage (and also do this
      for Debian mirrors)
    - add break for packagekit-backend-apt (<= 0.4.8-0ubuntu4)
  * tests:
    - test_deps: Add tests for apt_pkg.CheckDep, apt_pkg.check_dep,
      apt_pkg.parse_depends and apt_pkg.parse_src_depends.
  * tests/data/aptsources/sources.list.testDistribution:
    - change one mirror which is not on the mirror list anymore.
  * utils/get_debian_mirrors.py:
    - Parse Mirrors.masterlist instead of the HTML web page.
  * utils/get_ubuntu_mirrors_from_lp.py:
    - Sort the mirror list of each country.

 -- Julian Andres Klode <email address hidden> Wed, 10 Mar 2010 16:10:27 +0100

Changed in python-apt (Debian):
status: Fix Committed → Fix Released
Revision history for this message
Julian Andres Klode (juliank) wrote :

Fixed in Ubuntu now as well after the merge.

Changed in python-apt (Ubuntu):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.