-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a SL Micro 6.0 GA kernel module development container
- Loading branch information
1 parent
a0f8a8b
commit 55bde29
Showing
2 changed files
with
107 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
from bci_build.package import Package | ||
from bci_build.package import _build_tag_prefix | ||
from bci_build.package import generate_disk_size_constraints | ||
from bci_build.package.helpers import generate_from_image_tag | ||
|
||
_DISABLE_GETTY_AT_TTY1_SERVICE = "systemctl disable [email protected]" | ||
|
||
|
@@ -105,6 +106,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 = ( | ||
|
@@ -131,10 +139,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 "") | ||
) | ||
|
@@ -315,6 +320,7 @@ def _get_minimal_kwargs(os_version: OsVersion): | |
"kernel-devel", | ||
"kernel-syms", | ||
"gcc", | ||
"git-core", | ||
"kmod", | ||
"make", | ||
"patch", | ||
|
@@ -324,12 +330,54 @@ def _get_minimal_kwargs(os_version: OsVersion): | |
] | ||
# tar is not in bci-base in 15.4, but we need it to unpack tarballs | ||
+ (["tar"] if os_version == OsVersion.SP4 else []) | ||
+ (["suse-module-tools-scriptlets"] if os_version.is_slfo else []) | ||
), | ||
extra_files={"_constraints": generate_disk_size_constraints(8)}, | ||
) | ||
) | ||
|
||
|
||
# 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", | ||
] | ||
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, | ||
from_target_image=generate_from_image_tag( | ||
OsVersion.SLE16_0, "bci-sle16-kernel-module-devel" | ||
), | ||
package_list=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 09d9ea69:") = {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( | ||
|
55 changes: 55 additions & 0 deletions
55
src/bci_build/package/slm60-kernel-module-devel/README.md.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' %} |