Merge "Add installtype support to package-installs"

This commit is contained in:
Jenkins 2015-02-03 03:45:44 +00:00 committed by Gerrit Code Review
commit 6665274553
2 changed files with 21 additions and 3 deletions

View File

@ -10,6 +10,8 @@ example package-installs.yaml::
phase: pre-install.d phase: pre-install.d
networkmanager: networkmanager:
uninstall: True uninstall: True
os-collect-config:
installtype: source
example package-installs.json:: example package-installs.json::
@ -17,14 +19,20 @@ example package-installs.json::
"libxml2": null, "libxml2": null,
"grub2": {"phase": "pre-install.d"}, "grub2": {"phase": "pre-install.d"},
"networkmanager": {"uninstall": true} "networkmanager": {"uninstall": true}
"os-collect-config": {"installtype": "source"}
} }
Setting phase or uninstall properties for a package overrides the following Setting phase, uninstall, or installtype properties for a package overrides
default values:: the following default values::
phase: install.d phase: install.d
uninstall: False uninstall: False
installtype: * (Install package for all installtypes)
Setting the installtype property causes the package only to be installed if
the specified installtype would be used for the element. See the
diskimage-builder docs for more information on installtypes.
DEPRECATED: Adding a file under your elements pre-install.d, install.d, or DEPRECATED: Adding a file under your elements pre-install.d, install.d, or

View File

@ -23,6 +23,12 @@ import os
import yaml import yaml
def get_element_installtype(element_name):
default = os.environ.get("DIB_DEFAULT_INSTALLTYPE", "source")
element_name.replace('-', '_')
return os.environ.get("DIB_INSTALLTYPE_%s" % element_name, default)
def collect_data(data, filename, element_name): def collect_data(data, filename, element_name):
try: try:
objs = json.load(open(filename)) objs = json.load(open(filename))
@ -36,6 +42,10 @@ def collect_data(data, filename, element_name):
if 'uninstall' in params: if 'uninstall' in params:
install = "uninstall" install = "uninstall"
# Filter out incorrect installtypes
installtype = params.get('installtype', None)
elem_installtype = get_element_installtype(element_name)
if installtype is None or installtype == elem_installtype:
data[phase][install].append((pkg_name, element_name)) data[phase][install].append((pkg_name, element_name))
return data return data