Skip to content

Commit 7c9b33c

Browse files
bshermanEyeCantCU
andauthored
feat(ci): fix linux version metadata and make builds more reliable (#171)
Signed-off-by: RJ Trujillo <eyecantcu@pm.me> Co-authored-by: RJ Trujillo <eyecantcu@pm.me>
1 parent 55a17ac commit 7c9b33c

File tree

6 files changed

+120
-70
lines changed

6 files changed

+120
-70
lines changed

.github/workflows/reusable-build.yml

Lines changed: 79 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
required: true
88
type: string
99
env:
10-
IMAGE_NAME: akmods
10+
IMAGE_BASE_NAME: akmods
1111
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
1212

1313
concurrency:
@@ -36,14 +36,7 @@ jobs:
3636
cfile_suffix:
3737
- common
3838
- nvidia
39-
nvidia_version:
40-
- 0
41-
- 550
4239
exclude:
43-
- cfile_suffix: common
44-
nvidia_version: 550
45-
- cfile_suffix: nvidia
46-
nvidia_version: 0
4740
- kernel_flavor: asus
4841
fedora_version: 38
4942
- kernel_flavor: surface
@@ -56,7 +49,6 @@ jobs:
5649
kernel_flavor: fsync # kernel-fsync packages are not being built for F40 yet.
5750
- fedora_version: 40
5851
kernel_flavor: fsync-lts
59-
6052
steps:
6153
# Checkout push-to-registry action GitHub repository
6254
- name: Checkout Push to Registry action
@@ -65,26 +57,31 @@ jobs:
6557
- name: Matrix Variables
6658
shell: bash
6759
run: |
60+
if [ "common" == "${{ matrix.cfile_suffix }}" ]; then
61+
echo "IMAGE_NAME=${{ env.IMAGE_BASE_NAME }}" >> $GITHUB_ENV
62+
else
63+
echo "IMAGE_NAME=${{ env.IMAGE_BASE_NAME }}-${{ matrix.cfile_suffix }}" >> $GITHUB_ENV
64+
fi
6865
if [[ "${{ matrix.fedora_version }}" -ge "41" ]]; then
6966
# when we are confident of official fedora images we can switch to them
70-
echo "SOURCE_IMAGE=fedora-silverblue" >> $GITHUB_ENV
71-
echo "SOURCE_ORG=fedora" >> $GITHUB_ENV
67+
export SOURCE_IMAGE=fedora-silverblue
68+
export SOURCE_ORG=fedora
7269
else
73-
echo "SOURCE_IMAGE=base" >> $GITHUB_ENV
74-
echo "SOURCE_ORG=fedora-ostree-desktops" >> $GITHUB_ENV
70+
export SOURCE_IMAGE=base
71+
export SOURCE_ORG=fedora-ostree-desktops
7572
fi
73+
echo "FQ_SOURCE_IMAGE=quay.io/${SOURCE_ORG}/${SOURCE_IMAGE}:${{ matrix.fedora_version }}" >> $GITHUB_ENV
74+
echo "SOURCE_IMAGE=${SOURCE_IMAGE}" >> $GITHUB_ENV
75+
echo "SOURCE_ORG=${SOURCE_ORG}" >> $GITHUB_ENV
76+
7677
7778
- name: Generate tags
7879
id: generate-tags
7980
shell: bash
8081
run: |
8182
# Generate a timestamp for creating an image version history
8283
TIMESTAMP="$(date +%Y%m%d)"
83-
if [[ "${{ matrix.cfile_suffix }}" == "nvidia" ]]; then
84-
VARIANT="${{ matrix.kernel_flavor }}-${{ matrix.fedora_version }}-${{ matrix.nvidia_version }}"
85-
else
86-
VARIANT="${{ matrix.kernel_flavor }}-${{ matrix.fedora_version }}"
87-
fi
84+
VARIANT="${{ matrix.kernel_flavor }}-${{ matrix.fedora_version }}"
8885
8986
COMMIT_TAGS=()
9087
BUILD_TAGS=()
@@ -125,69 +122,103 @@ jobs:
125122
# DEBUG: get character count of key
126123
wc -c certs/private_key.priv
127124
128-
- name: Get current version
129-
id: labels
125+
- name: Pull build image
130126
uses: Wandalen/wretry.action@v2.1.0
131127
with:
132128
attempt_limit: 3
133129
attempt_delay: 15000
134130
command: |
135-
set -eo pipefail
136-
skopeo inspect docker://quay.io/${{ env.SOURCE_ORG }}/${{ env.SOURCE_IMAGE }}:${{ matrix.fedora_version }} > inspect.json
137-
ver=$(jq -r '.Labels["org.opencontainers.image.version"]' inspect.json)
131+
# pull the base image used for FROM in containerfile so
132+
# we can retry on that unfortunately common failure case
133+
podman pull ${{ env.FQ_SOURCE_IMAGE }}
134+
135+
- name: Get current version
136+
run: |
137+
set -eo pipefail
138+
139+
# skopeo must always run to inspect image labels for build version
140+
skopeo inspect docker://${{ env.FQ_SOURCE_IMAGE }} > inspect.json
141+
ver=$(jq -r '.Labels["org.opencontainers.image.version"]' inspect.json)
142+
if [ -z "$ver" ] || [ "null" = "$ver" ]; then
143+
echo "inspected image version must not be empty or null"
144+
exit 1
145+
fi
146+
147+
if [ "main" == "${{ matrix.kernel_flavor }}" ]; then
148+
# main kernel_flavor: use ostree.linux to determine kernel version
138149
linux=$(jq -r '.Labels["ostree.linux"]' inspect.json)
139-
if [ -z "$ver" ] || [ "null" = "$ver" ]; then
140-
echo "inspected image version must not be empty or null"
141-
exit 1
142-
fi
143-
if [ -z "$linux" ] || [ "null" = "$linux" ]; then
144-
echo "inspected image linux version must not be empty or null"
145-
exit 1
146-
fi
147-
echo "SOURCE_IMAGE_VERSION=$ver" >> $GITHUB_ENV
148-
echo "SOURCE_IMAGE_LINUX=$linux" >> $GITHUB_ENV
150+
else
151+
# other kernel_flavor: start container use dnf to find kernel version
152+
container_name="fq-$(uuidgen)"
153+
podman run --entrypoint /bin/bash --name "$container_name" -dt "${{ env.FQ_SOURCE_IMAGE }}"
154+
podman exec $container_name rpm-ostree install dnf dnf-plugins-core
155+
156+
# Fetch kernel version
157+
dnf="podman exec $container_name dnf"
158+
case "${{ matrix.kernel_flavor }}" in
159+
"asus")
160+
$dnf copr enable -y lukenukem/asus-kernel
161+
linux=$($dnf repoquery --repoid copr:copr.fedorainfracloud.org:lukenukem:asus-kernel --whatprovides kernel | tail -n1 | sed 's/.*://')
162+
;;
163+
"fsync")
164+
$dnf copr enable -y sentry/kernel-fsync
165+
linux=$($dnf repoquery --repoid copr:copr.fedorainfracloud.org:sentry:kernel-fsync --whatprovides kernel | tail -n1 | sed 's/.*://')
166+
;;
167+
"fsync-lts")
168+
$dnf copr enable -y sentry/kernel-ba
169+
linux=$($dnf repoquery --repoid copr:copr.fedorainfracloud.org:sentry:kernel-ba --whatprovides kernel | tail -n1 | sed 's/.*://')
170+
;;
171+
"main")
172+
linux=$($dnf repoquery --whatprovides kernel | tail -n1 | sed 's/.*://')
173+
;;
174+
"surface")
175+
$dnf config-manager --add-repo=https://pkg.surfacelinux.com/fedora/linux-surface.repo
176+
linux=$($dnf repoquery --repoid linux-surface --whatprovides kernel-surface | tail -n1 | sed 's/.*://')
177+
;;
178+
*)
179+
echo "unexpected kernel_flavor '${{ matrix.kernel_flavor }}' for dnf repoquery"
180+
;;
181+
esac
182+
fi
183+
184+
if [ -z "$linux" ] || [ "null" = "$linux" ]; then
185+
echo "inspected image linux version must not be empty or null"
186+
exit 1
187+
fi
188+
echo "SOURCE_IMAGE_VERSION=$ver" >> $GITHUB_ENV
189+
echo "KERNEL_VERSION=$linux" >> $GITHUB_ENV
149190
150191
# Build metadata
151192
- name: Image Metadata
152193
uses: docker/metadata-action@v5
153194
id: meta
154195
with:
155196
images: |
156-
${{ 'nvidia' == matrix.cfile_suffix && format('{0}-nvidia', env.IMAGE_NAME) || format('{0}', env.IMAGE_NAME) }}
197+
${{ env.IMAGE_NAME }}
157198
labels: |
158-
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
199+
org.opencontainers.image.title=${{ env.IMAGE_BASE_NAME }}
159200
org.opencontainers.image.description=A caching layer for pre-built akmod RPMs
160201
org.opencontainers.image.version=${{ env.SOURCE_IMAGE_VERSION }}
161-
ostree.linux=${{ env.SOURCE_IMAGE_LINUX }}
202+
ostree.linux=${{ env.KERNEL_VERSION }}
162203
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/${{ github.repository }}/main/README.md
163204
io.artifacthub.package.logo-url=https://avatars.githubusercontent.com/u/1728152?s=200&v=4
164205
165-
- name: Pull build image
166-
uses: Wandalen/wretry.action@v2.1.0
167-
with:
168-
attempt_limit: 3
169-
attempt_delay: 15000
170-
command: |
171-
# pull the base image used for FROM in containerfile so
172-
# we can retry on that unfortunately common failure case
173-
podman pull quay.io/${{ env.SOURCE_ORG }}/${{ env.SOURCE_IMAGE }}:${{ matrix.fedora_version }}
174-
175206
# Build image using Buildah action
176207
- name: Build Image
177208
id: build_image
178209
uses: redhat-actions/buildah-build@v2
179210
with:
180211
containerfiles: |
181212
./Containerfile.${{ matrix.cfile_suffix }}
182-
image: ${{ 'nvidia' == matrix.cfile_suffix && format('{0}-nvidia', env.IMAGE_NAME) || format('{0}', env.IMAGE_NAME) }}
213+
image: ${{ env.IMAGE_NAME }}
183214
tags: |
184215
${{ steps.generate-tags.outputs.alias_tags }}
185216
build-args: |
186217
SOURCE_IMAGE=${{ env.SOURCE_IMAGE }}
187218
SOURCE_ORG=${{ env.SOURCE_ORG }}
188219
KERNEL_FLAVOR=${{ matrix.kernel_flavor }}
220+
KERNEL_VERSION=${{ env.KERNEL_VERSION }}
189221
FEDORA_MAJOR_VERSION=${{ matrix.fedora_version }}
190-
NVIDIA_MAJOR_VERSION=${{ matrix.nvidia_version }}
191222
RPMFUSION_MIRROR=${{ vars.RPMFUSION_MIRROR }}
192223
labels: ${{ steps.meta.outputs.labels }}
193224
oci: false

