Skip to content

fix(apt): rewrite GPG setup script with native batch key generation - #5

Merged
mshafiee merged 1 commit into
mainfrom
chore/fix-gpg-setup-script
Jul 22, 2026
Merged

fix(apt): rewrite GPG setup script with native batch key generation#5
mshafiee merged 1 commit into
mainfrom
chore/fix-gpg-setup-script

Conversation

@mshafiee

Copy link
Copy Markdown
Contributor

What

Rewrites scripts/setup-gpg-keys.sh to use GPG's native batch key generation instead of fragile expect-based automation.

Why

The previous script used expect to drive gpg --edit-key interactively (for addkey and passwd). This was unreliable on macOS — it hung at interactive prompts, timed out, and never reliably set a passphrase on the subkey.

Changes

  • Single non-interactive call: gpg --batch --gen-key with a parameter file that generates both the primary RSA-4096 key and a sign-only subkey in one shot (Subkey-Type, Subkey-Usage: sign). No expect, no --edit-key, no hanging.
  • Passphrase generation: generates a random 256-bit passphrase (openssl rand -base64 32) and sets it on the key pair via the batch Passphrase: directive.
  • Passphrase export: writes the passphrase to /tmp/zurvan-gpg-passphrase.txt so the maintainer can copy it into the APT_SIGNING_PASSPHRASE GitHub Actions secret.
  • Secret subkey export: uses --pinentry-mode loopback --passphrase to export secret-subkey.asc non-interactively.
  • Updated public.key with the freshly generated key.

Tested

Ran end-to-end on macOS (GnuPG 2.4.8): primary key + subkey generated, both files exported, passphrase written. No interactive prompts, no timeouts.

- Replace fragile expect-based addkey/passwd automation with a single
  non-interactive gpg --batch --gen-key call that generates both the
  primary key and sign-only subkey in one shot.
- Generate a random passphrase (openssl rand -base64 32) and set it on
  the key pair via the batch Passphrase: directive.
- Export secret subkey using the generated passphrase with
  --pinentry-mode loopback.
- Write the passphrase to /tmp/zurvan-gpg-passphrase.txt for the
  maintainer to copy into the APT_SIGNING_PASSPHRASE GitHub secret.
- Update public.key with the freshly generated key.
@mshafiee
mshafiee merged commit 3d18b91 into main Jul 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant