Install gpg2 if required when adding apt keys

Not installed by default in many docker containers
This commit is contained in:
yuvipanda
2018-07-19 18:38:58 -07:00
parent fc0ecb6699
commit e609a840c7
2 changed files with 4 additions and 2 deletions

View File

@@ -11,6 +11,9 @@ def trust_gpg_key(key):
key is a GPG public key (bytes) that can be passed to apt-key add via stdin.
"""
# If gpg2 doesn't exist, install it.
if not os.path.exists('/usr/bin/gpg2'):
install_packages(['gnupg2'])
subprocess.run(['apt-key', 'add', '-'], input=key, check=True)