core-agent-linux/qubes-rpc/qvm-template-repo-query

40 lines
821 B
Bash
Executable File

#!/usr/bin/bash
OPTS=()
SPEC=
while IFS= read -r line; do
if [ "$line" = "---" ]; then
break
fi
case "$line" in
--enablerepo=*|\
--disablerepo=*|\
--repoid=*|\
--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
dnf repoquery "${OPTS[@]}" --qf='%{name}|%{epoch}|%{version}|%{release}|%{reponame}|%{downloadsize}|%{buildtime}|%{license}|%{url}|%{summary}|%{description}|' "$SPEC"
RET="$?"
elif [ "$1" = "download" ]; then
curl -L "$(dnf download "${OPTS[@]}" --url "$SPEC" | shuf -n 1)" -o -
RET="$?"
fi
rm -r "$repodir"
exit "$RET"