]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Use http_proxy and https_proxy from environment
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 13 Jul 2023 07:25:09 +0000 (09:25 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 13 Jul 2023 07:25:09 +0000 (09:25 +0200)
We generally don't use environment variables passed to the process,
but let's be a little more relaxed on this policy and make sure we
use any configured proxy variables so mkosi works out of the box on
servers behind a proxy.

mkosi/state.py

index 48f556b907143d1bf85a2eb0ef80e61157345a69..e29175e227cc8d675d53552a2707e378b202ee3c 100644 (file)
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: LGPL-2.1+
 
 import importlib
+import os
 import tempfile
 from pathlib import Path
 
@@ -23,9 +24,13 @@ class MkosiState:
 
         self.environment = self.config.environment.copy()
         if self.config.image_id is not None:
-            self.environment['IMAGE_ID'] = self.config.image_id
+            self.environment["IMAGE_ID"] = self.config.image_id
         if self.config.image_version is not None:
-            self.environment['IMAGE_VERSION'] = self.config.image_version
+            self.environment["IMAGE_VERSION"] = self.config.image_version
+        if (proxy := os.environ.get("http_proxy")):
+            self.environment["http_proxy"] = proxy
+        if (proxy := os.environ.get("https_proxy")):
+            self.environment["https_proxy"] = proxy
 
         try:
             distro = str(self.config.distribution)