Skip to content

Commit 9f43bb3

Browse files
committed
rebuild-todo: Add the --import-keys option
Allows to import PGP keys for packages source verification into the user's keyring before rebuilding packages (including support for offloaded builds).
1 parent bd8075b commit 9f43bb3

File tree

3 files changed

+80
-2
lines changed

3 files changed

+80
-2
lines changed

Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ BASH_SCRIPTS = \
99
aur/review \
1010
package/parse-submodules \
1111
package/pkgsearch \
12-
package/rebuild-todo
12+
package/rebuild-todo \
13+
package/pkggrep
1314

1415
PYTHON_SCRIPTS = \
1516
package/staging2testing \

package/pkggrep

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
3+
# SPDX-License-Identifier: GPL-2.0
4+
5+
set -eou pipefail
6+
7+
PROGNAME="${BASH_SOURCE[0]##*/}"
8+
9+
usage() {
10+
cat <<- _EOF_
11+
Usage: ${PROGNAME} [OPTIONS] expression
12+
13+
Does a full search on all files currently in the repository.
14+
This is useful if one wants to search for a symbol instead of a soname.
15+
For sonames please use 'sogrep'.
16+
17+
OPTIONS
18+
-h, --help Show this help text
19+
20+
Examples:
21+
$ ${PROGNAME} _ZN3fmt3v116detail10locale_refC1ISt6localeEERKT_
22+
_EOF_
23+
}
24+
25+
if ! ((${#})); then
26+
usage
27+
exit 0
28+
fi
29+
30+
SEARCH_EXPRESSION=""
31+
SEARCH_HOST="build.archlinux.org"
32+
33+
while ((${#})); do
34+
key="${1}"
35+
case ${key} in
36+
-h|--help)
37+
usage
38+
exit 0
39+
;;
40+
--)
41+
shift
42+
break
43+
;;
44+
-*)
45+
echo "invalid argument: $key"
46+
usage
47+
exit 1
48+
;;
49+
*)
50+
SEARCH_EXPRESSION="${key}"
51+
;;
52+
esac
53+
shift
54+
done
55+
56+
ssh "${SEARCH_HOST}" "parallel \"rg --files-with-matches --search-zip -- '${SEARCH_EXPRESSION}' {} && pacman -Qpq {}\" ::: /srv/ftp/pool/*/*.zst"

package/rebuild-todo

+22-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ usage() {
2727
-e, --edit Edit PKGBUILD before building. Default when todo type is "Task"
2828
-o, --offload Use offloaded builds
2929
-h, --help Show this help text
30-
--dry-run Show the offload-build and commitpkg being ran
30+
-d, --dry-run Show the offload-build and commitpkg being ran
31+
--import-keys Import PGP keys for packages source verification into the user's keyring
3132
--no-build Don't build PKGBUILD
3233
--no-publish Don't run commitpkg after building
3334
--no-bump Don't bump pkgrel before building (default bumps pkgrel)
@@ -63,6 +64,7 @@ STDIN=0
6364
NO_BUMP=0
6465
NO_BUILD=0
6566
PACKAGES=0
67+
IMPORT_KEYS=0
6668
NO_PUBLISH=0
6769
EDIT_PKGBUILD=0
6870
CONTINUE=0
@@ -112,6 +114,9 @@ while ((${#})); do
112114
-d|--dry-run)
113115
DRY=1
114116
;;
117+
--import-keys)
118+
IMPORT_KEYS=1
119+
;;
115120
--testing|--staging)
116121
REPO="$key"
117122
;;
@@ -219,6 +224,22 @@ read <&1
219224

220225
pkgctl repo clone "${packages[@]}"
221226

227+
if ((IMPORT_KEYS)); then
228+
echo "Importing PGP keys..."
229+
# Only add paths that actually have key(s) to import and ignore paths that don't, don't exit on error
230+
key_paths=($(find "${packages[@]/%//keys/pgp}" -type f 2>/dev/null || true))
231+
232+
if [[ "${#key_paths[@]}" -ne 0 ]]; then
233+
if [[ -z "$OFFLOAD" ]]; then
234+
cat "${key_paths[@]}" | gpg --import
235+
else
236+
cat "${key_paths[@]}" | ssh build.archlinux.org gpg --import
237+
fi
238+
else
239+
echo "No PGP key to import"
240+
fi
241+
fi
242+
222243
for pkg in "${packages[@]}"; do
223244
pushd "$pkg" &>/dev/null
224245

0 commit comments

Comments
 (0)