Skip to content

Commit 683d9b0

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 10d7f48 commit 683d9b0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

package/rebuild-todo

+21
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ usage() {
2828
-o, --offload Use offloaded builds
2929
-h, --help Show this help text
3030
-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+
mapfile -d '' key_paths < <(find "${packages[@]/%//keys/pgp}" -type f -print0 2>/dev/null) || true
231+
232+
if ((${#key_paths[@]})); then
233+
cat "${key_paths[@]}" | if [[ -z "$OFFLOAD" ]]; then
234+
gpg --import
235+
else
236+
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)