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

@@ -28,8 +28,7 @@ def main():
print('Setting up hub environment')
initial_setup = True
subprocess.check_output(['apt-get', 'update', '--yes'])
# gnupg2 is needed for nodesource to work
subprocess.check_output(['apt-get', 'install', '--yes', 'python3', 'python3-venv', 'gnupg2'])
subprocess.check_output(['apt-get', 'install', '--yes', 'python3', 'python3-venv'])
os.makedirs(hub_prefix, exist_ok=True)
subprocess.check_output(['python3', '-m', 'venv', hub_prefix])

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)