2 # dnf-repoquery-by-srpm [dnf-options...] srpm-name...
4 # List every package built from one of the given source RPMs
5 # (given by full name as in the SOURCERPM tag, e.g., glibc-2.31-4.fc32.src.rpm).
7 # This script's option parser is crude and assumes that every argument that
8 # doesn't begin with a dash is a source RPM name, so you must use the
9 # "--opt=val" form of dnf options, not "--opt val". Also, if you customize
10 # the query format, it must not contain an embedded newline or \x01.
12 # Ideally "dnf repoquery" would support arbitrary query tags like rpm
13 # (i.e., "rpm -qa SOURCERPM=...") and we wouldn't need this script.
21 orig_queryformat="%{name}-%{evr}.%{arch}"
26 orig_queryformat="${arg#--qf=}";;
28 orig_queryformat="${arg#--queryformat=}";;
30 dnf_options+=("$arg");;
32 # Hope . is the only character special in a basic regular expression that
33 # occurs in package filenames.
34 grep_options+=(-e $'\x01'"${arg//./\.}\$");;
38 real_queryformat="$orig_queryformat"$'\x01'"%{sourcerpm}"
40 dnf repoquery --queryformat="$real_queryformat" "${dnf_options[@]}" \
41 | { grep "${grep_options[@]}" || true; } \
42 | sed -e $'s,\x01.*$,,'