don't install packages if you don't want to (--keep_packages)
This commit is contained in:
parent
29e0e6be32
commit
f98c330f8f
@ -69,6 +69,10 @@ def parse():
|
|||||||
dest="r_component",
|
dest="r_component",
|
||||||
metavar="COMPONENT",
|
metavar="COMPONENT",
|
||||||
help="component which will not have ACTION applied but will be referenced as if it was (ACTION dependent)")
|
help="component which will not have ACTION applied but will be referenced as if it was (ACTION dependent)")
|
||||||
|
base_group.add_option("-k", "--keep-packages",
|
||||||
|
action="store_true",
|
||||||
|
dest="keep_packages",
|
||||||
|
help="uninstall will keep any installed packages on the system")
|
||||||
parser.add_option_group(base_group)
|
parser.add_option_group(base_group)
|
||||||
|
|
||||||
stop_un_group = OptionGroup(parser, "Uninstall/stop options")
|
stop_un_group = OptionGroup(parser, "Uninstall/stop options")
|
||||||
@ -107,5 +111,6 @@ def parse():
|
|||||||
output['ignore_deps'] = False
|
output['ignore_deps'] = False
|
||||||
else:
|
else:
|
||||||
output['ignore_deps'] = True
|
output['ignore_deps'] = True
|
||||||
|
output['keep_packages'] = options.keep_packages
|
||||||
output['extras'] = args
|
output['extras'] = args
|
||||||
return output
|
return output
|
||||||
|
@ -22,14 +22,17 @@ LOG = logging.getLogger("devstack.packager")
|
|||||||
|
|
||||||
|
|
||||||
class Packager(object):
|
class Packager(object):
|
||||||
def __init__(self, distro):
|
def __init__(self, distro, keep_packages):
|
||||||
self.distro = distro
|
self.distro = distro
|
||||||
|
self.keep_packages = keep_packages
|
||||||
|
|
||||||
def install_batch(self, pkgs):
|
def install_batch(self, pkgs):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def remove_batch(self, pkgs):
|
def remove_batch(self, pkgs):
|
||||||
raise NotImplementedError()
|
if not self.keep_packages:
|
||||||
|
return self._remove_batch(pkgs)
|
||||||
|
return []
|
||||||
|
|
||||||
def pre_install(self, pkgs, installparams=None):
|
def pre_install(self, pkgs, installparams=None):
|
||||||
pkgnames = sorted(pkgs.keys())
|
pkgnames = sorted(pkgs.keys())
|
||||||
@ -48,3 +51,6 @@ class Packager(object):
|
|||||||
if postinstallcmds and len(postinstallcmds):
|
if postinstallcmds and len(postinstallcmds):
|
||||||
LOG.info("Running post-install commands for package %s." % (name))
|
LOG.info("Running post-install commands for package %s." % (name))
|
||||||
utils.execute_template(*postinstallcmds, params=installparams)
|
utils.execute_template(*postinstallcmds, params=installparams)
|
||||||
|
|
||||||
|
def _remove_batch(self, pkgs):
|
||||||
|
raise NotImplementedError()
|
||||||
|
@ -42,8 +42,8 @@ VERSION_TEMPL = "%s=%s"
|
|||||||
|
|
||||||
|
|
||||||
class AptPackager(pack.Packager):
|
class AptPackager(pack.Packager):
|
||||||
def __init__(self, distro):
|
def __init__(self, distro, keep_packages):
|
||||||
pack.Packager.__init__(self, distro)
|
pack.Packager.__init__(self, distro, keep_packages)
|
||||||
self.auto_remove = True
|
self.auto_remove = True
|
||||||
|
|
||||||
def _format_pkg(self, name, version):
|
def _format_pkg(self, name, version):
|
||||||
@ -59,7 +59,7 @@ class AptPackager(pack.Packager):
|
|||||||
env_overrides=ENV_ADDITIONS,
|
env_overrides=ENV_ADDITIONS,
|
||||||
**kargs)
|
**kargs)
|
||||||
|
|
||||||
def remove_batch(self, pkgs):
|
def _remove_batch(self, pkgs):
|
||||||
pkgnames = sorted(pkgs.keys())
|
pkgnames = sorted(pkgs.keys())
|
||||||
#form the needed commands
|
#form the needed commands
|
||||||
cmds = []
|
cmds = []
|
||||||
|
@ -32,8 +32,8 @@ VERSION_TEMPL = "%s-%s"
|
|||||||
|
|
||||||
|
|
||||||
class YumPackager(pack.Packager):
|
class YumPackager(pack.Packager):
|
||||||
def __init__(self, distro):
|
def __init__(self, distro, keep_packages):
|
||||||
pack.Packager.__init__(self, distro)
|
pack.Packager.__init__(self, distro, keep_packages)
|
||||||
|
|
||||||
def _format_pkg_name(self, name, version):
|
def _format_pkg_name(self, name, version):
|
||||||
if version is not None and len(version):
|
if version is not None and len(version):
|
||||||
|
@ -135,9 +135,9 @@ def _clean_action(action):
|
|||||||
return action
|
return action
|
||||||
|
|
||||||
|
|
||||||
def _get_pkg_manager(distro):
|
def _get_pkg_manager(distro, keep_packages):
|
||||||
cls = _PKGR_MAP.get(distro)
|
cls = _PKGR_MAP.get(distro)
|
||||||
return cls(distro)
|
return cls(distro, keep_packages)
|
||||||
|
|
||||||
|
|
||||||
def _get_action_cls(action_name, component_name):
|
def _get_action_cls(action_name, component_name):
|
||||||
@ -286,7 +286,7 @@ def _run_components(action_name, component_order, components, distro, root_dir,
|
|||||||
non_components = set(components.keys()).difference(set(component_order))
|
non_components = set(components.keys()).difference(set(component_order))
|
||||||
if non_components:
|
if non_components:
|
||||||
LOG.info("Using reference components [%s]" % (", ".join(sorted(non_components))))
|
LOG.info("Using reference components [%s]" % (", ".join(sorted(non_components))))
|
||||||
pkg_manager = _get_pkg_manager(distro)
|
pkg_manager = _get_pkg_manager(distro, program_args.pop('keep_packages', True))
|
||||||
config = _get_config()
|
config = _get_config()
|
||||||
#form the active instances (this includes ones we won't use)
|
#form the active instances (this includes ones we won't use)
|
||||||
all_instances = dict()
|
all_instances = dict()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user