From 62a719e6b26c1e34371a8a39f456d4237e78ef46 Mon Sep 17 00:00:00 2001 From: gfxmonk Date: Wed, 22 Jun 2011 18:38:19 +1000 Subject: [PATCH] Add an include_packages flag to Selections.download_missing This is needed by "0compile autocompile", which does select and download in two steps. Normally downloading native packages wouldn't work, because the exact versions needed won't be available. Bug: - If the package is already installed, tries (and fails) to install it again. --- zeroinstall/injector/selections.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/zeroinstall/injector/selections.py b/zeroinstall/injector/selections.py index 9f13c6d..cd47d6d 100644 --- a/zeroinstall/injector/selections.py +++ b/zeroinstall/injector/selections.py @@ -265,11 +265,12 @@ class Selections(object): def __repr__(self): return "Selections for " + self.interface - def download_missing(self, config, _old = None): + def download_missing(self, config, _old = None, include_packages = False): """Check all selected implementations are available. Download any that are not present. - Note: package implementations (distribution packages) are ignored. + Note: package implementations (distribution packages) are ignored unless include_packages is True. @param config: used to get iface_cache, stores and fetcher + @param include_packages: also install native distribution packages @return: a L{tasks.Blocker} or None""" from zeroinstall.zerostore import NotStored @@ -280,13 +281,17 @@ class Selections(object): stores = config.stores # Check that every required selection is cached - needed_downloads = [] - for sel in self.selections.values(): - if (not sel.local_path) and (not sel.id.startswith('package:')): + def needs_download(sel): + if sel.id.startswith('package:'): + return include_packages + elif not sel.local_path: try: stores.lookup_any(sel.digests) except NotStored: - needed_downloads.append(sel) + return True + return False + + needed_downloads = list(filter(needs_download, self.selections.values())) if not needed_downloads: return -- 2.11.4.GIT