I'm creating two empty files which shall serve as primary keyring and trustdb:
echo -n > /tmp/gpgpyjOTOJX
echo -n > /tmp/gpgpy-tdbN200eB
I then try to import a key into this keyring:
'gpg2' '--command-fd' '0' '--with-fingerprint' '--list-options'
'--no-default-keyring' '--trustdb-name' '/tmp/gpgpy-tdbN200eB' '--status-fd' '2'
'--quiet' '--batch' '--primary-keyring' '/tmp/gpgpyjOTOJX' '--fixed-list-mode'
'--no-tty' '--with-colons' '--use-agent' '--import' < /tmp/k.asc
gpg, however fails:
gpg: Fatal: /tmp/gpgpy-tdbN200eB: invalid trustdb
Funnily enough: If run a second time, it doesn't complain.
On a related note: I realise that gpg doesn't like an empty trustdb file. It
works fine if I give a non-existing filename. Then gpg happily creates that file
for me. That behaviour is obviously different from the primary keyring file.
I expected gpg to be more coherent there.
I wished gpg would accept that empty file for its trustdb because then I can
have the file managed by, say, Python's NamedTempFile. Now I need to implement
logic for cleaning up myself.