Skip to content

Commit c97fc64

Browse files
committed
Use/prefer dnf5 if available
Arch has only dnf5, without dnf -> dnf5 symlink, so try to use dnf5. But also, prefer versioned name if available, as that simplifies version-dependent parts (no need to call --version for example).
1 parent 6dca8b6 commit c97fc64

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

package-managers/qubes-download-dom0-updates.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,17 @@ if [ -z "$UPDATE_ACTION" ]; then
6868
UPDATE_ACTION=upgrade
6969
fi
7070

71-
if type dnf >/dev/null 2>&1; then
72-
UPDATE_CMD=dnf
71+
if type dnf >/dev/null 2>&1 || type dnf5 >/dev/null 2>&1; then
72+
if type dnf5 >/dev/null 2>&1; then
73+
UPDATE_CMD=dnf5
74+
else
75+
UPDATE_CMD=dnf
76+
fi
7377
UPDATE_ARGUMENTS+=(--noplugins -y)
7478
CLEAN_OPTS+=(--noplugins -y)
7579
"$UPDATE_CMD" "${OPTS[@]}" "$UPDATE_ACTION" --help | grep -q best && UPDATE_ARGUMENTS+=(--best)
7680
"$UPDATE_CMD" "${OPTS[@]}" "$UPDATE_ACTION" --help | grep -q allowerasing && UPDATE_ARGUMENTS+=(--allowerasing)
77-
if "$UPDATE_CMD" --version | grep -q dnf5 && [ "$CHECK_ONLY" = "1" ]; then
81+
if [ "$UPDATE_CMD" = "dnf5" ] && [ "$CHECK_ONLY" = "1" ]; then
7882
UPDATE_ACTION=check-upgrade
7983
fi
8084
else

qubes-rpc/qvm-template-repo-query

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,13 @@ while read -r line; do
4545
fi
4646
done < "$repodir/template.repo"
4747

48+
if ! DNF=$(command -v dnf5 dnf dnf4 | head -1); then
49+
echo "ERROR: dnf command is missing, please use newer template for your UpdateVM to download templates." >&2
50+
echo "You can choose any Fedora version, Debian 11 (or newer), or any other based on those (like Whonix 16)." >&2
51+
exit 1
52+
fi
4853
DNF5=false
49-
if [ "$(readlink /usr/bin/dnf)" = "dnf5" ]; then
54+
if [[ "$DNF" = *"/dnf5" ]]; then
5055
DNF5=true
5156
fi
5257

@@ -58,11 +63,6 @@ if ! $DNF5; then
5863
OPTS+=("--setopt=pluginpath=/usr/lib/qubes/dnf-plugins")
5964
fi
6065

61-
if ! command -v dnf >/dev/null; then
62-
echo "ERROR: dnf command is missing, please use newer template for your UpdateVM to download templates." >&2
63-
echo "You can choose any Fedora version, Debian 11 (or newer), or any other based on those (like Whonix 16)." >&2
64-
exit 1
65-
fi
6666

6767
# This creates the hashfile if it doesn't exist, and keep the ctime and mtime
6868
# unchanged otherwise.
@@ -76,9 +76,9 @@ RET=0
7676

7777
if [ "$1" = "query" ]; then
7878
if $DNF5; then
79-
dnf repoquery "${OPTS[@]}" --qf='%{name}|%{epoch}|%{version}|%{release}|%{repoid}|%{downloadsize}|%{buildtime}|%{license}|%{url}|%{summary}|%{description}|\n' "$SPEC"
79+
$DNF repoquery "${OPTS[@]}" --qf='%{name}|%{epoch}|%{version}|%{release}|%{repoid}|%{downloadsize}|%{buildtime}|%{license}|%{url}|%{summary}|%{description}|\n' "$SPEC"
8080
else
81-
dnf repoquery "${OPTS[@]}" --qf='%{name}|%{epoch}|%{version}|%{release}|%{repoid}|%{downloadsize}|%{buildtime}|%{license}|%{url}|%{summary}|%{description}|' "$SPEC"
81+
$DNF repoquery "${OPTS[@]}" --qf='%{name}|%{epoch}|%{version}|%{release}|%{repoid}|%{downloadsize}|%{buildtime}|%{license}|%{url}|%{summary}|%{description}|' "$SPEC"
8282
fi
8383
RET="$?"
8484
elif [ "$1" = "download" ]; then
@@ -88,23 +88,23 @@ elif [ "$1" = "download" ]; then
8888
# downloaded, go to the next one. The intention is to retry on interrupted
8989
# connection, but skip mirrors that are not synchronized yet.
9090
declare -a urls=()
91-
if $DNF5 && dnf download --help | grep -q allmirrors; then
91+
if $DNF5 && $DNF download --help | grep -q allmirrors; then
9292
# The smartest case. DNF5 on Fedora 41 with --allmirrors patch
93-
space_separated_urls="$(dnf download "${OPTS[@]}" --url --allmirrors "$SPEC")"
93+
space_separated_urls="$($DNF download "${OPTS[@]}" --url --allmirrors "$SPEC")"
9494
readarray -d ' ' -t urls <<<"$space_separated_urls"
9595
urls=( $(shuf -e "${urls[@]}") )
9696
elif $DNF5; then
9797
# The middle case. DNF5 on Fedora 41 before --allmirror patch
9898
# TODO: Phase out after DNF5 --allmirrors patch is released
99-
url="$(dnf download "${OPTS[@]}" --url "$SPEC")"
99+
url="$($DNF download "${OPTS[@]}" --url "$SPEC")"
100100
urls=("$url")
101101
else
102102
# The old DNF4 on Fedora 40 and other old templates
103103
# use vendored 'downloadurl' dnf-plugin (fork of 'download' plugin),
104104
# to print all mirrors.
105105
# TODO: Phase out after DNF4 is EOL
106106
OPTS+=("--setopt=pluginpath=/usr/lib/qubes/dnf-plugins")
107-
urls="$(dnf downloadurl "${OPTS[@]}" --url --all-mirrors "$SPEC" | shuf)"
107+
urls="$($DNF downloadurl "${OPTS[@]}" --url --all-mirrors "$SPEC" | shuf)"
108108
readarray -t urls <<<"$urls"
109109
fi
110110
downloaded=0

0 commit comments

Comments
 (0)