Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Use cached kernel #265

Merged
merged 25 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
workflow_call:
inputs:
fedora_version:
description: 'The Fedora release version: 39, 40, etc'
description: "The Fedora release version: 39, 40, etc"
required: true
type: string
env:
Expand Down Expand Up @@ -161,17 +161,6 @@ jobs:
containers: akmods-nvidia:${{ matrix.kernel_flavor}}-${{ matrix.fedora_version }}
registry: ${{ env.IMAGE_REGISTRY }}

- name: Pull main and akmods-nvidia images
uses: Wandalen/wretry.action@v3.5.0
with:
attempt_limit: 3
attempt_delay: 15000
command: |
# pull the base image used for FROM in containerfile so
# we can retry on that unfortunately common failure case
podman pull ${{ env.IMAGE_REGISTRY }}/${{ env.SOURCE_IMAGE }}:${{ matrix.fedora_version }}
podman pull ${{ env.IMAGE_REGISTRY }}/akmods-nvidia:${{ matrix.kernel_flavor }}-${{ matrix.fedora_version }}

- name: Get current version
id: labels
uses: Wandalen/wretry.action@v3.5.0
Expand All @@ -187,15 +176,26 @@ jobs:
exit 1
fi
echo "SOURCE_IMAGE_VERSION=$ver" >> $GITHUB_ENV

skopeo inspect docker://${{ env.IMAGE_REGISTRY }}/akmods-nvidia:${{ matrix.kernel_flavor }}-${{ matrix.fedora_version }} > akmods.json
linux=$(jq -r '.Labels["ostree.linux"]' akmods.json)
skopeo inspect docker://${{ env.IMAGE_REGISTRY }}/${{ matrix.kernel_flavor }}-kernel:${{ matrix.fedora_version }} > kernel.json
linux=$(jq -r '.Labels["ostree.linux"]' kernel.json)
if [ -z "$linux" ] || [ "null" = "$linux" ]; then
echo "inspected image linux version must not be empty or null"
exit 1
fi
echo "KERNEL_VERSION=$linux" >> $GITHUB_ENV

- name: Pull main and akmods-nvidia images
uses: Wandalen/wretry.action@v3.5.0
with:
attempt_limit: 3
attempt_delay: 15000
command: |
# pull the base image used for FROM in containerfile so
# we can retry on that unfortunately common failure case
podman pull ${{ env.IMAGE_REGISTRY }}/${{ env.SOURCE_IMAGE }}:${{ matrix.fedora_version }}
podman pull ${{ env.IMAGE_REGISTRY }}/akmods-nvidia:${{ matrix.kernel_flavor }}-${{ matrix.fedora_version }}
podman pull ${{ env.IMAGE_REGISTRY }}/${{ matrix.kernel_flavor}}-kernel:${{ env.KERNEL_VERSION }}

# Build metadata
- name: Image Metadata
uses: docker/metadata-action@v5
Expand Down Expand Up @@ -226,6 +226,7 @@ jobs:
SOURCE_IMAGE=${{ env.SOURCE_IMAGE }}
FEDORA_MAJOR_VERSION=${{ matrix.fedora_version }}
KERNEL_FLAVOR=${{ matrix.kernel_flavor }}
KERNEL_VERSION=${{ env.KERNEL_VERSION }}
RPMFUSION_MIRROR=${{ vars.RPMFUSION_MIRROR }}
labels: ${{ steps.meta.outputs.labels }}
oci: false
Expand Down
9 changes: 6 additions & 3 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ ARG SOURCE_IMAGE="${SOURCE_IMAGE:-silverblue-main}"
ARG SOURCE_ORG="${SOURCE_ORG:-ublue-os}"
ARG BASE_IMAGE="ghcr.io/${SOURCE_ORG}/${SOURCE_IMAGE}"
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-40}"
ARG KERNEL_FLAVOR="${KERNEL_FLAVOR:-main}"
ARG KERNEL_VERSION="${KERNEL_VERSION:-6.9.7-200.fc40.x86_64}"

FROM ghcr.io/${SOURCE_ORG}/${KERNEL_FLAVOR}-kernel:${KERNEL_VERSION} AS kernel

FROM ${BASE_IMAGE}:${FEDORA_MAJOR_VERSION} AS main

Expand All @@ -11,16 +15,15 @@ ARG KERNEL_FLAVOR="${KERNEL_FLAVOR:-main}"
ARG IMAGE_NAME="${IMAGE_NAME:-silverblue}"
ARG IMAGE_VENDOR="${IMAGE_VENDOR:-ublue-os}"
ARG RPMFUSION_MIRROR=""
ARG KERNEL_VERSION="${KERNEL_VERSION:-6.9.7-200.fc40.x86_64}"

COPY *.sh /tmp/
COPY ${KERNEL_FLAVOR}/ /tmp/
COPY --from=kernel /tmp/rpms /tmp/kernel-rpms/

