Use reinstall and distrosync instead of downgrade to cover more use-cases

This commit is contained in:
Lumir Balhar 2026-07-13 12:13:27 +02:00
commit a83a4480c0

View file

@ -20,12 +20,12 @@ PYVER=${VERSION}
SCRIPT_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
WORK_DIR=""
DOWNGRADED=false
PKGS_MODIFIED=false
cleanup() {
if [[ "$DOWNGRADED" == true ]]; then
if [[ "$PKGS_MODIFIED" == true ]]; then
echo ""
echo "=== Reverting package downgrade ==="
echo "=== Reverting package changes ==="
dnf history undo last -y 2>&1 || echo "WARNING: dnf history undo failed" >&2
fi
[[ -n "$WORK_DIR" ]] && rm -rf "$WORK_DIR"
@ -53,14 +53,10 @@ WORK_DIR=$(mktemp -d)
echo "=== Collecting PR build symbols ==="
python${PYVER} "$SCRIPT_DIR/collect_symbols.py" "${SCAN_ARGS[@]}" > "$WORK_DIR/new.json"
# Downgrade to the latest stable version in the distribution repos.
# If no older version is available, there is nothing to compare against → skip.
echo ""
echo "=== Available repos ==="
dnf repolist --all
echo ""
echo "=== Downgrading to the latest stable version in repos ==="
# Discover packages dynamically from the installed source RPM so we don't need
# to hardcode subpackage names — works regardless of which subpackages were built.
readarray -t PKGS < <(
@ -68,13 +64,24 @@ readarray -t PKGS < <(
awk -v src="python${PYVER}" '$1 ~ "^" src "-[0-9]" { print $2 }' |
sort -u
)
echo "Packages to downgrade: ${PKGS[*]}"
echo "Packages to install from stable repos: ${PKGS[*]}"
if ! dnf downgrade -y "${PKGS[@]}" 2>&1; then
echo "INFO: dnf downgrade failed or no stable version available; skipping comparison." >&2
exit 0
# Install the stable version from distribution repos, excluding the artifact repo
# that carries the PR build, so we always compare against what is publicly available.
#
# Strategy:
# 1. dnf reinstall — works when the PR did not bump NVR (same version in stable repos)
# 2. dnf distro-sync — fallback when the PR bumped NVR; installs the latest stable NVR
echo ""
echo "=== Installing stable version from repos ==="
if ! dnf reinstall -y --disablerepo=test-artifacts "${PKGS[@]}" 2>&1; then
echo "INFO: reinstall failed (NVR not in stable repos), falling back to distro-sync" >&2
if ! dnf distro-sync -y --disablerepo=test-artifacts "${PKGS[@]}" 2>&1; then
echo "INFO: distro-sync failed; no stable version available, skipping comparison." >&2
exit 0
fi
fi
DOWNGRADED=true
PKGS_MODIFIED=true
echo ""
echo "=== Collecting stable version symbols ==="