@@ -301,7 +301,7 @@ def get_package_file(package_name, package_url, hash_algorithm='md5', expected_h
301301 return cache_file
302302
303303
304- def do_install (packages , config_file , installed , platform , install_dir , dry_run , local_archives = []):
304+ def do_install (packages , config_file , installed , platform , install_dir , dry_run , local_archives = [], cache_only = False ):
305305 """
306306 Install the specified list of packages. By default this will download the
307307 packages to the local cache, extract the contents of those
@@ -322,10 +322,12 @@ def do_install(packages, config_file, installed, platform, install_dir, dry_run,
322322
323323 # Existing tarball install, or new package install of either kind
324324 if pname in local_archives :
325- if _install_local (pname , platform , package , local_archives [pname ], install_dir , installed , dry_run ):
326- installed_pkgs .append (pname )
325+ if not cache_only :
326+ # local packages don't need to be placed in the cache
327+ if _install_local (pname , platform , package , local_archives [pname ], install_dir , installed , dry_run ):
328+ installed_pkgs .append (pname )
327329 else :
328- if _install_binary (pname , platform , package , config_file , install_dir , installed , dry_run ):
330+ if _install_binary (pname , platform , package , config_file , install_dir , installed , dry_run , cache_only = cache_only ):
329331 installed_pkgs .append (pname )
330332 return installed_pkgs
331333
@@ -354,7 +356,7 @@ def _install_local(configured_name, platform, package, package_path, install_dir
354356 else :
355357 return False
356358
357- def _install_binary (configured_name , platform , package , config_file , install_dir , installed , dry_run ):
359+ def _install_binary (configured_name , platform , package , config_file , install_dir , installed , dry_run , cache_only = False ):
358360 # Check that we have a platform-specific or common url to use.
359361 req_plat = package .get_platform (platform )
360362 package_name = getattr (package , 'name' , '(undefined)' )
@@ -387,6 +389,9 @@ def _install_binary(configured_name, platform, package, config_file, install_dir
387389 if cachefile is None :
388390 raise InstallError ("Failed to download package '%s' from '%s'" % (package_name , archive .url ))
389391
392+ if cache_only :
393+ return True
394+
390395 metadata , files = _install_common (configured_name , platform , package , cachefile , install_dir , installed , dry_run )
391396 if metadata :
392397 installed_package = package .copy ()
@@ -761,9 +766,9 @@ def install_packages(args, config_file, install_dir, platform, packages):
761766
762767 # do the actual install of any new/updated packages
763768 packages = do_install (packages , config_file , installed , platform , install_dir ,
764- args .dry_run , local_archives = local_archives )
769+ args .dry_run , local_archives = local_archives , cache_only = args . cache_only )
765770
766- if not args .dry_run :
771+ if not args .dry_run and not args . cache_only :
767772 # update the installed-packages.xml file
768773 try :
769774 # in case we got this far without ever having created installed_file's
@@ -886,6 +891,11 @@ def register(self, parser):
886891 help = "install packages for a specific build configuration\n (may be specified as comma separated values in $AUTOBUILD_CONFIGURATION)" ,
887892 metavar = 'CONFIGURATION' ,
888893 default = self .configurations_from_environment ())
894+ parser .add_argument ('--cache-only' ,
895+ action = 'store_true' ,
896+ default = False ,
897+ dest = 'cache_only' ,
898+ help = "fetch remote pacakges and populate the cache but do not install.\n intended for use preparing environment for offline operation" )
889899
890900 def run (self , args ):
891901 platform = common .get_current_platform ()
0 commit comments