From 038b89f17715f447a7dcb5f8c1b945adadf32fa8 Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Fri, 18 Oct 2024 22:06:07 +0200 Subject: [PATCH] Split into steps --- Containerfile | 28 +++++++++++++++---- scripts/build.sh | 6 ---- scripts/install_nvidia.sh | 52 +++++++++++++++++++++++++++++++++++ scripts/install_rpm_fusion.sh | 8 ++++++ scripts/nvidia/install.sh | 6 ++-- 5 files changed, 86 insertions(+), 14 deletions(-) delete mode 100755 scripts/build.sh create mode 100755 scripts/install_nvidia.sh create mode 100755 scripts/install_rpm_fusion.sh diff --git a/Containerfile b/Containerfile index 392f0cc..f02d49b 100644 --- a/Containerfile +++ b/Containerfile @@ -1,12 +1,28 @@ +# 1. BUILD ARG ARG FEDORA_MAJOR_VERSION=40 -FROM quay.io/fedora-ostree-desktops/kinoite:${FEDORA_MAJOR_VERSION} - -COPY scripts /tmp/scripts +# 2. IMAGES USED TO GET 3RD PARTY CONTENT # https://github.com/ublue-os/akmods#kmod-packages -COPY --from=ghcr.io/ublue-os/akmods-nvidia-open:main-40 /rpms/ /tmp/rpms +FROM ghcr.io/ublue-os/akmods-nvidia-open:main-${FEDORA_MAJOR_VERSION} AS akmods-nvidia -RUN mkdir -p /var/lib/alternatives && \ - /tmp/scripts/build.sh && \ +FROM scratch AS base-scripts + +COPY scripts /scripts + +# 3. BUILD COMMON BASE IMAGE +FROM quay.io/fedora-ostree-desktops/kinoite:${FEDORA_MAJOR_VERSION} AS base + +RUN --mount=type=bind,from=base-scripts,src=/scripts,dst=/tmp/scripts \ + mkdir -p /var/lib/alternatives && \ + /tmp/scripts/install_rpm_fusion.sh && \ + ostree container commit + +# 4. BUILD NVIDIA VARIANT IMAGE +FROM base AS nvidia + +RUN --mount=type=bind,from=akmods-nvidia,src=/rpms,dst=/tmp/akmods-rpms \ + --mount=type=bind,from=base-scripts,src=/scripts,dst=/tmp/scripts \ + mkdir -p /var/lib/alternatives && \ + /tmp/scripts/install_nvidia.sh && \ ostree container commit diff --git a/scripts/build.sh b/scripts/build.sh deleted file mode 100755 index d0e9607..0000000 --- a/scripts/build.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -set -ouex pipefail - -export RELEASE="$(rpm -E %fedora)" - -/tmp/scripts/nvidia/install.sh \ No newline at end of file diff --git a/scripts/install_nvidia.sh b/scripts/install_nvidia.sh new file mode 100755 index 0000000..2cfabcf --- /dev/null +++ b/scripts/install_nvidia.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +set -ouex pipefail + +RELEASE="$(rpm -E %fedora)" + +# disable any remaining rpmfusion repos +sed -i 's@enabled=1@enabled=0@g' /etc/yum.repos.d/rpmfusion*.repo + +sed -i 's@enabled=1@enabled=0@g' /etc/yum.repos.d/fedora-cisco-openh264.repo + +## nvidia install steps +rpm-ostree install /tmp/akmods-rpms/ublue-os/ublue-os-nvidia-addons-*.rpm + +# enables nvidia repos provided by ublue-os-nvidia-addons +sed -i '0,/enabled=0/{s/enabled=0/enabled=1/}' /etc/yum.repos.d/nvidia-container-toolkit.repo + +source /tmp/akmods-rpms/kmods/nvidia-vars + +rpm-ostree install \ + libnvidia-fbc \ + libnvidia-ml.i686 \ + libva-nvidia-driver \ + mesa-vulkan-drivers.i686 \ + nvidia-driver \ + nvidia-driver-cuda \ + nvidia-driver-cuda-libs.i686 \ + nvidia-driver-libs.i686 \ + nvidia-modprobe \ + nvidia-persistenced \ + nvidia-settings \ + nvidia-container-toolkit \ + /tmp/akmods-rpms/kmods/kmod-nvidia-${KERNEL_VERSION}-${NVIDIA_AKMOD_VERSION}.fc${RELEASE}.rpm + + +## nvidia post-install steps +# disables nvidia repos provided by ublue-os-nvidia-addons +sed -i 's@enabled=1@enabled=0@g' /etc/yum.repos.d/{eyecantcu-supergfxctl,negativo17-fedora-nvidia,nvidia-container-toolkit}.repo + +# ensure kernel.conf matches NVIDIA_FLAVOR (which must be nvidia or nvidia-open) +# kmod-nvidia-common defaults to 'nvidia-open' but this will match our akmod image +sed -i "s/^MODULE_VARIANT=.*/MODULE_VARIANT=$KERNEL_MODULE_TYPE/" /etc/nvidia/kernel.conf + +systemctl enable nvidia-persistenced.service + +systemctl enable ublue-nvctk-cdi.service +semodule --verbose --install /usr/share/selinux/packages/nvidia-container.pp + +# Universal Blue specific Initramfs fixes +echo "options nvidia NVreg_TemporaryFilePath=/var/tmp" >> /usr/lib/modprobe.d/nvidia-atomic.conf +cp /etc/modprobe.d/nvidia-modeset.conf /usr/lib/modprobe.d/nvidia-modeset.conf +sed -i 's@omit_drivers@force_drivers@g' /usr/lib/dracut/dracut.conf.d/99-nvidia.conf \ No newline at end of file diff --git a/scripts/install_rpm_fusion.sh b/scripts/install_rpm_fusion.sh new file mode 100755 index 0000000..b4dcade --- /dev/null +++ b/scripts/install_rpm_fusion.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -ouex pipefail + +RELEASE="$(rpm -E %fedora)" + +rpm-ostree install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$RELEASE.noarch.rpm \ + https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$RELEASE.noarch.rpm \ No newline at end of file diff --git a/scripts/nvidia/install.sh b/scripts/nvidia/install.sh index 631e68b..23e23e8 100755 --- a/scripts/nvidia/install.sh +++ b/scripts/nvidia/install.sh @@ -10,6 +10,8 @@ rpm-ostree install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-rele rpm-ostree install /tmp/rpms/ublue-os/ublue-os-nvidia*.rpm rpm-ostree install /tmp/rpms/kmods/kmod-nvidia*.rpm rpm-ostree install xorg-x11-drv-nvidia-cuda libva-nvidia-driver \ - nvidia-vaapi-driver libva-utils vdpauinfo + nvidia-vaapi-driver libva-utils vdpauinfo nvidia-modprobe \ + nvidia-container-toolkit -cp /tmp/scripts/nvidia/modprobe.d/*.conf /usr/lib/modprobe.d/ \ No newline at end of file +cp /tmp/scripts/nvidia/modprobe.d/*.conf /usr/lib/modprobe.d/ +cp /tmp/scripts/nvidia/modprobe.d/nvidia-modeset.conf /etc/modprobe.d/ \ No newline at end of file