feat(ci): use CPP preprocessor for akmods (#1799)

This commit is contained in:
renner 2026-02-27 18:51:50 +01:00 committed by GitHub
parent fea1f5fa77
commit 22d21c197c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 253 additions and 180 deletions

View file

@ -1,72 +0,0 @@
ARG BASE_IMAGE_ORG="${BASE_IMAGE_ORG}:-quay.io/fedora-ostree-desktops"
ARG BASE_IMAGE_NAME="${BASE_IMAGE_NAME}:-kinoite"
ARG BASE_IMAGE="${BASE_IMAGE_ORG}/${BASE_IMAGE_NAME}"
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION}:-43"
ARG COMMON_IMAGE="${COMMON_IMAGE}:-ghcr.io/get-aurora-dev/common:latest"
ARG COMMON_IMAGE_SHA=""
ARG BREW_IMAGE="${BREW_IMAGE}:-ghcr.io/ublue-os/brew:latest"
ARG BREW_IMAGE_SHA=""
FROM ${COMMON_IMAGE}@${COMMON_IMAGE_SHA} AS common
FROM ${BREW_IMAGE}@${BREW_IMAGE_SHA} AS brew
FROM scratch AS ctx
COPY /build_files /build_files
# https://github.com/get-aurora-dev/common
COPY --from=common /logos /system_files/shared
COPY --from=common /system_files /system_files
COPY --from=common /wallpapers /system_files/shared
# https://github.com/ublue-os/brew
COPY --from=brew /system_files /system_files/shared
# Overwrite files from common if necessary
COPY /system_files /system_files
## aurora image section
FROM ${BASE_IMAGE}:${FEDORA_MAJOR_VERSION} AS base
ARG AKMODS_FLAVOR="coreos-stable"
ARG BASE_IMAGE_NAME="${BASE_IMAGE_NAME}"
ARG FEDORA_MAJOR_VERSION=""
ARG IMAGE_NAME="aurora"
ARG IMAGE_VENDOR="ublue-os"
ARG KERNEL=""
ARG SHA_HEAD_SHORT="dedbeef"
ARG UBLUE_IMAGE_TAG="stable"
ARG VERSION=""
ARG IMAGE_FLAVOR=""
# so ghcurl wrapper is available to all later RUNs
ENV PATH="/tmp/scripts/helpers:${PATH}"
# Copy files from common/from system_files
# Install Packages, miscellaneous things that need a network
RUN --mount=type=tmpfs,dst=/boot \
--mount=type=tmpfs,dst=/var \
--mount=type=bind,from=ctx,source=/,target=/ctx \
--mount=type=cache,dst=/var/cache/libdnf5 \
--mount=type=secret,id=GITHUB_TOKEN \
/ctx/build_files/shared/build.sh && \
/ctx/build_files/base/01-packages.sh && \
/ctx/build_files/base/02-install-kernel-akmods.sh && \
/ctx/build_files/base/03-fetch.sh
# Everything that can be done offline after things are in place should be done here
RUN --network=none \
--mount=type=tmpfs,dst=/boot \
--mount=type=tmpfs,dst=/run \
--mount=type=bind,from=ctx,source=/,target=/ctx \
--mount=type=cache,dst=/var/cache/libdnf5 \
/ctx/build_files/base/16-override-install.sh && \
/ctx/build_files/base/17-cleanup.sh && \
/ctx/build_files/base/18-image-info.sh && \
/ctx/build_files/base/19-initramfs.sh && \
/ctx/build_files/shared/validate-repos.sh && \
/ctx/build_files/shared/clean-stage.sh && \
/ctx/build_files/base/20-tests.sh
CMD ["/sbin/init"]
RUN bootc container lint

146
Containerfile.in Normal file
View file

