From ba2d54e3a0cf5c4fb26db8e3ac4abf3507cb8c00 Mon Sep 17 00:00:00 2001 From: Ali Mirjamali Date: Fri, 27 Sep 2024 15:37:35 +0330 Subject: [PATCH] Fix DNF5 repoquery related: https://github.com/QubesOS/qubes-core-admin-client/pull/308 --- qubes-rpc/qvm-template-repo-query | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/qubes-rpc/qvm-template-repo-query b/qubes-rpc/qvm-template-repo-query index 2e78cb7c..75572f7a 100755 --- a/qubes-rpc/qvm-template-repo-query +++ b/qubes-rpc/qvm-template-repo-query @@ -49,7 +49,11 @@ touch -r "$hashfile" "$repodir/template.repo" RET=0 if [ "$1" = "query" ]; then - dnf repoquery "${OPTS[@]}" --qf='%{name}|%{epoch}|%{version}|%{release}|%{reponame}|%{downloadsize}|%{buildtime}|%{license}|%{url}|%{summary}|%{description}|' "$SPEC" + if dnf --version | grep -q dnf5; then + dnf repoquery "${OPTS[@]}" --qf='%{name}|%{epoch}|%{version}|%{release}|%{repoid}|%{downloadsize}|%{buildtime}|%{license}|%{url}|%{summary}|%{description}|\n' "$SPEC" + else + dnf repoquery "${OPTS[@]}" --qf='%{name}|%{epoch}|%{version}|%{release}|%{repoid}|%{downloadsize}|%{buildtime}|%{license}|%{url}|%{summary}|%{description}|' "$SPEC" + fi RET="$?" elif [ "$1" = "download" ]; then # Download/retry algorithm: take mirrors in random order. In this order, @@ -57,8 +61,17 @@ elif [ "$1" = "download" ]; then # downloaded - retry from the same one. If download failed and nothing was # downloaded, go to the next one. The intention is to retry on interrupted # connection, but skip mirrors that are not synchronized yet. - urls="$(dnf downloadurl "${OPTS[@]}" --url --all-mirrors "$SPEC" | shuf)" - readarray -t urls <<<"$urls" + if dnf --version | grep -q dnf5; then + if dnf download --help | grep -q allmirrors; then + urls="$(dnf download "${OPTS[@]}" --url --allmirrors -q "$SPEC" | shuf)" + else + urls="$(dnf download "${OPTS[@]}" --url -q "$SPEC")" + fi + readarray -d ' ' -t urls <<<"$urls" + else + urls="$(dnf downloadurl "${OPTS[@]}" --url --all-mirrors "$SPEC" | shuf)" + readarray -t urls <<<"$urls" + fi downloaded=0 status_file="$repodir/download-status.tmp" for url in "${urls[@]}"; do