From b0edd5f2095dc8abcd966bc46200139603a38c53 Mon Sep 17 00:00:00 2001 From: WillyPillow Date: Wed, 29 Jul 2020 19:46:18 +0800 Subject: [PATCH] qubes.Template*: Add --refresh option and allow DNF cache to be used. --- qubes-rpc/qvm-template-repo-query | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/qubes-rpc/qvm-template-repo-query b/qubes-rpc/qvm-template-repo-query index affb2c1..9391649 100755 --- a/qubes-rpc/qvm-template-repo-query +++ b/qubes-rpc/qvm-template-repo-query @@ -10,7 +10,8 @@ while IFS= read -r line; do --enablerepo=*|\ --disablerepo=*|\ --repoid=*|\ - --releasever=*) + --releasever=*|\ + --refresh) OPTS+=("$line") ;; *) @@ -25,13 +26,22 @@ cat > "$repodir/template.repo" OPTS+=("--setopt=reposdir=${repodir}") OPTS+=("--quiet") +# This creates the hashfile if it doesn't exist, and keep the ctime and mtime +# unchanged otherwise. +# We then copy the {c,m}time to the repo config. +# This allows DNF caching to work properly. +hashfile="/tmp/qvm-template-$(b2sum "$repodir/template.repo" | cut -f1 -d' ')" +touch -a "$hashfile" +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" RET="$?" elif [ "$1" = "download" ]; then - curl --silent -L "$(dnf download "${OPTS[@]}" --url "$SPEC" | shuf -n 1)" -o - + url="$(dnf download "${OPTS[@]}" --url "$SPEC" | shuf -n 1)" + curl --silent -L "$url" -o - RET="$?" fi