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

Add a SL Micro 6.0 GA kernel module development container #2017

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
63 changes: 59 additions & 4 deletions src/bci_build/package/basecontainers.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@
]


def _get_asset_script(baseurl: str, binaries: list[str]) -> str:
return "".join(
f"#!RemoteAssetUrl: {baseurl}{binary}\nCOPY {os.path.basename(binary)} .\n"
for binary in binaries
).strip()


def _get_fips_base_custom_end(os_version: OsVersion) -> str:
bins: list[str] = []
custom_set_fips_mode: str = (
Expand All @@ -130,10 +137,7 @@ def _get_fips_base_custom_end(os_version: OsVersion) -> str:
)

return (
"".join(
f"#!RemoteAssetUrl: {_FIPS_ASSET_BASEURL}{binary}\nCOPY {os.path.basename(binary)} .\n"
for binary in bins
).strip()
_get_asset_script(_FIPS_ASSET_BASEURL, bins)
+ (custom_install_bins if bins else "")
+ (custom_set_fips_mode if os_version not in (OsVersion.SP3,) else "")
)
Expand Down Expand Up @@ -330,6 +334,57 @@ def _get_minimal_kwargs(os_version: OsVersion):
)


# SL Micro 6.0 GA kernel container devel
_SLM60_BASEURL = "https://api.opensuse.org/public/build/SUSE:ALP:Source:Standard:Core:1.0:Build/standard/"
_SLM60_KERNEL_PACKAGES = [
"x86_64/patchinfo.ga/kernel-devel-6.4.0-17.1.noarch.rpm",
"x86_64/patchinfo.ga/kernel-macros-6.4.0-17.1.noarch.rpm",
"x86_64/patchinfo.ga/kernel-syms-6.4.0-17.1.x86_64.rpm",
"x86_64/patchinfo.ga/kernel-default-devel-6.4.0-17.1.x86_64.rpm",
"aarch64/patchinfo.ga/kernel-syms-6.4.0-17.1.aarch64.rpm",
"aarch64/patchinfo.ga/kernel-default-devel-6.4.0-17.1.aarch64.rpm",
"aarch64/patchinfo.ga/kernel-64kb-devel-6.4.0-17.1.aarch64.rpm",
"s390x/patchinfo.ga/kernel-syms-6.4.0-17.1.s390x.rpm",
"s390x/patchinfo.ga/kernel-default-devel-6.4.0-17.1.s390x.rpm",
]
_SLFO_KEY_ID = "09d9ea69"
KERNEL_MODULE_CONTAINERS.append(
OsContainer(
name="slm60-kernel-module-devel",
pretty_name="SUSE Linux Micro 6.0 Kernel module development",
logo_url="https://opensource.suse.com/bci/SLE_BCI_logomark_green.svg",
os_version=OsVersion.SLE16_0,
supported_until=_SUPPORTED_UNTIL_SLE.get(os_version),
is_latest=OsVersion.SLE16_0 in CAN_BE_LATEST_OS_VERSION,
package_list=(
[
"gcc-build",
"kmod",
"make",
"patch",
"gawk",
"pesign-obs-integration",
"dwarves",
"libelf-devel",
*OsVersion.SLE16_0.release_package_names,
]
),
exclusive_arch=[Arch.X86_64, Arch.S390X, Arch.AARCH64],
extra_files={"_constraints": generate_disk_size_constraints(8)},
custom_end=_get_asset_script(_SLM60_BASEURL, _SLM60_KERNEL_PACKAGES)
+ textwrap.dedent(
f"""
{DOCKERFILE_RUN} \\
[ $(LC_ALL=C rpm --checksig -v *rpm | \\
grep -c -E "^ *V3.*key ID {_SLFO_KEY_ID}:") = {len(_SLM60_KERNEL_PACKAGES)} ] \\
&& rpm -Uvh --oldpackage --force *.$(uname -m).rpm *.noarch.rpm \\
&& rm -vf *.rpm \\
&& rpmqpack | grep -E '^kernel-' | xargs zypper -n addlock\n"""
),
)
)


OSC_CHECKOUT = (Path(__file__).parent / "gitea-runner" / "osc_checkout").read_bytes()

GITEA_RUNNER_CONTAINER = OsContainer(
Expand Down
55 changes: 55 additions & 0 deletions src/bci_build/package/slm60-kernel-module-devel/README.md.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# SUSE Linux Micro 6.0 GA Kernel Module Development Container
{% include 'badges.j2' %}

## Description

Th Kernel Module Development Container Image includes all necessary tools to build kernel
modules for SUSE Linux Micro 6.0. It is intended to be used for building out-of-tree kernel
modules in restricted environments.


## Usage

The image can be used to launch a container and build a kernel
module. The following example below shows how to do this for the DRBD kernel module:
```ShellSession
$ podman run --rm -it --name drbd-build {{ image.pretty_reference }}
# zypper -n in coccinelle tar
# curl -Lsf -o - https://pkg.linbit.com/downloads/drbd/9/drbd-9.2.11.tar.gz | tar xzf -
# cd drbd-9.2.11/
# make -C drbd all KDIR=/usr/src/linux-obj/$(uname -m)/default
```

The built kernel module is then available in
`/drbd-9.2.11/drbd/build-current/drbd.ko`. It can be copied to the host system
as follows:
```ShellSession
$ podman cp drbd-build:/drbd-9.2.11/drbd/build-current/drbd.ko .
$ sudo modprobe drbd.ko
```

Alternatively, the kernel module can be built as part of a container build using
a `Dockerfile`:

```Dockerfile
FROM {{ image.pretty_reference }}
ENV DRBD_VERSION=9.2.11
WORKDIR /src/
RUN zypper -n in coccinelle tar

RUN set -euxo pipefail; \
curl -Lsf -o - https://pkg.linbit.com/downloads/drbd/9/drbd-${DRBD_VERSION}.tar.gz | tar xzf - ; \
cd drbd-${DRBD_VERSION}; \
make -C drbd all KDIR=/usr/src/linux-obj/$(uname -m)/default
```

Build the container image, launch the container, and copy the kernel module to
the local machine:
```ShellSession
$ buildah bud --layers -t drbd-ko .
$ podman run --name drbd drbd-ko
$ podman cp drbd:/src/drbd-9.2.11/drbd/build-current/drbd.ko .
$ podman rm drbd
```

{% include 'licensing_and_eula.j2' %}
Loading