Containerfile.common

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-39}"
1111
FROM ${BASE_IMAGE}:${FEDORA_MAJOR_VERSION} AS builder
1212
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-39}"
1313
ARG KERNEL_FLAVOR="{KERNEL_FLAVOR:-main}"
14+
ARG KERNEL_VERSION=""
1415
ARG RPMFUSION_MIRROR=""
1516

1617
COPY build*.sh /tmp

Containerfile.nvidia

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
###
2-
### Containerfile.nvidia - used to build ONLY NVIDIA kmods (one driver version per build)
2+
### Containerfile.nvidia - used to build ONLY NVIDIA kmods
33
###
44

5-
#Build from base, simpley because it's the smallest image
5+
#Build from base, simply because it's the smallest image
66
ARG SOURCE_IMAGE="${SOURCE_IMAGE:-base}"
77
ARG SOURCE_ORG="${SOURCE_ORG:-fedora-ostree-desktops}"
88
ARG BASE_IMAGE="quay.io/${SOURCE_ORG}/${SOURCE_IMAGE}"
99
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-39}"
1010

1111
FROM ${BASE_IMAGE}:${FEDORA_MAJOR_VERSION} AS builder
1212
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-39}"
13-
ARG NVIDIA_MAJOR_VERSION="${NVIDIA_MAJOR_VERSION:-550}"
1413
ARG KERNEL_FLAVOR="{KERNEL_FLAVOR:-main}"
14+
ARG KERNEL_VERSION=""
1515
ARG RPMFUSION_MIRROR=""
1616

