From b38c2d35b35f1e2c979ff548ef292cc036cfbc54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dirk=20M=C3=BCller?= Date: Fri, 29 Nov 2024 13:20:13 +0100 Subject: [PATCH] SLE15 SP5 LTSS base container --- src/bci_build/os_version.py | 7 ++- src/bci_build/package/__init__.py | 2 + src/bci_build/package/base.py | 84 ++++++++++++++++++------- src/bci_build/package/base/README.md.j2 | 14 ++++- 4 files changed, 82 insertions(+), 25 deletions(-) diff --git a/src/bci_build/os_version.py b/src/bci_build/os_version.py index 907983b5e..091f120d7 100644 --- a/src/bci_build/os_version.py +++ b/src/bci_build/os_version.py @@ -14,6 +14,8 @@ class OsVersion(enum.Enum): SP6 = 6 #: SLE 15 Service Pack 5 SP5 = 5 + #: SLE 15 Service Pack 5 with LTSS enforced + SP5_LTSS = "sle15.5" #: SLE 15 Service Pack 4 SP4 = 4 #: SLE 15 Service Pack 3 @@ -98,6 +100,7 @@ def is_sle15(self) -> bool: OsVersion.SP3.value, OsVersion.SP4.value, OsVersion.SP5.value, + OsVersion.SP5_LTSS.value, OsVersion.SP6.value, OsVersion.SP7.value, ) @@ -112,7 +115,7 @@ def is_tumbleweed(self) -> bool: @property def is_ltss(self) -> bool: - return self in ALL_OS_LTSS_VERSIONS + return self in (OsVersion.SP5_LTSS,) or self in ALL_OS_LTSS_VERSIONS @property def os_version(self) -> str: @@ -133,6 +136,8 @@ def has_container_suseconnect(self) -> bool: @property def eula_package_names(self) -> tuple[str, ...]: + if self.is_ltss: + return ("skelcd-EULA-SLES",) if self.is_sle15: return ("skelcd-EULA-bci",) # TODO: switch to skelcd-EULA-bci when SLES 16 is released diff --git a/src/bci_build/package/__init__.py b/src/bci_build/package/__init__.py index c4d552972..af538ae06 100644 --- a/src/bci_build/package/__init__.py +++ b/src/bci_build/package/__init__.py @@ -1032,6 +1032,8 @@ def labelprefix(self) -> str: def kiwi_version(self) -> str: if self.os_version in (OsVersion.TUMBLEWEED, OsVersion.SLE16_0): return str(datetime.datetime.now().year) + if self.os_version in (OsVersion.SP5_LTSS,): + return "15.5" return f"15.{int(self.os_version.value)}.0" @property diff --git a/src/bci_build/package/base.py b/src/bci_build/package/base.py index 09268c4ed..92a2f20f4 100644 --- a/src/bci_build/package/base.py +++ b/src/bci_build/package/base.py @@ -7,6 +7,7 @@ from bci_build.container_attributes import Arch from bci_build.container_attributes import BuildType +from bci_build.container_attributes import ImageType from bci_build.container_attributes import PackageType from bci_build.container_attributes import SupportLevel from bci_build.os_version import OsVersion @@ -14,7 +15,7 @@ from bci_build.package import Package -def _get_base_config_sh_script(os_version: OsVersion) -> str: +def _get_base_config_sh_script(os_version: OsVersion, is_ltss: bool) -> str: return Template( r""" echo "Configure image: [$kiwi_iname]..." @@ -51,7 +52,7 @@ def _get_base_config_sh_script(os_version: OsVersion) -> str: #-------------------------------------- sed -i 's/.*rpm.install.excludedocs.*/rpm.install.excludedocs = yes/g' /etc/zypp/zypp.conf -{% if os_version.is_sle15 and not os_version.is_ltss -%} +{% if os_version.is_sle15 and not is_ltss -%} #====================================== # Configure SLE BCI repositories #-------------------------------------- @@ -92,39 +93,74 @@ def _get_base_config_sh_script(os_version: OsVersion) -> str: #-------------------------------------- (shopt -s globstar; rm -f /usr/share/locale/**/*.mo) """ - ).render(os_version=os_version) + ).render(os_version=os_version, is_ltss=is_ltss) @dataclass class Sles15Image(OsContainer): + is_ltss: bool = False + @property def build_tags(self) -> list[str]: tags: list[str] = [] - if self.os_version.is_sle15: + if self.is_ltss: + tags.extend( + ( + f"suse/ltss/sle%OS_VERSION_ID_SP%/sle15:{self.image_ref_name}", + "suse/ltss/sle%OS_VERSION_ID_SP%/sle15:%OS_VERSION_ID_SP%", + "suse/ltss/sle%OS_VERSION_ID_SP%/sle15:latest", + ) + ) + elif self.os_version.is_sle15: tags.extend( - ("suse/sle15:%OS_VERSION_ID_SP%", f"suse/sle15:{self.image_ref_name}") + (f"suse/sle15:{self.image_ref_name}", "suse/sle15:%OS_VERSION_ID_SP%") ) tags += super().build_tags return tags + @property + def eula(self) -> str: + if self.is_ltss: + return "sle-eula" + return super().eula + + @property + def image_type(self) -> ImageType: + if self.is_ltss: + return ImageType.LTSS + return super().image_type() + @property def uid(self) -> str: - return "sles15" + return "sles15-ltss" if self.is_ltss else "sles15" + + @property + def registry_prefix(self) -> str: + if self.is_ltss: + return "suse/ltss/sle%OS_VERSION_ID_SP%" + return super().registry_prefix() + +def _get_base_kwargs(os_version: OsVersion, is_ltss: bool = False) -> dict: + kwargs = {} -def _get_base_kwargs(os_version: OsVersion) -> dict: + pretty_name: str = "%OS_VERSION_NO_DASH% Base" package_name: str = "base-image" - if os_version.is_ltss: + logo_url: str = "https://opensource.suse.com/bci/SLE_BCI_logomark_green.svg" + if is_ltss: + pretty_name = "%OS_PRETTY_NAME% LTSS Base Container Image" package_name = "sles15-ltss-image" + logo_url = None + kwargs["is_ltss"] = True elif os_version.is_sle15: package_name = "sles15-image" - return { + return kwargs | { "name": "base", - "pretty_name": "%OS_VERSION_NO_DASH% Base", + "pretty_name": pretty_name, "package_name": package_name, "custom_description": "Image for containers based on %OS_PRETTY_NAME%.", - "logo_url": "https://opensource.suse.com/bci/SLE_BCI_logomark_green.svg", + "logo_url": logo_url, "build_recipe_type": BuildType.KIWI, "from_image": None, "os_version": os_version, @@ -132,8 +168,6 @@ def _get_base_kwargs(os_version: OsVersion) -> dict: # we need to exclude i586 and other ports arches from building base images "exclusive_arch": [Arch.AARCH64, Arch.X86_64, Arch.PPC64LE, Arch.S390X], "kiwi_ignore_packages": ["rpm"] if os_version.is_sle15 else [], - # latest tag is injected in a special way for base images in prjconf - # "is_latest": os_version in CAN_BE_LATEST_OS_VERSION, "extra_files": { "LICENSE": (Path(__file__).parent / "base" / "LICENSE").read_text(), }, @@ -159,7 +193,7 @@ def _get_base_kwargs(os_version: OsVersion) -> dict: "sle-module-server-applications-release", "sle-module-python3-release", ] - if os_version.is_sle15 + if os_version.is_sle15 and os_version not in (OsVersion.SP5,) else [] ) + ( @@ -167,6 +201,7 @@ def _get_base_kwargs(os_version: OsVersion) -> dict: if os_version.is_tumbleweed else ["suse-build-key"] ) + + (["procps"] if os_version in (OsVersion.SP5,) else []) ) ] + [ @@ -198,15 +233,22 @@ def _get_base_kwargs(os_version: OsVersion) -> dict: + [*os_version.release_package_names] ) ], - "config_sh_script": _get_base_config_sh_script(os_version), + "config_sh_script": _get_base_config_sh_script(os_version, is_ltss), "_min_release_counter": 40, } # TODO merge in tumbleweed changes and switch to ALL_BASE_OS_VERSIONS -BASE_CONTAINERS = [ - Sles15Image(**_get_base_kwargs(os_ver)) for os_ver in (OsVersion.SP6, OsVersion.SP7) -] + [ - OsContainer(**_get_base_kwargs(os_version=os_ver)) - for os_ver in (OsVersion.SLE16_0,) -] +BASE_CONTAINERS = ( + [ + Sles15Image(**_get_base_kwargs(OsVersion.SP5_LTSS, is_ltss=True)), + ] + + [ + Sles15Image(**_get_base_kwargs(os_ver)) + for os_ver in (OsVersion.SP6, OsVersion.SP7) + ] + + [ + OsContainer(**_get_base_kwargs(os_version=os_ver)) + for os_ver in (OsVersion.SLE16_0,) + ] +) diff --git a/src/bci_build/package/base/README.md.j2 b/src/bci_build/package/base/README.md.j2 index c4e9d7778..8ff84cb81 100644 --- a/src/bci_build/package/base/README.md.j2 +++ b/src/bci_build/package/base/README.md.j2 @@ -15,8 +15,12 @@ testing environment. ## Usage -The container image comes with the `zypper` package manager, the free `SLE_BCI` -repository and the `container-suseconnect` utility. This allows you to access +The container image comes with the `zypper` package manager +{%- if image.os_version.is_ltss %} +, the free `SLE_BCI` repository +{%- endif %} + +and the `container-suseconnect` utility. This allows you to access the full SLE repositories with a valid SLE subscription. The image is designed to be extended by installing packages required for your specific scenario. @@ -47,6 +51,7 @@ $ podman run -ti --rm {{ image.pretty_reference }} {% set ref_list = image.pretty_reference.split(":") %}{{ ref_list[0] }} ``` +{%- if image.os_version.is_ltss %} ### The SLE_BCI repository The container image comes with the free `SLE_BCI` repository. The repository @@ -54,6 +59,7 @@ contains a subset of all packages from SUSE Linux Enterprise. The packages are available free of charge, and they can be redistributed freely. However, they are provided without support. The repository also contains the latest version of packages only. +{%- endif %} ### Getting access to the SLE repositories @@ -67,5 +73,7 @@ Find more information about container-suseconnect in the section in the container guide or in the tutorial ["How to use container-suseconnect"](https://opensource.suse.com/bci-docs/guides/container-suseconnect/). - +{%- if image.os_version.is_ltss %} +{% include 'access_protected_images.j2' %} +{%- endif %} {% include 'licensing_and_eula.j2' %}