[elbe-devel] [PATCH 19/20] rfs: use env_add feature in BuildEnv.debootstrap()

Torben Hohn torben.hohn at linutronix.de
Fri Oct 12 11:28:05 CEST 2018


setup proxy values using env_add, because messing with os.environ
is racy.

Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
 elbepack/rfs.py | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/elbepack/rfs.py b/elbepack/rfs.py
index ca1ed470..fd889410 100644
--- a/elbepack/rfs.py
+++ b/elbepack/rfs.py
@@ -98,22 +98,23 @@ class BuildEnv (object):
         primary_mirror = self.xml.get_primary_mirror(
             self.rfs.fname('/cdrom/targetrepo'))
 
+        env = {'LANG': 'C',
+               'LANGUAGE': 'C',
+               'LC_ALL': 'C',
+               'DEBIAN_FRONTEND': 'noninteractive',
+               'DEBCONF_NONINTERACTIVE_SEEN': 'true'}
+
         if self.xml.prj.has("mirror/primary_proxy"):
-            os.environ["no_proxy"] = "10.0.2.2,localhost,127.0.0.1"
             proxy = self.xml.prj.text("mirror/primary_proxy")
             proxy = proxy.strip().replace("LOCALMACHINE", "localhost")
-            os.environ["http_proxy"] = proxy
-            os.environ["https_proxy"] = proxy
-        else:
-            os.environ["no_proxy"] = ""
-            os.environ["http_proxy"] = ""
-            os.environ["https_proxy"] = ""
 
-        os.environ["LANG"] = "C"
-        os.environ["LANGUAGE"] = "C"
-        os.environ["LC_ALL"] = "C"
-        os.environ["DEBIAN_FRONTEND"] = "noninteractive"
-        os.environ["DEBONF_NONINTERACTIVE_SEEN"] = "true"
+            env.update({'no_proxy': '10.0.2.2,localhost,127.0.0.1',
+                        'http_proxy': proxy,
+                        'https_proxy': proxy})
+        else:
+            env.update({'no_proxy': '',
+                        'http_proxy': '',
+                        'https_proxy': ''})
 
         self.log.h2("debootstrap log")
 
@@ -136,7 +137,7 @@ class BuildEnv (object):
 
             try:
                 self.cdrom_mount()
-                self.log.do(cmd)
+                self.log.do(cmd, env_add=env)
             except CommandError:
                 cleanup = True
                 raise DebootstrapException()
@@ -162,7 +163,7 @@ class BuildEnv (object):
 
         try:
             self.cdrom_mount()
-            self.log.do(cmd)
+            self.log.do(cmd, env_add=env)
 
             ui = "/usr/share/elbe/qemu-elbe/" + self.xml.defs["userinterpr"]
 
@@ -177,9 +178,10 @@ class BuildEnv (object):
                     '/debootstrap/debootstrap --no-check-gpg --second-stage')
             else:
                 self.log.chroot(self.rfs.path,
-                                '/debootstrap/debootstrap --second-stage')
+                                '/debootstrap/debootstrap --second-stage',
+                                env_add=env)
 
-            self.log.chroot(self.rfs.path, 'dpkg --configure -a')
+            self.log.chroot(self.rfs.path, 'dpkg --configure -a',env_add=env)
 
         except CommandError:
             cleanup = True
-- 
2.11.0




More information about the elbe-devel mailing list