From 28c42fafdc7833fee5de5c23cdb8e9db5a3812c2 Mon Sep 17 00:00:00 2001 From: Gregory Haynes Date: Thu, 23 Apr 2015 00:48:51 +0000 Subject: [PATCH] Support arch-specific package-installs In some cases, like linux-image-* on debian, we need to only install packages for a specific target architecture. Change-Id: Ic0009d0c1e121d6f3f1f21345c544e2d98f080f9 --- elements/package-installs/README.rst | 6 ++++++ elements/package-installs/bin/package-installs-squash | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/elements/package-installs/README.rst b/elements/package-installs/README.rst index e3b6ad01..eb011e89 100644 --- a/elements/package-installs/README.rst +++ b/elements/package-installs/README.rst @@ -16,6 +16,8 @@ example package-installs.yaml:: uninstall: True os-collect-config: installtype: source + linux-image-amd64: + arch: amd64 example package-installs.json:: @@ -33,11 +35,15 @@ the following default values:: phase: install.d uninstall: False installtype: * (Install package for all installtypes) + arch: * (Install package for all architectures) 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. +Setting the arch property causes the package only to be installed for the +specified target architecture. See documentation about the ARCH variable +for more information. DEPRECATED: Adding a file under your elements pre-install.d, install.d, or post-install.d directories called package-installs- will cause diff --git a/elements/package-installs/bin/package-installs-squash b/elements/package-installs/bin/package-installs-squash index 04611588..ff0cd62a 100755 --- a/elements/package-installs/bin/package-installs-squash +++ b/elements/package-installs/bin/package-installs-squash @@ -46,7 +46,14 @@ def collect_data(data, filename, element_name): # Filter out incorrect installtypes installtype = params.get('installtype', None) elem_installtype = get_element_installtype(element_name) - if installtype is None or installtype == elem_installtype: + valid_installtype = (installtype is None or + installtype == elem_installtype) + + # Filter out incorrect ARCH versions + arch = params.get('arch', None) + valid_arch = arch is None or arch == os.environ['ARCH'] + + if valid_installtype and valid_arch: data[phase][install].append((pkg_name, element_name)) return data