From a15dad4b17644f29edfe336de4eb5063ab012c5f Mon Sep 17 00:00:00 2001 From: Bernhard Suttner Date: Fri, 2 Aug 2024 16:55:17 +0200 Subject: [PATCH] WIP: fix repofile.py - the /etc/apt/trusted.gpg.d dir may not exist --- src/rhsm/repofile.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/rhsm/repofile.py b/src/rhsm/repofile.py index bf613e4b74..9c56886136 100644 --- a/src/rhsm/repofile.py +++ b/src/rhsm/repofile.py @@ -515,13 +515,17 @@ def fix_content(self, content): # 'Signed-By': look for pulp public-key in '/etc/apt/trusted.gpg.d/' keypath = "/etc/apt/trusted.gpg.d/" - keyfiles = [ - os.path.join(keypath, f) - for f in os.listdir(keypath) - if os.path.isfile(os.path.join(keypath, f)) - and (f.startswith("orcharhino_") or f.startswith("pulp_") or f.startswith("client")) - and (f.endswith(".gpg") or f.endswith(".asc")) - ] + if os.path.exists(keypath) and os.path.isdir(keypath): + keyfiles = [ + os.path.join(keypath, f) + for f in os.listdir(keypath) + if os.path.isfile(os.path.join(keypath, f)) + and (f.startswith("orcharhino_") or f.startswith("pulp_") or f.startswith("client")) + and (f.endswith(".gpg") or f.endswith(".asc")) + ] + else: + keyfiles = [] + orcharhino_keyfile = None if len(keyfiles) > 1: orcharhino_keyfile = keyfiles[0]