From 1491d8471de4561bcb21c58551237de99695cbf6 Mon Sep 17 00:00:00 2001 From: Egbert Eich Date: Wed, 3 May 2023 13:05:14 +0200 Subject: Add 'zypper' to the valid container.os_packages options (#36681) Signed-off-by: Egbert Eich Co-authored-by: Massimiliano Culpo Co-authored-by: e4t --- lib/spack/docs/containers.rst | 2 +- lib/spack/spack/schema/container.py | 5 ++++- lib/spack/spack/test/container/docker.py | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/spack/docs/containers.rst b/lib/spack/docs/containers.rst index 2c097d366c..aa861e28c9 100644 --- a/lib/spack/docs/containers.rst +++ b/lib/spack/docs/containers.rst @@ -616,7 +616,7 @@ to customize the generation of container recipes: - No * - ``os_packages:command`` - Tool used to manage system packages - - ``apt``, ``yum`` + - ``apt``, ``yum``, ``zypper``, ``apk``, ``yum_amazon`` - Only with custom base images * - ``os_packages:update`` - Whether or not to update the list of available packages diff --git a/lib/spack/spack/schema/container.py b/lib/spack/spack/schema/container.py index 37912d4c55..030b238290 100644 --- a/lib/spack/spack/schema/container.py +++ b/lib/spack/spack/schema/container.py @@ -54,7 +54,10 @@ container_schema = { "os_packages": { "type": "object", "properties": { - "command": {"type": "string", "enum": ["apt", "yum"]}, + "command": { + "type": "string", + "enum": ["apt", "yum", "zypper", "apk", "yum_amazon"], + }, "update": {"type": "boolean"}, "build": _list_of_packages, "final": _list_of_packages, diff --git a/lib/spack/spack/test/container/docker.py b/lib/spack/spack/test/container/docker.py index 4f65dfd983..d6edca99a6 100644 --- a/lib/spack/spack/test/container/docker.py +++ b/lib/spack/spack/test/container/docker.py @@ -43,6 +43,28 @@ def test_packages(minimal_configuration): assert p.list == pkgs +def test_container_os_packages_command(minimal_configuration): + # In this minimal configuration we don't have packages + writer = writers.create(minimal_configuration) + assert writer.os_packages_build is None + assert writer.os_packages_final is None + + # If we add them a list should be returned + minimal_configuration["spack"]["container"]["images"] = { + "build": "custom-build:latest", + "final": "custom-final:latest", + } + minimal_configuration["spack"]["container"]["os_packages"] = { + "command": "zypper", + "final": ["libgomp1"], + } + writer = writers.create(minimal_configuration) + p = writer.os_packages_final + assert "zypper update -y" in p.update + assert "zypper install -y" in p.install + assert "zypper clean -a" in p.clean + + def test_ensure_render_works(minimal_configuration, default_config): # Here we just want to ensure that nothing is raised writer = writers.create(minimal_configuration) -- cgit v1.2.3-70-g09d2