Skip to content

Commit

Permalink
tests/kola: rework derived kernel-replace
Browse files Browse the repository at this point in the history
Now use dnf download to go ahead and download the RPMs that we'll
override replace in the container build.

Also, for Fedora, stop hardcoding the kernel to use and default to
using the latest kernel in the N-1 release of Fedora. It guarantees
it will be a different kernel and also is a moving target, which
means it won't get grotesquely out of date.
  • Loading branch information
dustymabe committed Jan 28, 2025
1 parent 6f86533 commit ec24f20
Showing 1 changed file with 33 additions and 34 deletions.
67 changes: 33 additions & 34 deletions tests/kola/rpm-ostree/kernel-replace
Original file line number Diff line number Diff line change
Expand Up @@ -71,46 +71,44 @@ build_base_ociarchive() {
}

build_derived_ociarchive() {
# do the container build in a temporary context directory
contextdir=$(mktemp -d)
pushd ${contextdir}

case "$OS_ID" in
rhcos|scos|rhel|centos)
c9s_mirror="https://mirror.stream.centos.org/9-stream/BaseOS/${arch}/os"
# we're probably already on CentOS and running the latest kernel. so
# here we need to instead pick whatever the latest that's *not* the same
dnf_opts="--repofrompath=tmp,"${c9s_mirror}" --disablerepo=* --enablerepo tmp"
kver=$(dnf repoquery $dnf_opts kernel --qf '%{EVR}' | \
grep -v "$(rpm -q kernel --qf '%{EVR}')" | tail -n1)
# For some reason for now `kernel-modules-extra` doesn't resolve so we need to explicitly ask for it here
dnf download $dnf_opts --resolve "kernel-${kver}" "kernel-modules-extra-${kver}"
;;
fedora)
VERSION_ID=$(. /etc/os-release; echo $VERSION_ID)
previous_version_id=$((VERSION_ID - 1))
dnf download --releasever "${previous_version_id}" --resolve \
--disablerepo=* --enablerepo=updates --enablerepo=fedora kernel
kver=$(rpm -qp --qf '%{EVR}' ./kernel-core*rpm)
;;
*)
echo "Unknown OS_ID: ${OS_ID}"
exit 1
;;
esac

# we only want to query repos once but need the info on multiple boots, so write out state to /var
if [ ! -f /var/kola-kernel.evr ]; then
case "$OS_ID" in
rhcos|scos|rhel|centos)
c9s_mirror="https://mirror.stream.centos.org/9-stream/BaseOS/${arch}/os"
# we're probably already on CentOS and running the latest kernel. so
# here we need to instead pick whatever the latest that's *not* the same
kver=$(dnf repoquery kernel --qf '%{EVR}' --repofrompath=tmp,"${c9s_mirror}" --disablerepo '*' --enablerepo tmp | \
grep -v "$(rpm -q kernel --qf '%{EVR}')" | tail -n1)
kver="${kver}.${arch}"
url="${c9s_mirror}/Packages/kernel"
;;
fedora)
# to get the version to use: koji latest-pkg f40 kernel
# XXX: once we can rely on dnf in FCOS, use repoquery also here
kver="6.8.5-301.fc40.${arch}"
url="https://kojipkgs.fedoraproject.org//packages/kernel/6.8.5/301.fc40/${arch}/kernel"
;;
*)
echo "Unknown OS_ID: ${OS_ID}"
exit 1
;;
esac
echo "$kver" > /var/kola-kernel.evr
echo "$url" > /var/kola-kernel.url
else
kver=$(cat /var/kola-kernel.evr)
url=$(cat /var/kola-kernel.url)
fi
echo "$kver" > /var/kola-kernel.evr

td=$(mktemp -d)
pushd ${td}
cat > Containerfile << EOF
FROM $imagespec
RUN rpm-ostree override replace \
$url-{,core-,modules-,modules-core-,modules-extra-}$kver.rpm && \
RUN rpm-ostree override replace /tmp/buildcontext/*rpm && \
rpm-ostree cleanup -m && \
ostree container commit
EOF
podman build --net=host -t "${derived_imagespec}" --squash .
podman build --volume $PWD:/tmp/buildcontext:z -t "${derived_imagespec}" --squash .
popd
}

Expand Down Expand Up @@ -141,7 +139,8 @@ case "${AUTOPKGTEST_REBOOT_MARK:-}" in
/tmp/autopkgtest-reboot 2
;;
2)
un=$(uname -r)
kver="$(cat /var/kola-kernel.evr).${arch}" # expected
un=$(uname -r) # detected
if test "$un" != "$kver"; then
echo "Expected kernel $kver but found $un"
exit 1
Expand Down

0 comments on commit ec24f20

Please sign in to comment.