RUN mkdir -p /var/lib/alternatives && \
IMAGE_FLAVOR=main /tmp/image-info.sh && \
/tmp/install.sh && \
if [ "${KERNEL_FLAVOR}" != "main" ]; then \
/tmp/build-initramfs.sh \
; fi && \
mv /var/lib/alternatives /staged-alternatives && \
rm -rf /tmp/* /var/* && \
ostree container commit && \
Expand Down
44 changes: 27 additions & 17 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,44 @@ fi
if [ "${KERNEL_FLAVOR}" = "asus" ]; then
echo "install.sh: steps for KERNEL_FLAVOR: ${KERNEL_FLAVOR}"
# Install Asus kernel
wget https://copr.fedorainfracloud.org/coprs/lukenukem/asus-linux/repo/fedora-${RELEASE}/lukenukem-asus-linux-fedora-${RELEASE}.repo -O /etc/yum.repos.d/_copr_lukenukem-asus-linux.repo
wget https://copr.fedorainfracloud.org/coprs/lukenukem/asus-kernel/repo/fedora-${RELEASE}/lukenukem-asus-kernel-fedora-${RELEASE}repo -O /etc/yum.repos.d/_copr_lukenukem-asus-kernel.repo
curl -Lo /etc/yum.repos.d/_copr_lukenukem-asus-linux.repo \
https://copr.fedorainfracloud.org/coprs/lukenukem/asus-linux/repo/fedora-"${RELEASE}"/lukenukem-asus-linux-fedora-"${RELEASE}".repo
rpm-ostree cliwrap install-to-root /
rpm-ostree override replace \
--experimental \
--from repo=copr:copr.fedorainfracloud.org:lukenukem:asus-kernel \
kernel \
kernel-core \
kernel-modules \
kernel-modules-core \
kernel-modules-extra
--experimental \
/tmp/kernel-rpms/kernel-"${KERNEL_VERSION}".rpm \
/tmp/kernel-rpms/kernel-core-"${KERNEL_VERSION}".rpm \
/tmp/kernel-rpms/kernel-modules-"${KERNEL_VERSION}".rpm \
/tmp/kernel-rpms/kernel-modules-core-"${KERNEL_VERSION}".rpm \
/tmp/kernel-rpms/kernel-modules-extra-"${KERNEL_VERSION}".rpm
git clone https://gitlab.com/asus-linux/firmware.git --depth 1 /tmp/asus-firmware
cp -rf /tmp/asus-firmware/* /usr/lib/firmware/
rm -rf /tmp/asus-firmware
elif [ "${KERNEL_FLAVOR}" = "surface" ]; then
echo "install.sh: steps for KERNEL_FLAVOR: ${KERNEL_FLAVOR}"
curl -Lo /etc/yum.repos.d/linux-surface.repo \
https://pkg.surfacelinux.com/fedora/linux-surface.repo
curl -Lo /tmp/surface-kernel.rpm \
https://github.com/linux-surface/linux-surface/releases/download/silverblue-20201215-1/kernel-20201215-1.x86_64.rpm
# Install Surface kernel
wget https://pkg.surfacelinux.com/fedora/linux-surface.repo -P /etc/yum.repos.d
wget https://github.com/linux-surface/linux-surface/releases/download/silverblue-20201215-1/kernel-20201215-1.x86_64.rpm -O /tmp/surface-kernel.rpm
rpm-ostree cliwrap install-to-root /
rpm-ostree override replace /tmp/surface-kernel.rpm \
rpm-ostree override replace \
--experimental \
--remove kernel \
--remove kernel-core \
--remove kernel-modules \
--remove kernel-modules-core \
--remove kernel-modules-extra \
--remove libwacom \
--remove libwacom-data \
--install kernel-surface \
--install iptsd \
--install libwacom-surface \
--install libwacom-surface-data
/tmp/kernel-rpms/kernel-surface-"${KERNEL_VERSION}".rpm \
/tmp/kernel-rpms/kernel-surface-core-"${KERNEL_VERSION}".rpm \
/tmp/kernel-rpms/kernel-surface-modules-"${KERNEL_VERSION}".rpm \
/tmp/kernel-rpms/kernel-surface-modules-core-"${KERNEL_VERSION}".rpm \
/tmp/kernel-rpms/kernel-surface-modules-extra-"${KERNEL_VERSION}".rpm \
/tmp/kernel-rpms/kernel-surface-default-watchdog-"${KERNEL_VERSION}".rpm \
/tmp/kernel-rpms/libwacom-surface*.rpm \
/tmp/kernel-rpms/iptsd*.rpm
else
echo "install.sh: steps for unexpected KERNEL_FLAVOR: ${KERNEL_FLAVOR}"
fi
Expand Down Expand Up @@ -94,4 +102,6 @@ if [ -n "${RPMFUSION_MIRROR}" ]; then
# reset forced use of single rpmfusion mirror
echo "Revert from single rpmfusion mirror: ${RPMFUSION_MIRROR}"
rename -v .repo.bak .repo /etc/yum.repos.d/rpmfusion-*repo.bak
fi
fi

/tmp/build-initramfs.sh