mirror-ublue-os-akmods/Containerfile.in
Benjamin Sherman ac05d00925
fix(nvidia): order CDI generation before nvidia-persistenced to fix boot race (#565)
* fix(nvidia): order CDI generation before nvidia-persistenced to fix boot race

nvidia-persistenced and nvidia-powerd only start if /dev/nvidia* already
exists, but those device nodes aren't created until CDI generation runs.
Without any ordering between the two, persistenced would sometimes lose
that race and stay stopped for the rest of the boot (ublue-os/ucore#419).

nvidia-container-toolkit-base now ships its own nvidia-cdi-refresh
service, which is better than our old ublue-nvctk-cdi.service: it forces
device creation explicitly, retries on failure, and re-runs on driver
upgrades. Switch to it and add a drop-in ordering it before
nvidia-persistenced and nvidia-powerd, so the race can't happen.

Verified on real NVIDIA hardware across multiple reboots.

* chore: Add missing service to nvidia-install.sh

---------

Co-authored-by: Kyle Gospodnetich <me@kylegospodneti.ch>
2026-08-08 17:26:12 -07:00

220 lines
6 KiB
Text

FROM BUILDER AS build_prep
ARG DUAL_SIGN="true"
ARG KERNEL_FLAVOR_ARG
ARG KERNEL_NAME_ARG
ARG RPMFUSION_MIRROR_ARG
ARG VERSION_ARG
#ifdef CI_SETX
ARG CI=1
#endif /* CI_SETX */
#ifdef NVIDIA
ARG KMOD_REPO_ARG
#endif /* NVIDIA */
# /*
# common copy/add
# */
COPY certs /tmp/certs
COPY files/usr/lib/systemd/system-preset/70-nvidia-cdi-refresh.preset /tmp/ublue-os-nvidia-addons/rpmbuild/SOURCES/70-nvidia-cdi-refresh.preset
COPY files/usr/lib/systemd/system/nvidia-cdi-refresh.service.d/10-ublue-ordering.conf /tmp/ublue-os-nvidia-addons/rpmbuild/SOURCES/10-ublue-ordering.conf
COPY files/etc/udev/rules.d/60-nvidia-extra-devices-pm.rules /tmp/ublue-os-nvidia-addons/rpmbuild/SOURCES/60-nvidia-extra-devices-pm.rules
#ifndef CENTOS
ADD https://copr.fedorainfracloud.org/coprs/ublue-os/akmods/repo/fedora-${VERSION}/ublue-os-akmods-fedora-${VERSION}.repo \
/tmp/ublue-os-akmods-addons/rpmbuild/SOURCES/_copr_ublue-os-akmods.repo
ADD https://negativo17.org/repos/fedora-multimedia.repo \
/tmp/ublue-os-akmods-addons/rpmbuild/SOURCES/negativo17-fedora-multimedia.repo
ADD https://raw.githubusercontent.com/terrapkg/packages/f${VERSION}/anda/terra/release/terra.repo \
/tmp/ublue-os-akmods-addons/rpmbuild/SOURCES/terra.repo
ADD https://copr.fedorainfracloud.org/coprs/rok/cdemu/repo/fedora-${VERSION}/rok-cdemu-fedora-${VERSION}.repo \
/tmp/ublue-os-akmods-addons/rpmbuild/SOURCES/_copr_rok-cdemu.repo
ADD https://raw.githubusercontent.com/terrapkg/packages/f${VERSION}/anda/terra/gpg-keys/RPM-GPG-KEY-terra${VERSION} \
/tmp/ublue-os-akmods-addons/rpmbuild/SOURCES/RPM-GPG-KEY-terra${VERSION}
#endif
# /*
# Preperation
# */
COPY build_files/prep /tmp/
RUN --mount=type=cache,dst=/var/cache/dnf \
--mount=type=cache,dst=/var/cache/libdnf5 \
bash <<'RUNEOF'
set ${CI+-x} -euo pipefail
ls -sh /tmp/kernel_cache
/tmp/build-prep.sh
RUNEOF
FROM build_prep AS builder
ARG DUAL_SIGN="true"
ARG KERNEL_FLAVOR_ARG
ARG KERNEL_NAME_ARG
ARG RPMFUSION_MIRROR_ARG
ARG VERSION_ARG
#ifdef CI_SETX
ARG CI=1
#endif /* CI_SETX */
#ifdef NVIDIA
ARG KMOD_REPO_ARG
#endif /* NVIDIA */
#ifdef ZFS
ARG ZFS_MINOR_VERSION_ARG
ARG ZFS_CONFIGURE_ARGS_ARG
#endif /* ZFS */
#if defined COMMON
# /*
# common akmods
# */
COPY build_files/common /tmp/
RUN --mount=type=cache,dst=/var/cache/dnf \
--mount=type=cache,dst=/var/cache/libdnf5 \
bash <<'RUNEOF'
set ${CI+-x} -euo pipefail
/tmp/build-ublue-os-akmods-addons.sh
cp /tmp/ublue-os-akmods-addons/rpmbuild/RPMS/noarch/ublue-os-akmods-addons*.rpm /var/cache/rpms/ublue-os/
RUNEOF
RUN --mount=type=cache,dst=/var/cache/dnf \
--mount=type=cache,dst=/var/cache/libdnf5 \
bash <<'RUNEOF'
/tmp/build-kmod-framework-laptop.sh
/tmp/build-kmod-openrazer.sh
/tmp/build-kmod-v4l2loopback.sh
/tmp/build-kmod-vhba.sh
/tmp/build-kmod-wl.sh
/tmp/build-kmod-xpadneo.sh
/tmp/build-kmod-xone.sh
RUNEOF
#elif defined EXTRA
# /*
# extra akmods
# */
COPY build_files/extra /tmp/
RUN --mount=type=cache,dst=/var/cache/dnf \
--mount=type=cache,dst=/var/cache/libdnf5 \
bash <<'RUNEOF'
set ${CI+-x} -euo pipefail
/tmp/build-kmod-gcadapter_oc.sh || echo "SKIPPED: gcadapter_oc"
/tmp/build-kmod-zenergy.sh || echo "SKIPPED: zenergy"
/tmp/build-kmod-ryzen-smu.sh || echo "SKIPPED: ryzen-smu"
/tmp/build-kmod-evdi.sh || echo "SKIPPED: evdi"
/tmp/build-kmod-system76.sh || echo "SKIPPED: system76"
/tmp/build-kmod-system76-io.sh || echo "SKIPPED: system76-io"
/tmp/build-kmod-hid-tmff2.sh || echo "SKIPPED: hid-tmff2"
/tmp/build-kmod-new-lg4ff.sh || echo "SKIPPED: new-lg4ff"
/tmp/build-kmod-t150-driver.sh || echo "SKIPPED: t150-driver"
/tmp/build-kmod-hid-fanatecff.sh || echo "SKIPPED: hid-fanatecff"
/tmp/build-kmod-sc0710.sh || echo "SKIPPED: sc0710"
/tmp/build-kmod-kvmfr.sh || echo "SKIPPED: kvmfr"
RUNEOF
#elif defined NVIDIA
# /*
# nvidia kmods
# */
COPY build_files/nvidia /tmp/
RUN --mount=type=cache,dst=/var/cache/dnf \
--mount=type=cache,dst=/var/cache/libdnf5 \
bash <<'RUNEOF'
/tmp/build-ublue-os-nvidia-addons.sh
cp /tmp/ublue-os-nvidia-addons/rpmbuild/RPMS/noarch/ublue-os-nvidia-addons*.rpm /var/cache/rpms/ublue-os/
RUNEOF
RUN --mount=type=cache,dst=/var/cache/dnf \
--mount=type=cache,dst=/var/cache/libdnf5 \
bash <<'RUNEOF'
/tmp/build-kmod-nvidia.sh "$KMOD_REPO"
RUNEOF
RUN --mount=type=cache,dst=/var/cache/dnf \
--mount=type=cache,dst=/var/cache/libdnf5 \
bash <<'RUNEOF'
/tmp/download-nvidia-rpms.sh "$KMOD_REPO"
install -m755 -t /var/cache/rpms/ublue-os /tmp/nvidia-install.sh
RUNEOF
#elif defined ZFS
# /*
# zfs akmods
# */
COPY build_files/zfs /tmp/
RUN --mount=type=cache,dst=/var/cache/dnf \
--mount=type=cache,dst=/var/cache/libdnf5 \
bash <<'RUNEOF'
set ${CI+-x} -euo pipefail
if [[ "${KERNEL_FLAVOR}" =~ (coreos|longterm) ]]; then
/tmp/build-ublue-os-ucore-addons.sh
cp /tmp/ublue-os-ucore-addons/rpmbuild/RPMS/noarch/ublue-os-ucore-addons*.rpm /var/cache/rpms/ucore/
fi
RUNEOF
RUN --mount=type=cache,dst=/var/cache/dnf \
--mount=type=cache,dst=/var/cache/libdnf5 \
bash <<'RUNEOF'
set ${CI+-x} -euo pipefail
/tmp/build-kmod-zfs.sh
RUNEOF
#endif
# /*
# Signing
# */
COPY build_files/post /tmp/
RUN --mount=type=cache,dst=/var/cache/dnf \
--mount=type=cache,dst=/var/cache/libdnf5 \
bash <<'RUNEOF'
set ${CI+-x} -euo pipefail
#ifdef ZFS
/tmp/dual-sign-zfs.sh
#else
/tmp/dual-sign.sh
#endif /* ZFS */
/tmp/build-post.sh
RUNEOF
FROM scratch AS RPM_CACHE
COPY --from=builder /var/cache/kernel-rpms /kernel-rpms
COPY --from=builder /var/cache/rpms /rpms
FROM build_prep AS test
ARG DUAL_SIGN="true"
ARG KERNEL_FLAVOR_ARG
ARG KERNEL_NAME_ARG
ARG RPMFUSION_MIRROR_ARG
ARG VERSION_ARG
#ifdef NVIDIA
ARG KMOD_REPO_ARG
#endif /* NVIDIA */
#ifdef CI_SETX
ENV CI=1
#endif
COPY --from=RPM_CACHE /kernel-rpms /tmp/kernel_cache
COPY --from=RPM_CACHE /rpms /tmp/akmods-rpms
COPY build_files/test/test-prep.sh /tmp/
COPY certs /tmp/certs
RUN --mount=type=cache,dst=/var/cache/dnf \
--mount=type=cache,dst=/var/cache/libdnf5 \
bash <<'RUNEOF'
set ${CI+-x} -euo pipefail
/tmp/test-prep.sh
RUNEOF
COPY build_files/test/check-signatures.sh /tmp/
CMD ["/tmp/check-signatures.sh"]
FROM scratch AS RPMS
COPY --from=RPM_CACHE / /