2020-07-02 20:04:55 +02:00
|
|
|
#!/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
|
2020-07-03 19:11:53 +02:00
|
|
|
dnf repoquery "${OPTS[@]}" --qf='%{name}:%{epoch}:%{version}:%{release}:%{reponame}:%{downloadsize}:%{summary}' "$SPEC"
|
2020-07-02 20:04:55 +02:00
|
|
|
RET="$?"
|
|
|
|
elif [ "$1" = "download" ]; then
|
2020-07-03 19:11:53 +02:00
|
|
|
curl -L "$(dnf download "${OPTS[@]}" --url "$SPEC" | shuf -n 1)" -o -
|
2020-07-02 20:04:55 +02:00
|
|
|
RET="$?"
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -r "$repodir"
|
|
|
|
exit "$RET"
|