From: Lennart Poettering Date: Thu, 23 Sep 2021 15:48:26 +0000 (+0200) Subject: boot: prefer IMAGE_VERSION from os-release as version string X-Git-Tag: v250-rc1~629^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8e8415e0d5d6714491180abe4e7d058f93bdf1c9;p=thirdparty%2Fsystemd.git boot: prefer IMAGE_VERSION from os-release as version string If the field exists it's probably the best version we have for sorting, since it will change on every single OS image update. --- diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index b0e16f71069..d82d679a47d 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -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;