Skip to content

Commit 28cb1e7

Browse files
christian-heuselAntiz96
authored andcommitted
feat: Add "packages-signed-by" script
Signed-off-by: Christian Heusel <[email protected]>
1 parent 2eb2c68 commit 28cb1e7

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ BASH_SCRIPTS = \
88
admin/checkservices \
99
aur/review \
1010
package/greposcope \
11+
package/packages-signed-by \
1112
package/parse-submodules \
1213
package/pkggrep \
1314
package/pkgsearch \

package/packages-signed-by

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#!/bin/bash
2+
3+
# SPDX-License-Identifier: GPL-2.0-or-later
4+
5+
set -eou pipefail
6+
7+
PROGNAME="${BASH_SOURCE[0]##*/}"
8+
9+
usage() {
10+
cat <<- _EOF_
11+
Usage: ${PROGNAME} [OPTIONS] [KEY-ID]
12+
13+
Does a search on all signatures files currently in the repository and
14+
prints the packages files for if the signature was done by <KEY-ID>.
15+
16+
Requires GNU Parallel, awk, bsdtar and Sequoia's sq on the remote host.
17+
18+
19+
OPTIONS
20+
-h, --help Show this help text
21+
-o, --output-format Set the output format
22+
Possible values include 'filename' and 'packagename' (default).
23+
24+
Examples:
25+
Get all packagefiles signed by given key
26+
$ ${PROGNAME} F00B96D15228013FFC9C9D0393B11DAA4C197E3D
27+
28+
Get a rebuild list for all packages signed by given key
29+
$ ${PROGNAME} --output-format packagename F00B96D15228013FFC9C9D0393B11DAA4C197E3D | xargs expac -S "%e" | sort --unique
30+
_EOF_
31+
}
32+
33+
in_array() {
34+
local needle=$1; shift
35+
local item
36+
for item in "$@"; do
37+
[[ $item = "$needle" ]] && return 0 # Found
38+
done
39+
return 1 # Not Found
40+
}
41+
42+
KEY_ID=""
43+
SEARCH_HOST="build.archlinux.org"
44+
OUTPUT_FORMAT="filename"
45+
VALID_OUTPUT_FORMATS=(
46+
'filename'
47+
'packagename'
48+
)
49+
50+
while ((${#})); do
51+
key="${1}"
52+
case ${key} in
53+
-h|--help)
54+
usage
55+
exit 0
56+
;;
57+
-o|--output-format)
58+
format="$2"
59+
(( $# <= 1 )) && echo "missing argument for ${key}" && exit 1
60+
61+
if ! in_array "${format}" "${VALID_OUTPUT_FORMATS[@]}"; then
62+
echo "Unknown output format: ${format}"
63+
exit 1
64+
fi
65+
shift 1
66+
OUTPUT_FORMAT="${format}"
67+
;;
68+
--)
69+
shift
70+
break
71+
;;
72+
-*)
73+
echo "invalid argument: $key"
74+
usage
75+
exit 1
76+
;;
77+
*)
78+
KEY_ID="${key}"
79+
;;
80+
esac
81+
shift
82+
done
83+
84+
parallel_common_command=(
85+
# extract signature information
86+
"sq --home none --cert-store none inspect {} | "
87+
# Get the key id
88+
"awk '/Alleged signer:/{getline; print}' | "
89+
# strip all whitespace
90+
"xargs | "
91+
# check for keyid and discard output
92+
"grep --quiet -- '${KEY_ID}'"
93+
)
94+
95+
case $OUTPUT_FORMAT in
96+
filename)
97+
# shellcheck disable=SC2029
98+
ssh "${SEARCH_HOST}" "parallel \"${parallel_common_command[*]} && echo {/.}\" ::: /srv/ftp/pool/packages/*.pkg.tar.*.sig"
99+
;;
100+
packagename)
101+
# shellcheck disable=SC2016 # $3 is to be used by awk and not bash
102+
awk_search='/pkgname/ { print \$3 }'
103+
104+
# shellcheck disable=SC2029
105+
ssh "${SEARCH_HOST}" "parallel \"${parallel_common_command[*]} && bsdtar xfO {.} .BUILDINFO | awk '${awk_search}'\" ::: /srv/ftp/pool/packages/*.pkg.tar.*.sig"
106+
;;
107+
esac

0 commit comments

Comments
 (0)