Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SLE15 SP5 LTSS base container #2091

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/bci_build/os_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
)
Expand All @@ -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:
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/bci_build/package/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
84 changes: 63 additions & 21 deletions src/bci_build/package/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@

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
from bci_build.package import OsContainer
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]..."
Expand Down Expand Up @@ -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
#--------------------------------------
Expand Down Expand Up @@ -92,48 +93,81 @@ 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,
"support_level": SupportLevel.L3,
# 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(),
},
Expand All @@ -159,14 +193,15 @@ 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 []
)
+ (
["openSUSE-build-key"]
if os_version.is_tumbleweed
else ["suse-build-key"]
)
+ (["procps"] if os_version in (OsVersion.SP5,) else [])
)
]
+ [
Expand Down Expand Up @@ -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,)
]
)
14 changes: 11 additions & 3 deletions src/bci_build/package/base/README.md.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -47,13 +51,15 @@ $ 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
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
Expand All @@ -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' %}
Loading