summaryrefslogtreecommitdiff
path: root/apt
diff options
context:
space:
mode:
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),