diff --git a/Containerfile b/Containerfile deleted file mode 100644 index 6298f0b6..00000000 --- a/Containerfile +++ /dev/null @@ -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 diff --git a/Containerfile.in b/Containerfile.in new file mode 100644 index 00000000..cf32775c --- /dev/null +++ b/Containerfile.in @@ -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 diff --git a/Justfile b/Justfile index 19778cdd..1bb6db88 100644 --- a/Justfile +++ b/Justfile @@ -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 diff --git a/build_files/base/01-packages.sh b/build_files/base/01-packages.sh index e6108546..a91db61a 100755 --- a/build_files/base/01-packages.sh +++ b/build_files/base/01-packages.sh @@ -79,6 +79,7 @@ FEDORA_PACKAGES=( fish flatpak-spawn foo2zjs + gcc git-credential-libsecret glow google-noto-sans-balinese-fonts diff --git a/build_files/base/02-install-common-kernel-akmods.sh b/build_files/base/02-install-common-kernel-akmods.sh new file mode 100755 index 00000000..99ba3741 --- /dev/null +++ b/build_files/base/02-install-common-kernel-akmods.sh @@ -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::" diff --git a/build_files/base/02-install-kernel-akmods.sh b/build_files/base/02-install-kernel-akmods.sh deleted file mode 100755 index f2570fc4..00000000 --- a/build_files/base/02-install-kernel-akmods.sh +++ /dev/null @@ -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' /usr/lib/modules-load.d/zfs.conf -fi - -echo "::endgroup::" diff --git a/build_files/base/20-tests.sh b/build_files/base/20-tests.sh index 0da37923..4e25e52b 100755 --- a/build_files/base/20-tests.sh +++ b/build_files/base/20-tests.sh @@ -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 diff --git a/build_files/base/nvidia.sh b/build_files/base/nvidia.sh new file mode 100755 index 00000000..ababd837 --- /dev/null +++ b/build_files/base/nvidia.sh @@ -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 </usr/lib/modules-load.d/zfs.conf + +echo "::endgroup::" diff --git a/build_files/shared/clean-stage.sh b/build_files/shared/clean-stage.sh index d3e8288a..7c51605b 100755 --- a/build_files/shared/clean-stage.sh +++ b/build_files/shared/clean-stage.sh @@ -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