From e609a840c732f093bdb0ab1ce9948c0cfd7f9ea9 Mon Sep 17 00:00:00 2001 From: yuvipanda Date: Thu, 19 Jul 2018 18:38:58 -0700 Subject: [PATCH] Install gpg2 if required when adding apt keys Not installed by default in many docker containers --- bootstrap/bootstrap.py | 3 +-- tljh/apt.py | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bootstrap/bootstrap.py b/bootstrap/bootstrap.py index 9654ada..02a9bfc 100644 --- a/bootstrap/bootstrap.py +++ b/bootstrap/bootstrap.py @@ -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]) diff --git a/tljh/apt.py b/tljh/apt.py index d6ac08e..b155124 100644 --- a/tljh/apt.py +++ b/tljh/apt.py @@ -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)