package-installs: add list to arch and "not-arch" list
Icf8a075224833fcfbbe2128e8802ff41c39f3c09 looked rather ugly, and it's easy for us to expand the processing done in the arch list. Change "arch" to a comma-separated list of architectures that should match for install. Add a "not-arch" list which will exclude the package from installation on those architectures. (An aside -- I considered making it just he one list with foo,!bar,moo but ! has special meaning in YAML, so it's easier to have two lists). $ ARCH=ppc64 package-installs-squash --elements ironic-agent --path=./elements/ /dev/stdout | grep dmidecode $ ARCH=ppc64 package-installs-squash --elements ironic-agent --path=./elements/ /dev/stdout | grep lshw "lshw", $ ARCH=amd64 package-installs-squash --elements ironic-agent --path=./elements/ /dev/stdout | grep lshw $ ARCH=amd64 package-installs-squash --elements ironic-agent --path=./elements/ /dev/stdout | grep dmidecode "dmidecode", Change-Id: Ic69dd02a09e6f3ba9078a2377d8df29871a20db2
This commit is contained in:
parent
76bf793a39
commit
8a1c8370a1
@ -1,12 +1,10 @@
|
|||||||
tgt:
|
tgt:
|
||||||
curl:
|
curl:
|
||||||
# dmidecode does not exist for ppc* arches so add includes for non ppc
|
# dmidecode does not exist for ppc* arches so we use lshw
|
||||||
dmidecode:
|
dmidecode:
|
||||||
arch: x86_64
|
not-arch: ppc64,ppc64el
|
||||||
dmidecode:
|
lshw:
|
||||||
arch: i386
|
arch: ppc64, ppc64el
|
||||||
dmidecode:
|
|
||||||
arch: amd64
|
|
||||||
ipmitool:
|
ipmitool:
|
||||||
qemu-utils:
|
qemu-utils:
|
||||||
gcc:
|
gcc:
|
||||||
@ -17,6 +15,5 @@ util-linux:
|
|||||||
genisoimage:
|
genisoimage:
|
||||||
gdisk:
|
gdisk:
|
||||||
kmod:
|
kmod:
|
||||||
lshw:
|
|
||||||
psmisc:
|
psmisc:
|
||||||
dosfstools:
|
dosfstools:
|
||||||
|
@ -9,19 +9,27 @@ package-installs.yaml or package-installs.json file in the element directory.
|
|||||||
In order to work on Gentoo hosts you will need to manually install
|
In order to work on Gentoo hosts you will need to manually install
|
||||||
`dev-python/pyyaml`.
|
`dev-python/pyyaml`.
|
||||||
|
|
||||||
example package-installs.yaml::
|
example ``package-installs.yaml``
|
||||||
|
|
||||||
libxml2:
|
.. code-block:: YAML
|
||||||
grub2:
|
|
||||||
phase: pre-install.d
|
|
||||||
networkmanager:
|
|
||||||
uninstall: True
|
|
||||||
os-collect-config:
|
|
||||||
installtype: source
|
|
||||||
linux-image-amd64:
|
|
||||||
arch: amd64
|
|
||||||
|
|
||||||
example package-installs.json::
|
libxml2:
|
||||||
|
grub2:
|
||||||
|
phase: pre-install.d
|
||||||
|
networkmanager:
|
||||||
|
uninstall: True
|
||||||
|
os-collect-config:
|
||||||
|
installtype: source
|
||||||
|
linux-image-amd64:
|
||||||
|
arch: amd64
|
||||||
|
dmidecode:
|
||||||
|
not-arch: ppc64, ppc64le
|
||||||
|
lshw:
|
||||||
|
arch: ppc64, ppc64le
|
||||||
|
|
||||||
|
example package-installs.json
|
||||||
|
|
||||||
|
.. code-block:: json
|
||||||
|
|
||||||
{
|
{
|
||||||
"libxml2": null,
|
"libxml2": null,
|
||||||
@ -43,9 +51,11 @@ Setting the installtype property causes the package only to be installed if
|
|||||||
the specified installtype would be used for the element. See the
|
the specified installtype would be used for the element. See the
|
||||||
diskimage-builder docs for more information on installtypes.
|
diskimage-builder docs for more information on installtypes.
|
||||||
|
|
||||||
Setting the arch property causes the package only to be installed for the
|
The ``arch`` property is a comma-separated list of architectures to
|
||||||
specified target architecture. See documentation about the ARCH variable
|
install for. The ``not-arch`` is a comma-separated list of
|
||||||
for more information.
|
architectures the package should be excluded from. Either ``arch`` or
|
||||||
|
``not-arch`` can be given for one package - not both. See
|
||||||
|
documentation about the ARCH variable for more information.
|
||||||
|
|
||||||
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
|
||||||
post-install.d directories called package-installs-<element-name> will cause
|
post-install.d directories called package-installs-<element-name> will cause
|
||||||
|
@ -19,7 +19,7 @@ import collections
|
|||||||
import functools
|
import functools
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
|
||||||
@ -30,6 +30,31 @@ def get_element_installtype(element_name):
|
|||||||
default)
|
default)
|
||||||
|
|
||||||
|
|
||||||
|
def _is_arch_in_list(strlist):
|
||||||
|
"""Checks if os.environ['ARCH'] is in comma separated strlist"""
|
||||||
|
strlist = strlist.split(',')
|
||||||
|
map(str.strip, strlist)
|
||||||
|
return os.environ['ARCH'] in strlist
|
||||||
|
|
||||||
|
|
||||||
|
def _valid_for_arch(pkg_name, arch, not_arch):
|
||||||
|
"""Filter out incorrect ARCH versions"""
|
||||||
|
if arch is None and not_arch is None:
|
||||||
|
# nothing specified; always OK
|
||||||
|
return True
|
||||||
|
if arch and not_arch:
|
||||||
|
print("package-installs configuration error: arch and not_arch "
|
||||||
|
"given for package [%s]" % pkg_name)
|
||||||
|
sys.exit(1)
|
||||||
|
# if we have an arch list, our current arch must be in it
|
||||||
|
# to install.
|
||||||
|
if arch:
|
||||||
|
return _is_arch_in_list(arch)
|
||||||
|
# if we don't have an explicit arch list, we should
|
||||||
|
# install unless we are in the not-arch list.
|
||||||
|
return not _is_arch_in_list(not_arch)
|
||||||
|
|
||||||
|
|
||||||
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))
|
||||||
@ -48,13 +73,12 @@ def collect_data(data, filename, element_name):
|
|||||||
elem_installtype = get_element_installtype(element_name)
|
elem_installtype = get_element_installtype(element_name)
|
||||||
valid_installtype = (installtype is None or
|
valid_installtype = (installtype is None or
|
||||||
installtype == elem_installtype)
|
installtype == elem_installtype)
|
||||||
|
valid_arch = _valid_for_arch(pkg_name, params.get('arch', None),
|
||||||
# Filter out incorrect ARCH versions
|
params.get('not-arch', None))
|
||||||
arch = params.get('arch', None)
|
|
||||||
valid_arch = arch is None or arch == os.environ['ARCH']
|
|
||||||
|
|
||||||
if valid_installtype and valid_arch:
|
if valid_installtype and valid_arch:
|
||||||
data[phase][install].append((pkg_name, element_name))
|
data[phase][install].append((pkg_name, element_name))
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- The ``package-installs`` element now supports a list of
|
||||||
|
architectures to install the package for in the ``arch`` field and
|
||||||
|
negative matching with a ``not-arch`` field. This allows greater
|
||||||
|
flexibility when installing packages for only some architectures.
|
Loading…
Reference in New Issue
Block a user