[elbe-devel] [PATCH 09/20] rpcaptcache: set os.environ upon manager process startup

Torben Hohn torben.hohn at linutronix.de
Fri Oct 12 11:27:55 CEST 2018


ChRootFilesystem.enter_chroot() is only called from initcode of the
RPCAptCache. It sets environment variables in os.environ.

Move setup of os.environ into a newly created inititializer of the
Manager Process.

Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
 elbepack/efilesystem.py |  4 ----
 elbepack/rpcaptcache.py | 14 +++++++++++++-
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/elbepack/efilesystem.py b/elbepack/efilesystem.py
index e6a8c2ab..d7972ea7 100644
--- a/elbepack/efilesystem.py
+++ b/elbepack/efilesystem.py
@@ -246,10 +246,6 @@ class ChRootFilesystem(ElbeFilesystem):
     def enter_chroot(self):
         assert not self.inchroot
 
-        os.environ["LANG"] = "C"
-        os.environ["LANGUAGE"] = "C"
-        os.environ["LC_ALL"] = "C"
-
         os.chdir(self.path)
         self.inchroot = True
 
diff --git a/elbepack/rpcaptcache.py b/elbepack/rpcaptcache.py
index c5487aaf..c6d502de 100644
--- a/elbepack/rpcaptcache.py
+++ b/elbepack/rpcaptcache.py
@@ -265,7 +265,19 @@ class RPCAPTCache(InChRootObject):
 
 
 class MyMan(BaseManager):
-    pass
+    @staticmethod
+    def setup_env():
+        # setting values in os.environ is ok,
+        # because this is initialisaton code
+        #
+        # prepare to enter chroot, which might
+        # not have locales installed.
+        os.environ["LANG"] = "C"
+        os.environ["LANGUAGE"] = "C"
+        os.environ["LC_ALL"] = "C"
+
+    def start(self):
+        BaseManager.start(self,initializer=self.setup_env)
 
 
 MyMan.register("RPCAPTCache", RPCAPTCache)
-- 
2.11.0




More information about the elbe-devel mailing list