]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot: use BUILD_ID if VERSION_ID is not present 531/head
authorDavid Herrmann <dh.herrmann@gmail.com>
Thu, 9 Jul 2015 11:04:58 +0000 (13:04 +0200)
committerDavid Herrmann <dh.herrmann@gmail.com>
Thu, 9 Jul 2015 11:07:27 +0000 (13:07 +0200)
According to os-release(5), VERSION_ID is not mandatory and BUILD_ID only
needs to be unique underneath VERSION_ID. Therefore, assuming a missing
VERSION_ID field means 'empty', we can rely on BUILD_ID to be unique.

Use BUILD_ID if VERSION_ID is not present. This way, rolling-release
distros can still provide a proper os-release entry without crafting
random VERSION_ID strings.

This fixes #186.

src/boot/efi/boot.c

index 861adff29f7a9a17d0cec1911f59b8385338771e..827c11844c597412f51be41d3dd8b72e1d8dde11 100644 (file)
@@ -1517,6 +1517,7 @@ static VOID config_entry_add_linux( Config *config, EFI_LOADED_IMAGE *loaded_ima
                         CHAR16 *os_name = NULL;
                         CHAR16 *os_id = NULL;
                         CHAR16 *os_version = NULL;
+                        CHAR16 *os_build = NULL;
 
                         bufsize = sizeof(buf);
                         err = uefi_call_wrapper(linux_dir->Read, 3, linux_dir, &bufsize, buf);
@@ -1563,13 +1564,19 @@ static VOID config_entry_add_linux( Config *config, EFI_LOADED_IMAGE *loaded_ima
                                         os_version = stra_to_str(value);
                                         continue;
                                 }
+
+                                if (strcmpa((CHAR8 *)"BUILD_ID", key) == 0) {
+                                        FreePool(os_build);
+                                        os_build = stra_to_str(value);
+                                        continue;
+                                }
                         }
 
-                        if (os_name && os_id && os_version) {
+                        if (os_name && os_id && (os_version || os_build)) {
                                 CHAR16 *conf;
                                 CHAR16 *path;
 
-                                conf = PoolPrint(L"%s-%s", os_id, os_version);
+                                conf = PoolPrint(L"%s-%s", os_id, os_version ? : os_build);
                                 path = PoolPrint(L"\\EFI\\Linux\\%s", f->FileName);
                                 config_entry_add_loader(config, loaded_image->DeviceHandle, LOADER_LINUX, conf, 'l', os_name, path);
                                 FreePool(conf);
@@ -1579,6 +1586,7 @@ static VOID config_entry_add_linux( Config *config, EFI_LOADED_IMAGE *loaded_ima
                         FreePool(os_name);
                         FreePool(os_id);
                         FreePool(os_version);
+                        FreePool(os_build);
                         FreePool(content);
                 }
                 uefi_call_wrapper(linux_dir->Close, 1, linux_dir);