Skip to content

Commit

Permalink
Fix DNF5 repoquery
Browse files Browse the repository at this point in the history
  • Loading branch information
alimirjamali committed Sep 27, 2024
1 parent 468e15f commit b06506a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions qubes-rpc/qvm-template-repo-query
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,23 @@ 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,
# try to download from the first one - if download failed but anything was
# 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)"
if dnf --version | grep -q dnf5; then
urls="$(dnf download "${OPTS[@]}" --url -q "$SPEC")"
else
urls="$(dnf downloadurl "${OPTS[@]}" --url --all-mirrors "$SPEC" | shuf)"
fi
readarray -t urls <<<"$urls"
downloaded=0
status_file="$repodir/download-status.tmp"
Expand Down

0 comments on commit b06506a

Please sign in to comment.