|
| 1 | +FROM registry.ci.openshift.org/ocp/4.22:rhel-coreos-10 |
| 2 | +ARG KERNEL_VERSION='' |
| 3 | +ARG RT_KERNEL_VERSION='' |
| 4 | +ARG RHEL_VERSION='' |
| 5 | +# If RHEL_VERSION is empty, we infer it from the /etc/os-release file. This is used by OKD as we always want the latest one. |
| 6 | +RUN [ "${RHEL_VERSION}" == "" ] && source /etc/os-release && RHEL_VERSION=${VERSION_ID}; echo ${RHEL_VERSION} > /etc/dnf/vars/releasever \ |
| 7 | + && dnf config-manager --best --setopt=install_weak_deps=False --save |
| 8 | + |
| 9 | +# kernel packages needed to build drivers / kmods |
| 10 | +RUN dnf -y install \ |
| 11 | + kernel-devel${KERNEL_VERSION:+-}${KERNEL_VERSION} \ |
| 12 | + kernel-devel-matched${KERNEL_VERSION:+-}${KERNEL_VERSION} \ |
| 13 | + kernel-headers${KERNEL_VERSION:+-}${KERNEL_VERSION} \ |
| 14 | + kernel-modules${KERNEL_VERSION:+-}${KERNEL_VERSION} \ |
| 15 | + kernel-modules-extra${KERNEL_VERSION:+-}${KERNEL_VERSION} |
| 16 | + |
| 17 | +# real-time kernel packages |
| 18 | +# Also, assert that the kernel and kernel-rt rpms come from the same build. Relevant for 9.3+. |
| 19 | +RUN if [ $(arch) = x86_64 ]; then \ |
| 20 | + dnf -y install \ |
| 21 | + kernel-rt-devel${RT_KERNEL_VERSION:+-}${RT_KERNEL_VERSION} \ |
| 22 | + kernel-rt-modules${RT_KERNEL_VERSION:+-}${RT_KERNEL_VERSION} \ |
| 23 | + kernel-rt-modules-extra${RT_KERNEL_VERSION:+-}${RT_KERNEL_VERSION}; \ |
| 24 | + diff --side-by-side <(rpm -qi kernel-core | grep 'Source RPM') <(rpm -qi kernel-rt-core | grep 'Source RPM'); \ |
| 25 | + fi |
| 26 | + |
| 27 | +# 64k-pages kernel packages for aarch64 |
| 28 | +# Headers are not compiled, so there is no kernel-64k-headers packages, |
| 29 | +# and compilation will use the headers from kernel-headers |
| 30 | +RUN if [ $(arch) = aarch64 ]; then \ |
| 31 | + dnf -y install \ |
| 32 | + kernel-64k-devel${KERNEL_VERSION:+-}${KERNEL_VERSION} \ |
| 33 | + kernel-64k-modules${KERNEL_VERSION:+-}${KERNEL_VERSION} \ |
| 34 | + kernel-64k-modules-extra${KERNEL_VERSION:+-}${KERNEL_VERSION}; \ |
| 35 | + fi |
| 36 | + |
| 37 | +RUN dnf -y install kernel-rpm-macros |
| 38 | + |
| 39 | +# Additional packages that are mandatory for driver-containers |
| 40 | +RUN dnf -y install elfutils-libelf-devel kmod binutils kabi-dw glibc |
| 41 | + |
| 42 | +# Find and install the GCC version used to compile the kernel |
| 43 | +# If it cannot be found (fails on some architectures), install the default gcc |
| 44 | +RUN export INSTALLED_KERNEL=$(rpm -q --qf "%{VERSION}-%{RELEASE}.%{ARCH}" kernel-devel) && \ |
| 45 | + GCC_VERSION=$(cat /lib/modules/${INSTALLED_KERNEL}/config | grep -Eo "gcc \(GCC\) ([0-9\.]+)" | grep -Eo "([0-9\.]+)") && \ |
| 46 | + dnf -y install gcc-${GCC_VERSION} gcc-c++-${GCC_VERSION} || dnf -y install gcc gcc-c++ |
| 47 | + |
| 48 | +# Additional packages that are needed for a subset (e.g DPDK) of driver-containers |
| 49 | +RUN dnf -y install xz diffutils flex bison |
| 50 | + |
| 51 | +# Packages needed to build driver-containers |
| 52 | +RUN dnf -y install git make rpm-build |
| 53 | + |
| 54 | +# Packages needed to sign and run externally build kernel modules |
| 55 | +RUN if [ $(arch) == "x86_64" ] || [ $(arch) == "aarch64" ]; then \ |
| 56 | + ARCH_DEP_PKGS="mokutil"; fi \ |
| 57 | + && dnf -y install openssl keyutils $ARCH_DEP_PKGS |
| 58 | + |
| 59 | +RUN dnf clean all |
| 60 | + |
| 61 | +COPY manifests/01-openshift-imagestream.yaml /manifests/01-openshift-imagestream.yaml |
| 62 | +COPY manifests/image-references-rhel10 /manifests/image-references |
| 63 | + |
| 64 | +LABEL io.k8s.description="driver-toolkit is a container with the kernel packages necessary for building driver containers for deploying kernel modules/drivers on OpenShift" \ |
| 65 | + name="driver-toolkit" \ |
| 66 | + io.openshift.release.operator=true \ |
| 67 | + version="0.1" \ |
| 68 | + io.openshift.os.streamclass=rhel-10 \ |
| 69 | + kernel-version=${KERNEL_VERSION} \ |
| 70 | + kernel-rt-version=${RT_KERNEL_VERSION} |
| 71 | + |
| 72 | +# Last layer for metadata for mapping the driver-toolkit to a specific kernel version |
| 73 | +RUN export INSTALLED_KERNEL=$(rpm -q --qf "%{VERSION}-%{RELEASE}.%{ARCH}" kernel-devel); \ |
| 74 | + export INSTALLED_RT_KERNEL=$(rpm -q --qf "%{VERSION}-%{RELEASE}.%{ARCH}+rt" kernel-rt-core); \ |
| 75 | + echo "{ \"KERNEL_VERSION\": \"${INSTALLED_KERNEL}\", \"RT_KERNEL_VERSION\": \"${INSTALLED_RT_KERNEL}\", \"RHEL_VERSION\": \"$(</etc/dnf/vars/releasever)\" }" > /etc/driver-toolkit-release.json |
| 76 | + |
0 commit comments