@ -0,0 +1,146 @@
ARG BASE_IMAGE_ORG="${BASE_IMAGE_ORG}:-quay.io/fedora-ostree-desktops"
ARG BASE_IMAGE_NAME="${BASE_IMAGE_NAME}:-kinoite"
ARG BASE_IMAGE="${BASE_IMAGE_ORG}/${BASE_IMAGE_NAME}"
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION}:-43"
ARG AKMODS_FLAVOR="${AKMODS_FLAVOR}-${FEDORA_MAJOR_VERSION}:-coreos-stable-43"
ARG KERNEL="${KERNEL}:-6.17.12-300.fc43.x86_64"
ARG COMMON_IMAGE="${COMMON_IMAGE}:-ghcr.io/get-aurora-dev/common:latest"
ARG COMMON_IMAGE_SHA=""
ARG BREW_IMAGE="${BREW_IMAGE}:-ghcr.io/ublue-os/brew:latest"
ARG BREW_IMAGE_SHA=""
FROM ${COMMON_IMAGE}@${COMMON_IMAGE_SHA} AS common
FROM ${BREW_IMAGE}@${BREW_IMAGE_SHA} AS brew
FROM ghcr.io/ublue-os/akmods:${AKMODS_FLAVOR}-${FEDORA_MAJOR_VERSION}-${KERNEL} AS akmods
#if defined(NVIDIA)
FROM ghcr.io/ublue-os/akmods-nvidia-open:${AKMODS_FLAVOR}-${FEDORA_MAJOR_VERSION}-${KERNEL} AS akmods-nvidia-open
#endif
#if defined(ZFS)
FROM ghcr.io/ublue-os/akmods-zfs:${AKMODS_FLAVOR}-${FEDORA_MAJOR_VERSION}-${KERNEL} AS akmods-zfs
#endif
FROM scratch AS ctx
COPY /build_files /build_files
# /* https://github.com/get-aurora-dev/common */
COPY --from=common /logos /system_files/shared
COPY --from=common /system_files /system_files
COPY --from=common /wallpapers /system_files/shared
# /* https://github.com/ublue-os/brew */
COPY --from=brew /system_files /system_files/shared
# /* Overwrite files from common if necessary */
COPY /system_files /system_files
# /* aurora image section */
FROM ${BASE_IMAGE}:${FEDORA_MAJOR_VERSION} AS base
ARG AKMODS_FLAVOR="main"
ARG BASE_IMAGE_NAME="${BASE_IMAGE_NAME}"
ARG FEDORA_MAJOR_VERSION=""
ARG IMAGE_NAME="aurora"
ARG IMAGE_VENDOR="ublue-os"
ARG KERNEL=""
ARG SHA_HEAD_SHORT="dedbeef"
ARG UBLUE_IMAGE_TAG="latest"
ARG VERSION=""
ARG IMAGE_FLAVOR=""
# /* so ghcurl wrapper is available to all later RUNs */
ENV PATH="/tmp/scripts/helpers:${PATH}"
# /* Copy files from common/from system_files */
# /* Install Packages, miscellaneous things that need a network */
# /* aurora:latest no zfs or nvidia */
#if !defined(NVIDIA) && !defined(ZFS)
RUN --mount=type=tmpfs,dst=/boot \
--mount=type=tmpfs,dst=/var \
--mount=type=bind,from=ctx,source=/,target=/ctx \
--mount=type=cache,dst=/var/cache/libdnf5 \
--mount=type=bind,from=akmods,src=/kernel-rpms,dst=/tmp/kernel-rpms \
--mount=type=bind,from=akmods,src=/rpms/common,dst=/tmp/rpms/common \
--mount=type=bind,from=akmods,src=/rpms/kmods,dst=/tmp/rpms/kmods \
--mount=type=secret,id=GITHUB_TOKEN \
/ctx/build_files/shared/build.sh && \
/ctx/build_files/base/01-packages.sh && \
/ctx/build_files/base/02-install-common-kernel-akmods.sh && \
/ctx/build_files/base/03-fetch.sh
#endif
# /* aurora:stable with zfs no nvidia */
#if !defined(NVIDIA) && defined(ZFS)
RUN --mount=type=tmpfs,dst=/boot \
--mount=type=tmpfs,dst=/var \
--mount=type=bind,from=ctx,source=/,target=/ctx \
--mount=type=cache,dst=/var/cache/libdnf5 \
--mount=type=bind,from=akmods,src=/kernel-rpms,dst=/tmp/kernel-rpms \
--mount=type=bind,from=akmods,src=/rpms/common,dst=/tmp/rpms/common \
--mount=type=bind,from=akmods,src=/rpms/kmods,dst=/tmp/rpms/kmods \
--mount=type=bind,from=akmods-zfs,src=/rpms/kmods/zfs,dst=/tmp/rpms/kmods/zfs \
--mount=type=secret,id=GITHUB_TOKEN \
/ctx/build_files/shared/build.sh && \
/ctx/build_files/base/01-packages.sh && \
/ctx/build_files/base/02-install-common-kernel-akmods.sh && \
/ctx/build_files/base/zfs.sh && \
/ctx/build_files/base/03-fetch.sh
#endif
# /* aurora-nvidia-open:latest no zfs */
#if defined(NVIDIA) && !defined(ZFS)
RUN --mount=type=tmpfs,dst=/boot \
--mount=type=tmpfs,dst=/var \
--mount=type=bind,from=ctx,source=/,target=/ctx \
--mount=type=cache,dst=/var/cache/libdnf5 \
--mount=type=bind,from=akmods,src=/kernel-rpms,dst=/tmp/kernel-rpms \
--mount=type=bind,from=akmods,src=/rpms/common,dst=/tmp/rpms/common \
--mount=type=bind,from=akmods,src=/rpms/kmods,dst=/tmp/rpms/kmods \
--mount=type=bind,from=akmods-nvidia-open,src=/rpms,dst=/tmp/rpms/nvidia \
--mount=type=secret,id=GITHUB_TOKEN \
/ctx/build_files/shared/build.sh && \
/ctx/build_files/base/01-packages.sh && \
/ctx/build_files/base/02-install-common-kernel-akmods.sh && \
/ctx/build_files/base/nvidia.sh && \
/ctx/build_files/base/03-fetch.sh
#endif
# /* aurora-nvidia-open:stable with ZFS */
#if defined(NVIDIA) && defined(ZFS)
RUN --mount=type=tmpfs,dst=/boot \
--mount=type=tmpfs,dst=/var \
--mount=type=bind,from=ctx,source=/,target=/ctx \
--mount=type=cache,dst=/var/cache/libdnf5 \
--mount=type=bind,from=akmods,src=/kernel-rpms,dst=/tmp/kernel-rpms \
--mount=type=bind,from=akmods,src=/rpms/common,dst=/tmp/rpms/common \
--mount=type=bind,from=akmods,src=/rpms/kmods,dst=/tmp/rpms/kmods \
--mount=type=bind,from=akmods-nvidia-open,src=/rpms,dst=/tmp/rpms/nvidia \
--mount=type=bind,from=akmods-zfs,src=/rpms/kmods/zfs,dst=/tmp/rpms/kmods/zfs \
--mount=type=secret,id=GITHUB_TOKEN \
/ctx/build_files/shared/build.sh && \
/ctx/build_files/base/01-packages.sh && \
/ctx/build_files/base/02-install-common-kernel-akmods.sh && \
/ctx/build_files/base/nvidia.sh && \
/ctx/build_files/base/zfs.sh && \
/ctx/build_files/base/03-fetch.sh
#endif
# /* Everything that can be done offline after things are in place should be done here */
RUN --network=none \
--mount=type=tmpfs,dst=/boot \
--mount=type=tmpfs,dst=/run \
--mount=type=bind,from=ctx,source=/,target=/ctx \
/ctx/build_files/base/16-override-install.sh && \
/ctx/build_files/base/17-cleanup.sh && \
/ctx/build_files/base/18-image-info.sh && \
/ctx/build_files/base/19-initramfs.sh && \
/ctx/build_files/shared/validate-repos.sh && \
/ctx/build_files/shared/clean-stage.sh && \
/ctx/build_files/base/20-tests.sh
CMD ["/sbin/init"]
RUN bootc container lint

