[elbe-devel] [PATCH 2/2] gpg: use env_add to set GNUPGHOME where gpg is called via log.do()

Torben Hohn torben.hohn at linutronix.de
Wed Apr 3 17:45:35 CEST 2019


gpg is called indirectly via reprepro or directly. all the time through
log.do() and it always uses the process wide environment.

Stop that, and pass GNUPGPHOME via env_add.

Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
 elbepack/finetuning.py  |  5 +++--
 elbepack/repomanager.py | 17 ++++++++++-------
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/elbepack/finetuning.py b/elbepack/finetuning.py
index ec5a69c6..d5f0da5c 100644
--- a/elbepack/finetuning.py
+++ b/elbepack/finetuning.py
@@ -413,8 +413,9 @@ class UpdatedAction(FinetuningAction):
 
             target.mkdir_p("/var/cache/elbe/gnupg", mode=0o700)
             with target:
-                os.environ['GNUPGHOME'] = target.path + "/var/cache/elbe/gnupg"
-                log.do("gpg --import " + target.path + "/pub.key")
+                env_add = {'GNUPGHOME': target.path + "/var/cache/elbe/gnupg"}
+                log.do("gpg --import " + target.path + "/pub.key",
+                       env_add=env_add)
 
         log.printo("generate base repo")
         arch = target.xml.text("project/arch", key="arch")
diff --git a/elbepack/repomanager.py b/elbepack/repomanager.py
index da62259b..3805efbb 100644
--- a/elbepack/repomanager.py
+++ b/elbepack/repomanager.py
@@ -163,23 +163,25 @@ class RepoBase(object):
             self.log.do(
                 'reprepro --export=force --basedir "' +
                 self.fs.path +
-                '" update')
+                '" update',
+                env_add={'GNUPGHOME': '/var/cache/elbe/gnupg'})
         else:
             for att in self.attrs:
                 self.log.do(
                     'reprepro --basedir "' +
                     self.fs.path +
                     '" export ' +
-                    att.codename)
+                    att.codename,
+                    env_add={'GNUPGHOME': '/var/cache/elbe/gnupg'})
 
     def finalize(self):
-        os.environ['GNUPGHOME'] = "/var/cache/elbe/gnupg"
         for att in self.attrs:
             self.log.do(
                 'reprepro --basedir "' +
                 self.fs.path +
                 '" export ' +
-                att.codename)
+                att.codename,
+                env_add={'GNUPGHOME': '/var/cache/elbe/gnupg'})
 
     def _includedeb(self, path, codename, component):
         if self.maxsize:
@@ -226,7 +228,8 @@ class RepoBase(object):
     def _removedeb(self, pkgname, codename):
         self.log.do(
             "reprepro --basedir %s remove %s %s" %
-            (self.fs.path, codename, pkgname))
+            (self.fs.path, codename, pkgname),
+            env_add={'GNUPGHOME': '/var/cache/elbe/gnupg'})
 
     def removedeb(self, pkgname, component="main"):
         self._removedeb(pkgname, self.repo_attr.codename)
@@ -234,7 +237,8 @@ class RepoBase(object):
     def _removesrc(self, srcname, codename):
         self.log.do(
             "reprepro --basedir %s removesrc %s %s" %
-            (self.fs.path, codename, srcname))
+            (self.fs.path, codename, srcname),
+            env_add={'GNUPGHOME': '/var/cache/elbe/gnupg'})
 
     def removesrc(self, path, component="main"):
         for p in Deb822.iter_paragraphs(file(path)):
@@ -242,7 +246,6 @@ class RepoBase(object):
                 self._removesrc(p['Source'], self.repo_attr.codename)
 
     def _remove(self, path, codename, component):
-        os.environ['GNUPGHOME'] = "/var/cache/elbe/gnupg"
         for p in Deb822.iter_paragraphs(file(path)):
             if 'Source' in p:
                 self._removesrc(p['Source'], codename)
-- 
2.11.0




More information about the elbe-devel mailing list