diff options
Diffstat (limited to 'cloudinit/CloudConfig/cc_apt_update_upgrade.py')
-rw-r--r-- | cloudinit/CloudConfig/cc_apt_update_upgrade.py | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/cloudinit/CloudConfig/cc_apt_update_upgrade.py b/cloudinit/CloudConfig/cc_apt_update_upgrade.py index e918e8c8..30ef8d44 100644 --- a/cloudinit/CloudConfig/cc_apt_update_upgrade.py +++ b/cloudinit/CloudConfig/cc_apt_update_upgrade.py @@ -20,6 +20,7 @@ import subprocess import traceback import os import glob +import cloudinit.CloudConfig as cc def handle(name,cfg,cloud,log,args): update = util.get_cfg_option_bool(cfg, 'apt_update', False) @@ -54,29 +55,15 @@ def handle(name,cfg,cloud,log,args): log.error("Failed to run debconf-set-selections") log.debug(traceback.format_exc()) - pkglist = [] - if 'packages' in cfg: - if isinstance(cfg['packages'],list): - pkglist = cfg['packages'] - else: pkglist.append(cfg['packages']) - - if update or upgrade or pkglist: - #retcode = subprocess.call(list) - subprocess.Popen(['apt-get', 'update']).communicate() - - e=os.environ.copy() - e['DEBIAN_FRONTEND']='noninteractive' + if update: + cc.update_package_sources() if upgrade: - cmd=[ 'apt-get', '--option', 'Dpkg::Options::=--force-confold', - 'upgrade', '--assume-yes' ] - - subprocess.Popen(cmd, env=e).communicate() + cc.apt_get("upgrade") - if pkglist: - cmd=['apt-get', 'install', '--assume-yes'] - cmd.extend(pkglist) - subprocess.Popen(cmd, env=e).communicate() + pkglist = util.get_cfg_option_list_or_str(cfg,'packages',[]) + if len(pkglist): + cc.install_packages(pkglist) return(True) |