forked from systemd/systemd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request systemd#21285 from poettering/boot-os-rel-fix
sd-boot/bootspec: os-release parsing fixes
- Loading branch information
Showing
10 changed files
with
238 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* SPDX-License-Identifier: LGPL-2.1-or-later */ | ||
|
||
#include "bootspec-fundamental.h" | ||
|
||
sd_bool bootspec_pick_name_version( | ||
const sd_char *os_pretty_name, | ||
const sd_char *os_image_id, | ||
const sd_char *os_name, | ||
const sd_char *os_id, | ||
const sd_char *os_image_version, | ||
const sd_char *os_version, | ||
const sd_char *os_version_id, | ||
const sd_char *os_build_id, | ||
const sd_char **ret_name, | ||
const sd_char **ret_version) { | ||
|
||
const sd_char *good_name, *good_version; | ||
|
||
/* Find the best human readable title and version string for a boot entry (using the os-release(5) | ||
* fields). Precise is preferred over vague, and human readable over machine readable. Thus: | ||
* | ||
* 1. First priority gets the PRETTY_NAME field, which is the primary string intended for display, | ||
* and should already contain both a nice description and a version indication (if that concept | ||
* applies). | ||
* | ||
* 2. Otherwise we go for IMAGE_ID and IMAGE_VERSION (thus we show details about the image, | ||
* i.e. specific combination of packages and configuration), if that concept applies. | ||
* | ||
* 3. Otherwise we go for NAME and VERSION (i.e. human readable OS name and version) | ||
* | ||
* 4. Otherwise we go for ID and VERSION_ID (i.e. machine readable OS name and version) | ||
* | ||
* 5. Finally, for the version we'll use BUILD_ID (i.e. a machine readable version that identifies | ||
* the original OS build used during installation) | ||
* | ||
* Note that the display logic will show only the name by default, except if that isn't unique in | ||
* which case the version is shown too. | ||
* | ||
* Note that name/version determined here are used only for display purposes. Boot entry preference | ||
* sorting (i.e. algorithmic ordering of boot entries) is done based on the order of the entry "id" | ||
* string (i.e. not on os-release(5) data). */ | ||
|
||
good_name = os_pretty_name ?: (os_image_id ?: (os_name ?: os_id)); | ||
good_version = os_image_version ?: (os_version ?: (os_version_id ? : os_build_id)); | ||
|
||
if (!good_name || !good_version) | ||
return sd_false; | ||
|
||
if (ret_name) | ||
*ret_name = good_name; | ||
|
||
if (ret_version) | ||
*ret_version = good_version; | ||
|
||
return sd_true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* SPDX-License-Identifier: LGPL-2.1-or-later */ | ||
#pragma once | ||
|
||
#include "types-fundamental.h" | ||
|
||
sd_bool bootspec_pick_name_version( | ||
const sd_char *os_pretty_name, | ||
const sd_char *os_image_id, | ||
const sd_char *os_name, | ||
const sd_char *os_id, | ||
const sd_char *os_image_version, | ||
const sd_char *os_version, | ||
const sd_char *os_version_id, | ||
const sd_char *os_build_id, | ||
const sd_char **ret_name, | ||
const sd_char **ret_version); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.