summaryrefslogtreecommitdiff
path: root/apt/cache.py
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-09-03 11:57:44 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2010-09-03 11:57:44 +0200
commit297adb794c0f2548ea45dc3582ae0912724fcf9c (patch)
treee3cbee454234f274b9720242771f156500e35225 /apt/cache.py
parent0d622864bf45b2826335b3be31330829f43db7cd (diff)
downloadpython-apt-297adb794c0f2548ea45dc3582ae0912724fcf9c.tar.gz
* apt/cache.py:
- add "sources_list" parameter to cache.update() to force updating a single sources.list entry only
Diffstat (limited to 'apt/cache.py')
-rw-r--r--apt/cache.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/apt/cache.py b/apt/cache.py
index f64b489a..585fca0a 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,6 +342,15 @@ 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")
+ self._list.read_main_list()
+
try:
if fetch_progress is None:
fetch_progress = apt.progress.base.AcquireProgress()
@@ -354,6 +365,11 @@ 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)
+ self._list.read_main_list()
@deprecated_args
def install_archives(self, pm, install_progress):