summaryrefslogtreecommitdiff
path: root/apt/cache.py
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2012-08-14 14:58:25 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2012-08-14 14:58:25 +0200
commitc1ad8a0fbc0adfebdb847f28da92b3d5a1f90582 (patch)
tree80225148a1c1d0d4283fb76e827c6ccc9ca206bf /apt/cache.py
parentc736d5c9290a2ffdb8802a4ac62e521cf1218b54 (diff)
parentdfd6bacface878eecf3fec4876bdae2f0491a646 (diff)
downloadpython-apt-c1ad8a0fbc0adfebdb847f28da92b3d5a1f90582.tar.gz
merged from the debian-sid tree
Diffstat (limited to 'apt/cache.py')
-rw-r--r--apt/cache.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/apt/cache.py b/apt/cache.py
index be137b76..86a788bb 100644
--- a/apt/cache.py
+++ b/apt/cache.py
@@ -46,8 +46,13 @@ class LockFailedException(IOError):
class Cache(object):
"""Dictionary-like package cache.
- This class has all the packages that are available in it's
- dictionary.
+ The APT cache file contains a hash table mapping names of binary
+ packages to their metadata. A Cache object is the in-core
+ representation of the same. It provides access to APTs idea of the
+ list of available packages.
+
+ The cache can be used like a mapping from package names to Package
+ objects (although only getting items is supported).
Keyword arguments:
progress -- a OpProgress object
@@ -84,6 +89,10 @@ class Cache(object):
apt_pkg.config.set("Dir", rootdir)
apt_pkg.config.set("Dir::State::status",
rootdir + "/var/lib/dpkg/status")
+ # also set dpkg to the rootdir path so that its called for the
+ # --print-foreign-architectures call
+ apt_pkg.config.set("Dir::bin::dpkg",
+ os.path.join(rootdir, "usr", "bin", "dpkg"))
# create required dirs/files when run with special rootdir
# automatically
self._check_and_create_required_dirs(rootdir)
@@ -112,7 +121,7 @@ class Cache(object):
]
for d in dirs:
if not os.path.exists(rootdir + d):
- print "creating: ", rootdir + d
+ #print "creating: ", rootdir + d
os.makedirs(rootdir + d)
for f in files:
if not os.path.exists(rootdir + f):
@@ -143,8 +152,7 @@ class Cache(object):
self._sorted_set = None
self._weakref.clear()
- self._have_multi_arch = bool(apt_pkg.config.value_list("APT::" +
- "Architectures"))
+ self._have_multi_arch = len(apt_pkg.get_architectures()) > 1
progress.op = _("Building data structures")
i = last = 0
@@ -507,7 +515,7 @@ class Cache(object):
self._callbacks[name].append(callback)
def actiongroup(self):
- """Return an ActionGroup() object for the current cache.
+ """Return an `ActionGroup` object for the current cache.
Action groups can be used to speedup actions. The action group is
active as soon as it is created, and disabled when the object is
@@ -520,7 +528,7 @@ class Cache(object):
for package in my_selected_packages:
package.mark_install()
- This way, the ActionGroup is automatically released as soon as the
+ This way, the action group is automatically released as soon as the
with statement block is left. It also has the benefit of making it
clear which parts of the code run with a action group and which
don't.