]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
build: check for BUILD_ID/VERSION_ID before adding systemd-boot workaround
authorLuca Boccassi <luca.boccassi@microsoft.com>
Tue, 18 Jan 2022 00:08:54 +0000 (00:08 +0000)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 18 Jan 2022 10:36:11 +0000 (10:36 +0000)
Instead of hard-coding the debian release, which breaks booting on
testing/bookworm, check os-release to see if BUILD_ID or VERSION_ID
are actually there.

mkosi/__init__.py

index 4a3a62ab679ca980f55ec7f671319e1884fb2e2c..d7583a0e03c4548e85f7736fae419b419c9d2fdd 100644 (file)
@@ -2733,12 +2733,13 @@ def install_debian_or_ubuntu(args: MkosiArgs, root: Path, *, do_run_build_script
         with dpkg_nodoc_conf.open("w") as f:
             f.writelines(f"path-exclude {d}/*\n" for d in doc_paths)
 
-    if (not do_run_build_script and args.bootable and args.with_unified_kernel_images and
-       args.distribution == Distribution.debian and args.release == "unstable" and args.base_image is None):
+    if not do_run_build_script and args.bootable and args.with_unified_kernel_images and args.base_image is None:
         # systemd-boot won't boot unified kernel images generated without a BUILD_ID or VERSION_ID in
-        # /etc/os-release.
-        with root.joinpath("etc/os-release").open("a") as f:
-            f.write("BUILD_ID=unstable\n")
+        # /etc/os-release. Build one with the mtime of os-release if we don't find them.
+        with root.joinpath("etc/os-release").open("r+") as f:
+            os_release = f.read()
+            if "VERSION_ID" not in os_release and "BUILD_ID" not in os_release:
+                f.write(f"BUILD_ID=mkosi-{args.release}\n")
 
     invoke_apt(args, do_run_build_script, root, "install", extra_packages)