<s> """<STR_LIT>""" <EOL> from fabric . api import * <EOL> from fabric . contrib . files import * <EOL> from cloudbio . package . shared import _yaml_to_packages <EOL> from cloudbio . flavor . config import get_config_file <EOL> def _apt_packages ( to_install = None , pkg_list = None ) : <EOL> """<STR_LIT>""" <EOL> if "<STR_LIT>" not in env . flavor . short_name : <EOL> env . logger . info ( "<STR_LIT>" ) <EOL> with settings ( warn_only = True ) : <EOL> env . safe_sudo ( "<STR_LIT>" ) <EOL> if to_install is not None : <EOL> config_file = get_config_file ( env , "<STR_LIT>" ) <EOL> if "<STR_LIT>" not in env . flavor . name and "<STR_LIT>" not in env . flavor . short_name : <EOL> env . flavor . apt_upgrade_system ( env = env ) <EOL> ( packages , _ ) = _yaml_to_packages ( config_file . base , to_install , config_file . dist ) <EOL> packages = env . flavor . rewrite_config_items ( "<STR_LIT>" , packages ) <EOL> elif pkg_list is not None : <EOL> env . logger . info ( "<STR_LIT>" . format ( pkg_list ) ) <EOL> packages = pkg_list <EOL> else : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> group_size = <NUM_LIT:30> <EOL> i = <NUM_LIT:0> <EOL> env . logger . info ( "<STR_LIT>" % len ( packages ) ) <EOL> while i < len ( packages ) : <EOL> env . logger . info ( "<STR_LIT>" . format ( i , len ( packages ) ) ) <EOL> env . safe_sudo ( "<STR_LIT>" % "<STR_LIT:U+0020>" . join ( packages [ i : i + group_size ] ) ) <EOL> i += group_size <EOL> env . safe_sudo ( "<STR_LIT>" ) <EOL> def _add_apt_gpg_keys ( ) : <EOL> """<STR_LIT>""" <EOL> env . logger . info ( "<STR_LIT>" ) <EOL> standalone = [ <EOL> "<STR_LIT>" , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> keyserver = [ <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ] <EOL> standalone , keyserver = env . flavor . rewrite_apt_keys ( standalone , keyserver ) <EOL> for key in standalone : <EOL> with settings ( warn_only = True ) : <EOL> env . safe_sudo ( "<STR_LIT>" % key ) <EOL> for url , key in keyserver : <EOL> with settings ( warn_only = True ) : <EOL> env . safe_sudo ( "<STR_LIT>" % ( url , key ) ) <EOL> with settings ( warn_only = True ) : <EOL> env . safe_sudo ( "<STR_LIT>" ) <EOL> env . safe_sudo ( "<STR_LIT>" ) <EOL> def _setup_apt_automation ( ) : <EOL> """<STR_LIT>""" <EOL> interactive_cmd = "<STR_LIT>" <EOL> if not env . safe_contains ( env . shell_config , interactive_cmd ) : <EOL> env . safe_append ( env . shell_config , interactive_cmd ) <EOL> env . safe_comment ( env . shell_config , "<STR_LIT>" ) <EOL> package_info = [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> ] <EOL> package_info = env . flavor . rewrite_apt_automation ( package_info ) <EOL> cmd = "<STR_LIT>" <EOL> for l in package_info : <EOL> cmd += '<STR_LIT>' % l <EOL> env . safe_sudo ( cmd ) <EOL> def _setup_apt_sources ( ) : <EOL> """<STR_LIT>""" <EOL> if not env . safe_exists ( '<STR_LIT>' ) or not env . safe_exists ( '<STR_LIT>' ) : <EOL> env . safe_sudo ( '<STR_LIT>' ) <EOL> env . safe_sudo ( '<STR_LIT>' ) <EOL> env . logger . debug ( "<STR_LIT>" + env . sources_file ) <EOL> env . flavor . check_packages_source ( ) <EOL> comment = "<STR_LIT>" + env . flavor . name <EOL> preferences = env . flavor . rewrite_apt_preferences ( [ ] ) <EOL> if len ( preferences ) : <EOL> env . safe_sudo ( "<STR_LIT>" % env . apt_preferences_file ) <EOL> env . safe_sudo ( "<STR_LIT>" % env . apt_preferences_file ) <EOL> env . safe_append ( env . apt_preferences_file , comment , use_sudo = True ) <EOL> lines = "<STR_LIT:\n>" . join ( preferences ) <EOL> env . logger . debug ( "<STR_LIT>" % lines ) <EOL> env . safe_sudo ( "<STR_LIT>" % ( lines , env . apt_preferences_file ) ) <EOL> env . logger . debug ( env . safe_sudo ( "<STR_LIT>" ) ) <EOL> if not env . safe_exists ( env . sources_file ) : <EOL> env . safe_sudo ( "<STR_LIT>" % env . sources_file ) <EOL> if not env . safe_contains ( env . sources_file , comment ) : <EOL> env . safe_append ( env . sources_file , comment , use_sudo = True ) <EOL> for source in env . flavor . rewrite_apt_sources_list ( env . std_sources ) : <EOL> env . logger . debug ( "<STR_LIT>" % source ) <EOL> if source . startswith ( "<STR_LIT>" ) : <EOL> env . safe_sudo ( "<STR_LIT>" ) <EOL> env . safe_sudo ( "<STR_LIT>" % source ) <EOL> elif ( not env . safe_contains ( env . sources_file , source ) and <EOL> not env . safe_contains ( env . global_sources_file , source ) ) : <EOL> env . safe_append ( env . sources_file , source , use_sudo = True ) </s>