1717
COPY build*.sh /tmp
@@ -39,7 +39,7 @@ RUN if grep -qv "surface" <<< "${KERNEL_FLAVOR}"; then \
3939
; else \
4040
export KERNEL_NAME="kernel-surface" \
4141
; fi && \
42-
/tmp/build-kmod-nvidia.sh ${NVIDIA_MAJOR_VERSION}
42+
/tmp/build-kmod-nvidia.sh 550
4343

4444
RUN cp /tmp/ublue-os-nvidia-addons/rpmbuild/RPMS/noarch/ublue-os-nvidia-addons*.rpm \
4545
/var/cache/rpms/ublue-os/

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,21 @@ The [`akmods` image](https://github.com/orgs/ublue-os/packages/container/package
4040

4141
Here's a rundown on how it's organized.
4242

43-
We do our best to support all current builds of Fedora, current versions of the kernel modules listed, and in the case of NVIDIA current (550).
44-
**Note: NVIDIA legacy driver version 470 is no longer provided as RPMfusion has ceased updates to the package and it no longer builds with kernel 6.8 which has now released for Fedora 38 and 39.**
43+
We do our best to support all current builds of Fedora, current versions of the kernel modules listed, and the latest NVIDIA driver.
44+
**Note: NVIDIA legacy driver version 470 is no longer provided as RPMfusion has ceased updates to the package and it no longer builds with kernel 6.8 which has now released for Fedora 38 and 39. Also the `-550` extra driver version tag has been removed as the latest driver will always be included.**
4545

4646
The majority of the drivers are tagged with `KERNEL_TYPE-FEDORA_RELEASE`. NVIDIA drivers are bundled distinctly with tag `KERNEL_TYPE-FEDORA_RELEASE-NVIDIA_VERSION`.
4747

4848
| KERNEL_TYPE | FEDORA_RELEASE | TAG |
4949
| - | - | - |
50-
| Fedora stock kernel | 38 | `main-38`, `main-38-550` |
51-
| | 39 | `main-39`, `main-39-550` |
52-
| | 40 | `main-40`, `main-40-550` |
53-
| [patched for ASUS devices](https://copr.fedorainfracloud.org/coprs/lukenukem/asus-kernel) | 39 | `asus-39`, `asus-39-550` |
54-
| | 40 | `asus-40`, `asus-40-550` |
55-
| [patched fsync](https://copr.fedorainfracloud.org/coprs/sentry/kernel-fsync) | 39 | `fsync-39`, `fsync-39-550` |
56-
| [patched Microsoft Surface devices](https://github.com/linux-surface/linux-surface/) | 39 | `surface-39`, `surface-39-550` |
57-
| | 40 | `surface-40`, `surface-40-550` |
50+
| Fedora stock kernel | 38 | `main-38` |
51+
| | 39 | `main-39` |
52+
| | 40 | `main-40` |
53+
| [patched for ASUS devices](https://copr.fedorainfracloud.org/coprs/lukenukem/asus-kernel) | 39 | `asus-39`|
54+
| | 40 | `asus-40` |
55+
| [patched fsync](https://copr.fedorainfracloud.org/coprs/sentry/kernel-fsync) | 39 | `fsync-39` |
56+
| [patched Microsoft Surface devices](https://github.com/linux-surface/linux-surface/) | 39 | `surface-39` |
57+
| | 40 | `surface-40` |
5858

5959

6060

build-kmod-nvidia.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ akmods --force --kernels "${KERNEL_VERSION}" --kmod "${NVIDIA_PACKAGE_NAME}"
3434
modinfo /usr/lib/modules/${KERNEL_VERSION}/extra/${NVIDIA_PACKAGE_NAME}/nvidia{,-drm,-modeset,-peermem,-uvm}.ko.xz > /dev/null || \
3535
(cat /var/cache/akmods/${NVIDIA_PACKAGE_NAME}/${NVIDIA_AKMOD_VERSION}-for-${KERNEL_VERSION}.failed.log && exit 1)
3636

37-
cat <<EOF > /var/cache/rpms/kmods/nvidia-vars.${NVIDIA_MAJOR_VERSION}
37+
cat <<EOF > /var/cache/rpms/kmods/nvidia-vars
3838
KERNEL_VERSION=${KERNEL_VERSION}
3939
RELEASE=${RELEASE}
4040
NVIDIA_PACKAGE_NAME=${NVIDIA_PACKAGE_NAME}

build-prep.sh

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,15 @@ if [ -n "${RPMFUSION_MIRROR}" ]; then
4242
sed -i "s%^#baseurl=http://download1.rpmfusion.org%baseurl=${RPMFUSION_MIRROR}%" /etc/yum.repos.d/rpmfusion-*.repo
4343
fi
4444

45+
# required for main and surface when fedora repo has updated kernel beyond what was in the image
46+
curl -L -o /etc/yum.repos.d/fedora-coreos-pool.repo \
47+
https://raw.githubusercontent.com/coreos/fedora-coreos-config/testing-devel/fedora-coreos-pool.repo
48+
4549
### PREPARE CUSTOM KERNEL SUPPORT
4650
if [[ "asus" == "${KERNEL_FLAVOR}" ]]; then
4751
echo "Installing ASUS Kernel:"
48-
wget https://copr.fedorainfracloud.org/coprs/lukenukem/asus-kernel/repo/fedora-$(rpm -E %fedora)/lukenukem-asus-kernel-fedora-$(rpm -E %fedora).repo -O /etc/yum.repos.d/_copr_lukenukem-asus-kernel.repo
52+
curl -L -o /etc/yum.repos.d/_copr_lukenukem-asus-kernel.repo \
53+
https://copr.fedorainfracloud.org/coprs/lukenukem/asus-kernel/repo/fedora-$(rpm -E %fedora)/lukenukem-asus-kernel-fedora-$(rpm -E %fedora).repo
4954
rpm-ostree cliwrap install-to-root /
5055
rpm-ostree override replace \
5156
--experimental \
@@ -59,7 +64,8 @@ if [[ "asus" == "${KERNEL_FLAVOR}" ]]; then
5964
kernel-modules-extra
6065
elif [[ "fsync-lts" == "${KERNEL_FLAVOR}" ]]; then
6166
echo "Installing fsync-lts kernel:"
62-
wget https://copr.fedorainfracloud.org/coprs/sentry/kernel-ba/repo/fedora-$(rpm -E %fedora)/sentry-kernel-ba-fedora-$(rpm -E %fedora).repo -O /etc/yum.repos.d/_copr_sentry-kernel-ba.repo
67+
curl -L -o /etc/yum.repos.d/_copr_sentry-kernel-ba.repo \
68+
https://copr.fedorainfracloud.org/coprs/sentry/kernel-ba/repo/fedora-$(rpm -E %fedora)/sentry-kernel-ba-fedora-$(rpm -E %fedora).repo
6369
rpm-ostree cliwrap install-to-root /
6470
rpm-ostree override replace \
6571
--experimental \
@@ -73,7 +79,8 @@ elif [[ "fsync-lts" == "${KERNEL_FLAVOR}" ]]; then
7379
kernel-modules-extra
7480
elif [[ "fsync" == "${KERNEL_FLAVOR}" ]]; then
7581
echo "Installing fsync kernel:"
76-
wget https://copr.fedorainfracloud.org/coprs/sentry/kernel-fsync/repo/fedora-$(rpm -E %fedora)/sentry-kernel-fsync-fedora-$(rpm -E %fedora).repo -O /etc/yum.repos.d/_copr_sentry-kernel-fsync.repo
82+
curl -L -o /etc/yum.repos.d/_copr_sentry-kernel-fsync.repo \
83+
https://copr.fedorainfracloud.org/coprs/sentry/kernel-fsync/repo/fedora-$(rpm -E %fedora)/sentry-kernel-fsync-fedora-$(rpm -E %fedora).repo
7784
rpm-ostree cliwrap install-to-root /
7885
rpm-ostree override replace \
7986
--experimental \
@@ -88,9 +95,10 @@ elif [[ "fsync" == "${KERNEL_FLAVOR}" ]]; then
8895
elif [[ "surface" == "${KERNEL_FLAVOR}" ]]; then
8996
echo "Installing Surface Kernel:"
9097
# Add Linux Surface repo
91-
wget https://pkg.surfacelinux.com/fedora/linux-surface.repo -P /etc/yum.repos.d
92-
wget https://github.com/linux-surface/linux-surface/releases/download/silverblue-20201215-1/kernel-20201215-1.x86_64.rpm -O \
93-
/tmp/surface-kernel.rpm
98+
curl -L -o /etc/yum.repos.d/linux-surface.repo \
99+
https://pkg.surfacelinux.com/fedora/linux-surface.repo
100+
curl -L -o /tmp/surface-kernel.rpm \
101+
https://github.com/linux-surface/linux-surface/releases/download/silverblue-20201215-1/kernel-20201215-1.x86_64.rpm
94102
rpm-ostree cliwrap install-to-root /
95103
rpm-ostree override replace /tmp/surface-kernel.rpm \
96104
--remove kernel-core \
@@ -103,8 +111,18 @@ elif [[ "surface" == "${KERNEL_FLAVOR}" ]]; then
103111
--install kernel-surface-modules \
104112
--install kernel-surface-modules-core \
105113
--install kernel-surface-modules-extra
114+
elif [[ "main" == "${KERNEL_FLAVOR}" ]] && \
115+
[[ "" != "${KERNEL_VERSION}" ]]; then
116+
echo "main kernel version ${KERNEL_VERSION} to avoid upgrading kernel beyond what is in the image."
117+
rpm-ostree cliwrap install-to-root /
118+
rpm-ostree install \
119+
kernel-devel-${KERNEL_VERSION} \
120+
kernel-devel-matched-${KERNEL_VERSION}
106121
else
107-
echo "Default main kernel needs no customization."
122+
echo "Default main kernel without a specific version."
123+
rpm-ostree install \
124+
kernel-devel \
125+
kernel-devel-matched
108126
fi
109127

110128

0 commit comments

Comments
 (0)