From d1f27749a9345b3f5134b35262bfc190400fdfd8 Mon Sep 17 00:00:00 2001 From: WillyPillow Date: Fri, 3 Jul 2020 02:04:55 +0800 Subject: [PATCH] New qrexec calls for interacting with template repos. See for details. --- qubes-rpc/qubes.TemplateDownload | 3 +++ qubes-rpc/qubes.TemplateSearch | 3 +++ qubes-rpc/qvm-template-repo-query | 42 +++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100755 qubes-rpc/qubes.TemplateDownload create mode 100755 qubes-rpc/qubes.TemplateSearch create mode 100755 qubes-rpc/qvm-template-repo-query diff --git a/qubes-rpc/qubes.TemplateDownload b/qubes-rpc/qubes.TemplateDownload new file mode 100755 index 0000000..7f0097b --- /dev/null +++ b/qubes-rpc/qubes.TemplateDownload @@ -0,0 +1,3 @@ +#!/usr/bin/bash + +exec /usr/lib/qubes/qvm-template-repo-query download diff --git a/qubes-rpc/qubes.TemplateSearch b/qubes-rpc/qubes.TemplateSearch new file mode 100755 index 0000000..fe79b29 --- /dev/null +++ b/qubes-rpc/qubes.TemplateSearch @@ -0,0 +1,3 @@ +#!/usr/bin/bash + +exec /usr/lib/qubes/qvm-template-repo-query query diff --git a/qubes-rpc/qvm-template-repo-query b/qubes-rpc/qvm-template-repo-query new file mode 100755 index 0000000..02060b7 --- /dev/null +++ b/qubes-rpc/qvm-template-repo-query @@ -0,0 +1,42 @@ +#!/usr/bin/bash + +OPTS=() +SPEC= +while IFS= read -r line; do + if [ "$line" = "---" ]; then + break + fi + case "$line" in + --enablerepo=*|\ + --disablerepo=*|\ + --repoid=*|\ + --repofrompath=*|\ + --releasever=*) + OPTS+=("$line") + ;; + *) + SPEC="$line" + ;; + esac +done + +repodir=$(mktemp -d) +cat > "$repodir/template.repo" + +OPTS+=("--setopt=reposdir=${repodir}") +OPTS+=("--quiet") + +RET=0 + +if [ "$1" = "query" ]; then + # shellcheck disable=SC2068 + dnf repoquery ${OPTS[@]} --qf='%{name}:%{epoch}:%{version}:%{release}:%{reponame}:%{downloadsize}:%{summary}' "$SPEC" + RET="$?" +elif [ "$1" = "download" ]; then + # shellcheck disable=SC2068 + curl -L "$(dnf download ${OPTS[@]} --url "$SPEC" | shuf -n 1)" -o - + RET="$?" +fi + +rm -r "$repodir" +exit "$RET"