[elbe-devel] [PATCH 2/2] Assert that /etc/apt/trusted.gpg.d exists in VirtApt

dion at linutronix.de dion at linutronix.de
Thu Jun 27 17:58:22 CEST 2019


From: Olivier Dion <dion at linutronix.de>

Signed-off-by: Olivier Dion <dion at linutronix.de>
---
 elbepack/virtapt.py | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/elbepack/virtapt.py b/elbepack/virtapt.py
index e382c688..a3b66532 100644
--- a/elbepack/virtapt.py
+++ b/elbepack/virtapt.py
@@ -173,11 +173,12 @@ class VirtApt(object):
 
     def setup_gpg(self):
         ring_path = os.path.join(self.projectpath, "etc/apt/trusted.gpg")
-        if not os.path.isdir("/etc/apt/trusted.gpg.d"):
-            print("/etc/apt/trusted.gpg.d doesn't exist")
-            print("apt-get install debian-archive-keyring may "
-                  "fix this problem")
-            sys.exit(20)
+        trusted_dir = "/etc/apt/trusted.gpg.d"
+        err_msg = ("%s doesn't exist\n"
+                   "apt-get install debian-archive-keyring may "
+                   "fix this problem" % trusted_dir)
+
+        assert os.path.isdir(trusted_dir), err_msg
 
         if os.path.exists("/etc/apt/trusted.gpg"):
             system('cp /etc/apt/trusted.gpg "%s"' % ring_path)
@@ -186,13 +187,13 @@ class VirtApt(object):
                       '--trust-model always --no-default-keyring ' \
                       '--homedir "%s"' % (ring_path, self.projectpath)
 
-        trustkeys = os.listdir("/etc/apt/trusted.gpg.d")
+        trustkeys = os.listdir(trusted_dir)
         for key in trustkeys:
             print("Import %s: " % key)
             try:
                 system('gpg %s --import "%s"' % (
                     gpg_options,
-                    os.path.join("/etc/apt/trusted.gpg.d", key)))
+                    os.path.join(trusted_dir, key)))
             except CommandError:
                 print("adding elbe-pubkey to keyring failed")
 
-- 
2.11.0




More information about the elbe-devel mailing list