From 297adb794c0f2548ea45dc3582ae0912724fcf9c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 3 Sep 2010 11:57:44 +0200 Subject: * apt/cache.py: - add "sources_list" parameter to cache.update() to force updating a single sources.list entry only --- apt/cache.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'apt/cache.py') 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): -- cgit v1.2.3