@@ -45,8 +45,13 @@ while read -r line; do
4545 fi
4646done < " $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
4853DNF5=false
49- if [ " $( readlink /usr/bin/dnf ) " = " dnf5" ]; then
54+ if [[ " $DNF " = * " / dnf5" ] ]; then
5055 DNF5=true
5156fi
5257
@@ -58,11 +63,6 @@ if ! $DNF5; then
5863 OPTS+=(" --setopt=pluginpath=/usr/lib/qubes/dnf-plugins" )
5964fi
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.
7676
7777if [ " $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=" $? "
8484elif [ " $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