Skip to content

Commit 17b93a8

Browse files
amscannegvisor-bot
authored andcommitted
Attempt to fix gpg package signing (redux).
The semantics for gpg seem to vary in subtle way across systems. This attempts to identify the key fingerprint on import, since listing the secret keys afterwards does not appear to have the intended effect. PiperOrigin-RevId: 432067329
1 parent 1a7f7a5 commit 17b93a8

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

tools/make_apt.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,14 @@ trap cleanup EXIT
8181
# is not found. This isn't actually a failure for us, because we don't require
8282
# the public key (this may be stored separately). The second import will succeed
8383
# because, in reality, the first import succeeded and it's a no-op.
84-
gpg "${gpg_opts[@]}" --import "${private_key}" || \
85-
gpg "${gpg_opts[@]}" --import "${private_key}"
86-
87-
# Select the private key version. For some versions of gpg, it seems like some
88-
# will fail with the "no default secret" error.
8984
declare keyid
90-
keyid="$(gpg --no-default-keyring --secret-keyring "${keyring}" --list-secret-keys | grep -E '^ ' | tail -1)"
85+
keyid=$(
86+
(gpg "${gpg_opts[@]}" --import "${private_key}" 2>&1 ||
87+
gpg "${gpg_opts[@]}" --import "${private_key}" 2>&1) |
88+
grep "secret key imported" |
89+
head -1 |
90+
cut -d':' -f2 |
91+
awk '{print $2;}')
9192
readonly keyid
9293

9394
# Copy the packages into the root.

0 commit comments

Comments
 (0)