summaryrefslogtreecommitdiffstats
path: root/src/fundamental
diff options
context:
space:
mode:
Diffstat (limited to 'src/fundamental')
-rw-r--r--src/fundamental/bootspec-fundamental.c20
-rw-r--r--src/fundamental/bootspec-fundamental.h5
2 files changed, 16 insertions, 9 deletions
diff --git a/src/fundamental/bootspec-fundamental.c b/src/fundamental/bootspec-fundamental.c
index 9c4aee9744..89e29f5982 100644
--- a/src/fundamental/bootspec-fundamental.c
+++ b/src/fundamental/bootspec-fundamental.c
@@ -2,7 +2,7 @@
#include "bootspec-fundamental.h"
-sd_bool bootspec_pick_name_version(
+sd_bool bootspec_pick_name_version_sort_key(
const sd_char *os_pretty_name,
const sd_char *os_image_id,
const sd_char *os_name,
@@ -12,12 +12,14 @@ sd_bool bootspec_pick_name_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 **ret_version,
+ const sd_char **ret_sort_key) {
- const sd_char *good_name, *good_version;
+ const sd_char *good_name, *good_version, *good_sort_key;
- /* 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:
+ /* Find the best human readable title, version string and sort key 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
@@ -37,11 +39,12 @@ sd_bool bootspec_pick_name_version(
* 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). */
+ * sorting (i.e. algorithmic ordering of boot entries) is done based on the order of the sort key (if
+ * defined) or entry "id" string (i.e. entry file name) otherwise. */
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));
+ good_sort_key = os_image_id ?: os_id;
if (!good_name || !good_version)
return sd_false;
@@ -52,5 +55,8 @@ sd_bool bootspec_pick_name_version(
if (ret_version)
*ret_version = good_version;
+ if (ret_sort_key)
+ *ret_sort_key = good_sort_key;
+
return sd_true;
}
diff --git a/src/fundamental/bootspec-fundamental.h b/src/fundamental/bootspec-fundamental.h
index 2cb6d7daa1..ff88f8bc3f 100644
--- a/src/fundamental/bootspec-fundamental.h
+++ b/src/fundamental/bootspec-fundamental.h
@@ -3,7 +3,7 @@
#include "types-fundamental.h"
-sd_bool bootspec_pick_name_version(
+sd_bool bootspec_pick_name_version_sort_key(
const sd_char *os_pretty_name,
const sd_char *os_image_id,
const sd_char *os_name,
@@ -13,4 +13,5 @@ sd_bool bootspec_pick_name_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 **ret_version,
+ const sd_char **ret_sort_key);