diff --git a/tests/kola/rpm-ostree/kernel-replace b/tests/kola/rpm-ostree/kernel-replace index 3c2215ee6..31480edc0 100755 --- a/tests/kola/rpm-ostree/kernel-replace +++ b/tests/kola/rpm-ostree/kernel-replace @@ -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 } @@ -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