Skip to content

Commit

Permalink
tests/hetzner: Make getting GPG key ID more robust
Browse files Browse the repository at this point in the history
GnuPG has a --with-colons flag, so we don't need to use a complicated
sed expression to extract the key ID.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
  • Loading branch information
aszlig committed Jan 2, 2017
1 parent b09e618 commit 9c3aecb
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions tests/hetzner-backend/repository.nix
Expand Up @@ -47,12 +47,10 @@ let
${pkgs.gnupg}/bin/gpg2 --batch --gen-key template
${pkgs.gnupg}/bin/gpg2 --list-secret-keys | \
sed -n -re 's,^sec +[^/]*/([^ ]+).*,\1,p' \
> "$secretKeyId"
${pkgs.gnupg}/bin/gpg2 --list-public-keys | \
sed -n -re 's,^pub +[^/]*/([^ ]+).*,\1,p' \
> "$publicKeyId"
${pkgs.gnupg}/bin/gpg2 --list-secret-keys --with-colons | \
grep '^sec:' | cut -d: -f5 > "$secretKeyId"
${pkgs.gnupg}/bin/gpg2 --list-public-keys --with-colons | \
grep '^pub:' | cut -d: -f5 > "$publicKeyId"
${pkgs.gnupg}/bin/gpg2 --export \
"$(< "$publicKeyId")" \
> "$publicKey"
Expand Down

0 comments on commit 9c3aecb

Please sign in to comment.