]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Added boot counting to unified kernels if /etc/kernel/tries exists
authorMichael A Cassaniti <michael@cassaniti.id.au>
Thu, 28 Jul 2022 07:40:55 +0000 (17:40 +1000)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 8 Aug 2022 08:31:46 +0000 (10:31 +0200)
See https://systemd.io/AUTOMATIC_BOOT_ASSESSMENT/ for details on boot counting

mkosi/__init__.py

index d6fa184b865dfb194257c1cb931f9aff12e1612e..7596d2be619f9ab4eec86284283545808e8009fa 100644 (file)
@@ -4060,12 +4060,17 @@ def install_unified_kernel(
                 image_id = f"mkosi-{args.distribution}"
                 partlabel = None
 
+            # See https://systemd.io/AUTOMATIC_BOOT_ASSESSMENT/#boot-counting
+            boot_count = ""
+            if root.joinpath("etc/kernel/tries").exists():
+                boot_count = f'+{root.joinpath("etc/kernel/tries").read_text().strip()}'
+
             if args.image_version:
-                boot_binary = root / prefix / f"EFI/Linux/{image_id}_{args.image_version}.efi"
+                boot_binary = root / prefix / f"EFI/Linux/{image_id}_{args.image_version}{boot_count}.efi"
             elif root_hash:
-                boot_binary = root / prefix / f"EFI/Linux/{image_id}-{kver}-{root_hash}.efi"
+                boot_binary = root / prefix / f"EFI/Linux/{image_id}-{kver}-{root_hash}{boot_count}.efi"
             else:
-                boot_binary = root / prefix / f"EFI/Linux/{image_id}-{kver}.efi"
+                boot_binary = root / prefix / f"EFI/Linux/{image_id}-{kver}{boot_count}.efi"
 
             if root.joinpath("etc/kernel/cmdline").exists():
                 boot_options = root.joinpath("etc/kernel/cmdline").read_text().strip()