summaryrefslogtreecommitdiff
path: root/apt
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-09-07 13:37:20 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2010-09-07 13:37:20 +0200
commit5498a3d94354732d215e23beeb9c07a47616cabb (patch)
tree1736eb4aa18d8025b688b08be843a8a0338725dc /apt
parentbc301a8f07e50c7a14973b10fa4cb95f7a2beff2 (diff)
parent3aaf50270475e0a2a5fc8e7783e2f8917f8ac327 (diff)
downloadpython-apt-5498a3d94354732d215e23beeb9c07a47616cabb.tar.gz
* add "provides" property to the apt.Version objects
* apt/debfile.py: - fix error when reading binary content and add regresion test * merged patch from Samuel Lidén Borell to fix crash if there utf8 in the control file (LP: #624290) and add test * apt/cache.py: - add "sources_list" parameter to cache.update() to force updating a single sources.list entry only * debian/control: - add missing build-depends on python-debian (needed to run the tests for apt.debfile.DebPackage()
Diffstat (limited to 'apt')
-rw-r--r--apt/cache.py22
-rw-r--r--apt/debfile.py2
-rw-r--r--apt/package.py5
3 files changed, 26 insertions, 3 deletions
diff --git a/apt/cache.py b/apt/cache.py
index f64b489a..586df366 100644
--- a/apt/cache.py
+++ b/apt/cache.py
@@ -327,12 +327,14 @@ class Cache(object):
@deprecated_args
def update(self, fetch_progress=None, pulse_interval=0,
- raise_on_error=True):
+ raise_on_error=True, sources_list=None):
"""Run the equivalent of apt-get update.
The first parameter *fetch_progress* may be set to an instance of
apt.progress.FetchProgress, the default is apt.progress.FetchProgress()
.
+ sources_list -- Update a alternative sources.list than the default.
+ Note that the sources.list.d directory is ignored in this case
"""
lockfile = apt_pkg.config.find_dir("Dir::State::Lists") + "lock"
lock = apt_pkg.get_lock(lockfile)
@@ -340,11 +342,23 @@ class Cache(object):
if lock < 0:
raise LockFailedException("Failed to lock %s" % lockfile)
+ if sources_list:
+ old_sources_list = apt_pkg.config.find("Dir::Etc::sourcelist")
+ old_sources_list_d = apt_pkg.config.find("Dir::Etc::sourceparts")
+ old_cleanup = apt_pkg.config.find("APT::List-Cleanup")
+ apt_pkg.config.set("Dir::Etc::sourcelist", os.path.abspath(sources_list))
+ apt_pkg.config.set("Dir::Etc::sourceparts", "xxx")
+ apt_pkg.config.set("APT::List-Cleanup", "0")
+ slist = apt_pkg.SourceList()
+ slist.read_main_list()
+ else:
+ slist = self._list
+
try:
if fetch_progress is None:
fetch_progress = apt.progress.base.AcquireProgress()
try:
- res = self._cache.update(fetch_progress, self._list,
+ res = self._cache.update(fetch_progress, slist,
pulse_interval)
except SystemError, e:
raise FetchFailedException(e)
@@ -354,6 +368,10 @@ class Cache(object):
return res
finally:
os.close(lock)
+ if sources_list:
+ apt_pkg.config.set("Dir::Etc::sourcelist", old_sources_list)
+ apt_pkg.config.set("Dir::Etc::sourceparts", old_sources_list_d)
+ apt_pkg.config.set("APT::List-Cleanup", old_cleanup)
@deprecated_args
def install_archives(self, pm, install_progress):
diff --git a/apt/debfile.py b/apt/debfile.py
index d8159546..7728ed21 100644
--- a/apt/debfile.py
+++ b/apt/debfile.py
@@ -66,7 +66,7 @@ class DebPackage(object):
self._debfile = apt_inst.DebFile(open(self.filename))
control = self._debfile.control.extractdata("control")
# hm, 'replace' is probably better but python2.6 test fail with that
- self._sections = apt_pkg.TagSection(control.decode("UTF-8", 'ignore'))
+ self._sections = apt_pkg.TagSection(control)
self.pkgname = self._sections["Package"]
def __getitem__(self, key):
diff --git a/apt/package.py b/apt/package.py
index 228a3385..871c1e16 100644
--- a/apt/package.py
+++ b/apt/package.py
@@ -415,6 +415,11 @@ class Version(object):
return depends_list
@property
+ def provides(self):
+ """ Return a list of names that this version provides."""
+ return [p[0] for p in self._cand.provides_list]
+
+ @property
def enhances(self):
"""Return the list of enhances for the package version."""
return self.get_dependencies("Enhances")