]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot: prefer IMAGE_VERSION from os-release as version string 20789/head
authorLennart Poettering <lennart@poettering.net>
Thu, 23 Sep 2021 15:48:26 +0000 (17:48 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 23 Sep 2021 15:48:26 +0000 (17:48 +0200)
If the field exists it's probably the best version we have for sorting,
since it will change on every single OS image update.

src/boot/efi/boot.c

index b0e16f710699958c5c305730b5790039678dc89d..d82d679a47d798d732b9b43093a627585089918b 100644 (file)
@@ -1956,7 +1956,7 @@ static VOID config_entry_add_linux(
 
         for (;;) {
                 _cleanup_freepool_ CHAR16 *os_name_pretty = NULL, *os_name = NULL, *os_id = NULL,
-                        *os_version = NULL, *os_version_id = NULL, *os_build_id = NULL;
+                        *os_version = NULL, *os_version_id = NULL, *os_build_id = NULL, *os_image_version = NULL;
                 _cleanup_freepool_ CHAR8 *content = NULL;
                 const CHAR8 *sections[] = {
                         (CHAR8 *)".osrel",
@@ -2028,16 +2028,28 @@ static VOID config_entry_add_linux(
                                 os_build_id = stra_to_str(value);
                                 continue;
                         }
+
+                        if (strcmpa((const CHAR8*) "IMAGE_VERSION", key) == 0) {
+                                FreePool(os_image_version);
+                                os_image_version = stra_to_str(value);
+                                continue;
+                        }
                 }
 
-                if ((os_name_pretty || os_name) && os_id && (os_version || os_version_id || os_build_id)) {
+                if ((os_name_pretty || os_name) && os_id && (os_image_version || os_version || os_version_id || os_build_id)) {
                         _cleanup_freepool_ CHAR16 *path = NULL;
 
                         path = PoolPrint(L"\\EFI\\Linux\\%s", f->FileName);
 
-                        entry = config_entry_add_loader(config, device, LOADER_LINUX, f->FileName, 'l',
-                                                        os_name_pretty ?: os_name, path,
-                                                        os_version ?: (os_version_id ? : os_build_id));
+                        entry = config_entry_add_loader(
+                                        config,
+                                        device,
+                                        LOADER_LINUX,
+                                        f->FileName,
+                                        /* key= */ 'l',
+                                        os_name_pretty ?: os_name,
+                                        path,
+                                        os_image_version ?: (os_version ?: (os_version_id ? : os_build_id)));
 
                         FreePool(content);
                         content = NULL;