]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
distributions: try reading /etc/os-release first
authorLuca Boccassi <bluca@debian.org>
Wed, 7 Aug 2024 22:35:39 +0000 (23:35 +0100)
committerLuca Boccassi <bluca@debian.org>
Thu, 8 Aug 2024 12:00:21 +0000 (13:00 +0100)
It might be a local modification by an image builder, read it first
as per specification instructions

mkosi/distributions/__init__.py

index f801414b0a2de685965fb954a6a3198e6d6f8635..c2d24f57dc27e416967037590420736df0029efb 100644 (file)
@@ -163,9 +163,12 @@ class Distribution(StrEnum):
 
 def detect_distribution() -> tuple[Optional[Distribution], Optional[str]]:
     try:
-        os_release = read_env_file("/usr/lib/os-release")
+        os_release = read_env_file("/etc/os-release")
     except FileNotFoundError:
-        return None, None
+        try:
+            os_release = read_env_file("/usr/lib/os-release")
+        except FileNotFoundError:
+            return None, None
 
     dist_id = os_release.get("ID", "linux")
     dist_id_like = os_release.get("ID_LIKE", "").split()