summaryrefslogtreecommitdiff
path: root/apt
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-09-07 13:26:35 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2010-09-07 13:26:35 +0200
commit6c5feb6111db81f4e7ec871275daa736a6fc793c (patch)
tree47d06e08e7236be2d700e28af0e2aad4ccb562d9 /apt
parent33bbf9482fe486aab915768fc74609d303c1e1f9 (diff)
parentb390a866fc3af9e7050148f11fb558fd52a8a703 (diff)
downloadpython-apt-6c5feb6111db81f4e7ec871275daa736a6fc793c.tar.gz
* 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() * apt/debfile: - don't fail if we conflict with the pkgs we are reinstalling
Diffstat (limited to 'apt')
-rw-r--r--apt/cache.py22
-rw-r--r--apt/debfile.py5
2 files changed, 23 insertions, 4 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 f4a31379..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):
@@ -347,7 +347,8 @@ class DebPackage(object):
'targetver' : c_or.target_ver }
self._cache.op_progress.done()
return False
- if c_or.target_pkg.name in provides:
+ if (c_or.target_pkg.name in provides and
+ self.pkgname != pkg.name):
self._dbg(2, "would break (conflicts) %s" % provides)
self._failure_string += _("Breaks existing package '%(pkgname)s' that conflict: '%(targetpkg)s'. But the '%(debfile)s' provides it via: '%(provides)s'") % {
'provides' : ",".join(provides),