View file

@ -225,7 +225,16 @@ build $image="aurora" $tag="latest" $flavor="main" rechunk="0" ghcr="0" pipeline
LABELS+=("--label" "io.artifacthub.package.maintainers=[{\"name\": \"NiHaiden\", \"email\": \"me@nhaiden.io\"}]")
echo "::endgroup::"
PODMAN_BUILD_ARGS=("${BUILD_ARGS[@]}" "${LABELS[@]}" --tag localhost/"${image_name}:${tag}" --file Containerfile)
case "${akmods_flavor}" in
"coreos-stable") BUILD_ARGS+=("--cpp-flag=-DZFS") ;;
esac
if [[ "${image_name}" =~ nvidia ]]; then
BUILD_ARGS+=("--cpp-flag=-DNVIDIA")
fi
PODMAN_BUILD_ARGS=("${BUILD_ARGS[@]}" "${LABELS[@]}" --tag localhost/"${image_name}:${tag}" --file Containerfile.in)
# Add GitHub token secret if available (for CI/CD)
if [[ -n "${GITHUB_TOKEN:-}" ]]; then

View file

@ -79,6 +79,7 @@ FEDORA_PACKAGES=(
fish
flatpak-spawn
foo2zjs
gcc
git-credential-libsecret
glow
google-noto-sans-balinese-fonts

View file

@ -0,0 +1,39 @@
#!/usr/bin/bash
echo "::group:: ===$(basename "$0")==="
set -eoux pipefail
# Remove Existing Kernel
for pkg in kernel kernel{-core,-modules,-modules-core,-modules-extra,-tools-libs,-tools}; do
rpm --erase "${pkg}" --nodeps
done
# cleanup leftovers that are not covered by kernel-* packages for some reason
rm -rf /usr/lib/modules
# Install Kernel
dnf5 -y install \
/tmp/kernel-rpms/kernel-[0-9]*.rpm \
/tmp/kernel-rpms/kernel-core-*.rpm \
/tmp/kernel-rpms/kernel-modules-*.rpm
if [[ "${IMAGE_FLAVOR}" == "dx" ]]; then
dnf -y install /tmp/kernel-rpms/kernel-devel-*.rpm
fi
dnf5 versionlock add kernel kernel-devel kernel-devel-matched kernel-core kernel-modules kernel-modules-core kernel-modules-extra
dnf -y install /tmp/rpms/{common,kmods}/*xone*.rpm /tmp/rpms/{common,kmods}/*openrazer*.rpm || true
dnf -y install /tmp/rpms/{kmods,common}/*v4l2loopback*.rpm || true
mkdir -p /etc/pki/akmods/certs
ghcurl "https://github.com/ublue-os/akmods/raw/refs/heads/main/certs/public_key.der" --retry 3 -Lo /etc/pki/akmods/certs/akmods-ublue.der
# OpenRazer from hardware:razer repo (not a COPR)
dnf -y config-manager addrepo --from-repofile=https://openrazer.github.io/hardware:razer.repo
dnf -y install openrazer-daemon || true
sed -i 's@enabled=1@enabled=0@g' /etc/yum.repos.d/hardware:razer.repo
echo "::endgroup::"

View file

@ -1,105 +0,0 @@
#!/usr/bin/bash
echo "::group:: ===$(basename "$0")==="
set -eoux pipefail
# Remove Existing Kernel
for pkg in kernel kernel{-core,-modules,-modules-core,-modules-extra,-tools-libs,-tools}; do
rpm --erase $pkg --nodeps
done
# cleanup leftovers that are not covered by kernel-* packages for some reason
rm -rf /usr/lib/modules
# Fetch Common AKMODS & Kernel RPMS
skopeo copy --retry-times 3 docker://ghcr.io/ublue-os/akmods:"${AKMODS_FLAVOR}"-"$(rpm -E %fedora)"-"${KERNEL}" dir:/tmp/akmods
AKMODS_TARGZ=$(jq -r '.layers[].digest' </tmp/akmods/manifest.json | cut -d : -f 2)
tar -xvzf /tmp/akmods/"$AKMODS_TARGZ" -C /tmp/
mv /tmp/rpms/* /tmp/akmods/
# NOTE: kernel-rpms should auto-extract into correct location
# Install Kernel
dnf5 -y install \
/tmp/kernel-rpms/kernel-[0-9]*.rpm \
/tmp/kernel-rpms/kernel-core-*.rpm \
/tmp/kernel-rpms/kernel-modules-*.rpm
# TODO: Figure out why akmods cache is pulling in akmods/kernel-devel
dnf5 -y install \
/tmp/kernel-rpms/kernel-devel-*.rpm
dnf5 versionlock add kernel kernel-devel kernel-devel-matched kernel-core kernel-modules kernel-modules-core kernel-modules-extra
dnf copr enable -y ublue-os/akmods
# RPMFUSION Dependent AKMODS
dnf5 -y install /tmp/akmods/kmods/*xone*.rpm || true
dnf5 -y install /tmp/akmods/kmods/*openrazer*.rpm || true
dnf5 -y install \
https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-"$(rpm -E %fedora)".noarch.rpm \
https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-"$(rpm -E %fedora)".noarch.rpm
dnf5 -y install \
v4l2loopback /tmp/akmods/kmods/*v4l2loopback*.rpm || true
dnf5 -y remove rpmfusion-free-release rpmfusion-nonfree-release
mkdir -p /etc/pki/akmods/certs
ghcurl "https://github.com/ublue-os/akmods/raw/refs/heads/main/certs/public_key.der" --retry 3 -Lo /etc/pki/akmods/certs/akmods-ublue.der
# OpenRazer from hardware:razer repo (not a COPR)
dnf -y config-manager addrepo --from-repofile=https://openrazer.github.io/hardware:razer.repo
dnf -y install openrazer-daemon || true
sed -i 's@enabled=1@enabled=0@g' /etc/yum.repos.d/hardware:razer.repo
# Nvidia AKMODS
if [[ "${IMAGE_NAME}" =~ nvidia ]]; then
# Fetch Nvidia RPMs
skopeo copy --retry-times 3 docker://ghcr.io/ublue-os/akmods-nvidia-open:"${AKMODS_FLAVOR}"-"$(rpm -E %fedora)"-"${KERNEL}" dir:/tmp/akmods-rpms
NVIDIA_TARGZ=$(jq -r '.layers[].digest' </tmp/akmods-rpms/manifest.json | cut -d : -f 2)
tar -xvzf /tmp/akmods-rpms/"$NVIDIA_TARGZ" -C /tmp/
mv /tmp/rpms/* /tmp/akmods-rpms/
# Not available for Fedora 43 yet
dnf5 config-manager setopt excludepkgs=golang-github-nvidia-container-toolkit
# Install Nvidia RPMs
ghcurl "https://raw.githubusercontent.com/ublue-os/main/main/build_files/nvidia-install.sh" -o /tmp/nvidia-install.sh
chmod +x /tmp/nvidia-install.sh
IMAGE_NAME="${BASE_IMAGE_NAME}" RPMFUSION_MIRROR="" /tmp/nvidia-install.sh
rm -f /usr/share/vulkan/icd.d/nouveau_icd.*.json
ln -sf libnvidia-ml.so.1 /usr/lib64/libnvidia-ml.so
tee /usr/lib/bootc/kargs.d/00-nvidia.toml <<EOF
kargs = ["rd.driver.blacklist=nouveau", "modprobe.blacklist=nouveau", "nvidia-drm.modeset=1", "initcall_blacklist=simpledrm_platform_driver_init"]
EOF
fi
# ZFS for gts/stable
if [[ ${AKMODS_FLAVOR} =~ coreos ]]; then
# Fetch ZFS RPMs
skopeo copy --retry-times 3 docker://ghcr.io/ublue-os/akmods-zfs:"${AKMODS_FLAVOR}"-"$(rpm -E %fedora)"-"${KERNEL}" dir:/tmp/akmods-zfs
ZFS_TARGZ=$(jq -r '.layers[].digest' </tmp/akmods-zfs/manifest.json | cut -d : -f 2)
tar -xvzf /tmp/akmods-zfs/"$ZFS_TARGZ" -C /tmp/
mv /tmp/rpms/* /tmp/akmods-zfs/
# Declare ZFS RPMs
ZFS_RPMS=(
/tmp/akmods-zfs/kmods/zfs/kmod-zfs-"${KERNEL}"-*.rpm
/tmp/akmods-zfs/kmods/zfs/libnvpair[0-9]-*.rpm
/tmp/akmods-zfs/kmods/zfs/libuutil[0-9]-*.rpm
/tmp/akmods-zfs/kmods/zfs/libzfs[0-9]-*.rpm
/tmp/akmods-zfs/kmods/zfs/libzpool[0-9]-*.rpm
/tmp/akmods-zfs/kmods/zfs/python3-pyzfs-*.rpm
/tmp/akmods-zfs/kmods/zfs/zfs-*.rpm
pv
)
# Install
dnf5 -y install "${ZFS_RPMS[@]}"
# Depmod and autoload
depmod -a -v "${KERNEL}"
echo "zfs" >/usr/lib/modules-load.d/zfs.conf
fi
echo "::endgroup::"

View file

@ -148,6 +148,18 @@ if [[ "${IMAGE_NAME}" =~ nvidia ]]; then
done
fi
if [[ ${AKMODS_FLAVOR} =~ coreos ]]; then
ZFS_PACKAGES=(
kmod-zfs
libzfs6
zfs
python3-pyzfs
)
for package in "${ZFS_PACKAGES[@]}"; do
rpm -q "${package}" >/dev/null || { echo "Missing ZFS package: ${package}... Exiting"; exit 1 ; }
done
fi
IMPORTANT_UNITS=(
rpm-ostree-countme.timer
tailscaled.service

19
build_files/base/nvidia.sh Executable file
View file

@ -0,0 +1,19 @@
#!/usr/bin/bash
echo "::group:: ===$(basename "$0")==="
set -eoux pipefail
# Not available for Fedora 43 yet
dnf config-manager setopt excludepkgs=golang-github-nvidia-container-toolkit
ghcurl "https://raw.githubusercontent.com/ublue-os/main/main/build_files/nvidia-install.sh" -o /tmp/nvidia-install.sh
chmod +x /tmp/nvidia-install.sh
IMAGE_NAME="${BASE_IMAGE_NAME}" RPMFUSION_MIRROR="" AKMODNV_PATH="/tmp/rpms/nvidia" /tmp/nvidia-install.sh
rm -f /usr/share/vulkan/icd.d/nouveau_icd.*.json
ln -sf libnvidia-ml.so.1 /usr/lib64/libnvidia-ml.so
tee /usr/lib/bootc/kargs.d/00-nvidia.toml <<EOF
kargs = ["rd.driver.blacklist=nouveau", "modprobe.blacklist=nouveau", "nvidia-drm.modeset=1", "initcall_blacklist=simpledrm_platform_driver_init"]
EOF
echo "::endgroup::"

26
build_files/base/zfs.sh Executable file
View file

@ -0,0 +1,26 @@
#!/usr/bin/bash
echo "::group:: ===$(basename "$0")==="
set -eoux pipefail
# ZFS is only installed on coreos-stable
ZFS_RPMS=(
/tmp/rpms/kmods/zfs/kmod-zfs-"${KERNEL}"-*.rpm
/tmp/rpms/kmods/zfs/libnvpair[0-9]-*.rpm
/tmp/rpms/kmods/zfs/libuutil[0-9]-*.rpm
/tmp/rpms/kmods/zfs/libzfs[0-9]-*.rpm
/tmp/rpms/kmods/zfs/libzpool[0-9]-*.rpm
/tmp/rpms/kmods/zfs/python3-pyzfs-*.rpm
/tmp/rpms/kmods/zfs/zfs-*.rpm
pv
)
dnf -y install "${ZFS_RPMS[@]}"
# Depmod and autoload
depmod -a -v "${KERNEL}"
echo "zfs" >/usr/lib/modules-load.d/zfs.conf
echo "::endgroup::"

View file

@ -17,8 +17,6 @@ mv '/usr/share/doc/just/README.中文.md' '/usr/share/doc/just/README.zh-cn.md'
rm -rf /.gitkeep
rm -rf /var/ && mkdir -p /var/tmp
# Needs to be here to make the main image build strict (no /opt there)
# This is for downstream images/stuff like k0s
rm -rf /opt && ln -s /var/opt /opt