apt.Cache(rootdir="/foo") is honoured only for first instantiation of a Cache per-process

Bug #320665 reported by Max Bowsher on 2009-01-23
Affects Status Importance Assigned to Milestone
apt (Ubuntu)
python-apt (Ubuntu)
Julian Andres Klode

Bug Description

Binary package hint: python-apt

apt.Cache(rootdir="/foo") is honoured only for first instantiation of a Cache per-process

$ python
>>> import apt
>>> apt.Cache(rootdir="/someboguspath")
SystemError: E:Could not open file /someboguspath/var/lib/dpkg/status - ....
>>> apt.Cache(rootdir="/")
...(same exception again, still mentioning /someboguspath)...

Actually, looking into the source, instantiating an apt.Cache object appears to tweak process-global state of the apt_pkg library. If apt_pkg's global state cannot be adequately encapsulated by python-apt, it should be presented to the Python programmer in an obviously global way.

ProblemType: Bug
Architecture: i386
DistroRelease: Ubuntu 9.04
Package: python-apt 0.7.9~exp2ubuntu3
 PATH=(custom, user)
SourcePackage: python-apt
Uname: Linux 2.6.28-5-generic i686

Max Bowsher (maxb) wrote :
Julian Andres Klode (juliank) wrote :

The problem seems to be somewhere in apt_pkg. Changes are accepted as soon as InitSystem() is called. This makes me believe the bug is in apt itself, in apt-pkg/deb/debsystem.cc(debSystem::AddStatusFiles). The problem seems to be that the status file is only registered once.

Changed in python-apt (Ubuntu):
status: New → Confirmed
Julian Andres Klode (juliank) wrote :

Re-initializing the system before every cache creation could help, but this is no good option. I would prefer to see a solution where we don't have to use a global state, but a local one. But I guess this is just impossible.

Julian Andres Klode (juliank) wrote :

This bug is a bug in apt.

affects: python-apt (Ubuntu) → apt (Ubuntu)
Julian Andres Klode (juliank) wrote :

The following attachment is a test case to reproduce this bug.

Julian Andres Klode (juliank) wrote :

I re-added python-apt to the list of affected packages, so we can provide a fix there while apt needs fixing.

Changed in python-apt (Ubuntu):
assignee: nobody → Julian Andres Klode (juliank)
status: New → In Progress
Launchpad Janitor (janitor) wrote :
Download full text (3.6 KiB)

This bug was fixed in the package python-apt -

python-apt ( karmic; urgency=low

  [ Michael Vogt ]
  * apt/package.py:
    - add "recommends" property
  * debian/control:
    - change build-dep for libapt-pkg-dev to >= 0.7.21
  * merged with debian/unstable

  [ Loïc Minier ]
  * Revert addition of gcc and gcc_s to python-apt libs as the toolchain has
    been fixed; LP: #375334.

  [ Julian Andres Klode ]
  * apt/package.py:
   - Introduce Version.get_dependencies() which takes one or more types
     of dependencies and returns a list of Dependency objects.

python-apt ( unstable; urgency=low

  * apt/debfile.py:
    - Fix missing space in message (Closes: #539704)
  * apt/package.py:
    - Add missing argument to Version.__le__() and Version.__ge__()
  * debian/control:
    - Do not build-depend on python-gtk2 and python-vte on kfreebsd-*.
  * setup.py:
    - Always build documentation, even if python-gtk2 is not installed.

python-apt ( unstable; urgency=low

  [ Julian Andres Klode ]
  * python/cache.cc:
    - Support Breaks, Enhances dependency types (Closes: #416247)
  * debian/control:
    - Only recommend libjs-jquery (Closes: #527543)
    - Build-depend on libapt-pkg-dev (>= 0.7.22~)
    - Update Standards-Version to 3.8.2
  * apt/cache.py:
    - Correctly handle rootdir on second and later invocations of
      open(), by calling InitSystem again. (LP: #320665).
    - Provide broken_count, delete_count, install_count, keep_count
      properties (Closes: #532338)
    - Only create Package objects when they are requested, do not keep them in
      a dict. Saves 10MB for 25,000 packages on my machine.
  * apt/package.py:
    - Allow to set the candidate of a package (Closes: #523997)
      + Support assignments to the 'candidate' property of Package objects.
      + Initial patch by Sebastian Heinlein
    - Make comparisons of Version object more robust.
    - Return VersionList objects in Package.versions, which are sequences
      and also provide features of mappings. (partial API BREAK)
      + Allows to get a specific version (Closes: #523998)
  * apt/progress/__init__.py:
    - Do not break out of InstallProgress.waitChild()'s loop just because it
      is hitting EINTR, but only on child exit or on ECHILD.
  * Use debhelper 7 instead of CDBS

  [ Stefano Zacchiroli ]
  * debian/python-apt.doc-base: register the documentation with the
    doc-base system (Closes: #525134)

  [ Sebastian Heinlein ]
  * apt/progress.py: Extract the package name from the status message
    (Closes: #532660)

python-apt ( unstable; urgency=low

  [ Stephan Peijnik ]
  * apt/progress/__init__.py:
    - Exception handling fixes in InstallProgress class.

  [ Michael Vogt ]
  * python/tag.cc:
    - merge patch from John Wright that adds FindRaw method
      (closes: #538723)

python-apt ( unstable; urgency=low

  [ Julian Andres Klode ]
  * data/templates/Debian.info.in: Squeeze will be 6.0, not 5.1

  [ Stephan Peijnik ]
  * apt/progress/__init__.py:
    - add update_status_full() that takes file_size/partial_size as
      additional callback arguments
    - add pulse...


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

Other bug subscribers