mirror of
https://github.com/edera-dev/sprout.git
synced 2026-05-07 23:00:17 +00:00
feat(boot): introduce sort keys, which are sorted in reverse order, to make boot order more configurable (#55)
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
use crate::utils;
|
||||
use crate::utils::vercmp;
|
||||
use alloc::collections::BTreeMap;
|
||||
use alloc::string::{String, ToString};
|
||||
use alloc::vec::Vec;
|
||||
@@ -186,17 +185,15 @@ pub fn scan(
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
// Sort the kernel pairs by kernel version, if it has one, newer kernels first.
|
||||
pairs.sort_by(|a, b| vercmp::compare_versions(&a.kernel, &b.kernel).reverse());
|
||||
|
||||
// Generate a unique name for the linux chainload action.
|
||||
let chainload_action_name = format!("{}{}", LINUX_CHAINLOAD_ACTION_PREFIX, root_unique_hash,);
|
||||
let chainload_action_name = format!("{}{}", LINUX_CHAINLOAD_ACTION_PREFIX, root_unique_hash);
|
||||
|
||||
// Kernel pairs are detected, generate a list configuration for it.
|
||||
let generator = ListConfiguration {
|
||||
entry: EntryDeclaration {
|
||||
title: "Boot Linux $name".to_string(),
|
||||
actions: vec![chainload_action_name.clone()],
|
||||
sort_key: Some("$kernel".to_string()),
|
||||
..Default::default()
|
||||
},
|
||||
values: pairs
|
||||
|
||||
@@ -51,13 +51,14 @@ pub fn scan(
|
||||
let chainload_action_name = format!("{}{}", WINDOWS_CHAINLOAD_ACTION_PREFIX, root_unique_hash,);
|
||||
|
||||
// Generate an entry name for Windows.
|
||||
let entry_name = format!("auto-windows-{}", root_unique_hash,);
|
||||
let entry_name = format!("auto-windows-{}", root_unique_hash);
|
||||
|
||||
// Create an entry for Windows and insert it into the configuration.
|
||||
let entry = EntryDeclaration {
|
||||
title: "Boot Windows".to_string(),
|
||||
actions: vec![chainload_action_name.clone()],
|
||||
values: Default::default(),
|
||||
sort_key: None, // Use the default sort key.
|
||||
};
|
||||
config.entries.insert(entry_name, entry);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user