mirror-ublue-os-akmods/Containerfile.in
Benjamin Sherman 9a4db4eb14
fix: Make kmod build failures fatal and retry flaky ZFS downloads (#590)
* fix: Fail the build when a common or nvidia kmod script fails

The RUN blocks that call build-kmod-*.sh for the common and nvidia
targets ran `bash <<'RUNEOF'` without `set -euo pipefail`, unlike every
other block in the Containerfile. When a script exited non-zero, the
remaining scripts still ran and the build went on to RPM caching and
signing with a partial set of modules.

That is how the Terra openrazer change broke aarch64 builds. openrazer
aborted before removing its repo file, and the later kmod scripts kept
running with that repo still enabled, pulling in x86_64 RPMs.

Add `set ${CI+-x} -euo pipefail` to the common kmod block and the three
nvidia blocks so any failure stops the job. The extra block already has
it and intentionally keeps going on per-kmod failures via
`|| echo "SKIPPED: ..."`, so it is unchanged.

* fix: Retry the ZFS release downloads and fail on bad responses

`build-kmod-zfs.sh` fetched the OpenZFS release list from the
unauthenticated GitHub API with a bare `curl`, no retry and no `--fail`.
When GitHub throttled the runner it wrote the rate-limit page to
`data.json`, `jq` then died with "Invalid numeric literal", and the
build stopped with no hint of the real cause. The release tarball and
signature downloads had the same exposure to a transient github.com
error.

Route all four through a shared `curl --fail --show-error --location
--retry 5 --retry-delay 5 --retry-all-errors`, so a throttle or 5xx is
retried and a persistent bad response aborts the script at the curl
call.

* don't attempt vhba for aarch64
2026-09-03 03:59:16 +00:00

225 lines
6.2 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'
set ${CI+-x} -euo pipefail
/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-nct6687d.sh || echo "SKIPPED: nct6687d"
/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'
set ${CI+-x} -euo pipefail
/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'
set ${CI+-x} -euo pipefail
/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'
set ${CI+-x} -euo pipefail
/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 / /