I know that this is old, but since I spent some time finding a solution, I am going to share it.
GnuPG has always been a pain, when it comes to automation and there doesn't seem to be a way, to make it use the old keyring v4 format.
However it can be done by re-exporting the key. Here an ugly one-liner with the MariaDB repo as an example:
# cd /etc/apt/trusted.gpg.d/ && wget -q -O - https://mariadb.org/mariadb_release_signing_key.asc | \
gpg --no-default-keyring --keyring=$(pwd)/mariadb.gpg --batch --import - && \
gpg --no-default-keyring --keyring=$(pwd)/mariadb.gpg --batch --output $(pwd)/mariadb.gpg~ --export --yes && \
mv $(pwd)/mariadb.gpg~ $(pwd)/mariadb.gpg; chmod 644 $(pwd)/mariadb.gpg
This can be done much easier with apt-key
and its --keyring
option (tested on Debian Buster 10.7).
$ wget -q -O - https://mariadb.org/mariadb_release_signing_key.asc | \
sudo apt-key --keyring /etc/apt/trusted.gpg.d/mariadb.gpg add -
If you look at the apt-key
script you will find something similar to the one-liner above (but probably more robust).
Note that apt-key
will complain and fail, if you use the suffix .asc
instead of .gpg
for the trusted file. That seems to be a bug, that can be avoided with a previous touch
on the file.
apt-key
is deprecated – Hulbig