mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2025-03-03 13:27:12 +00:00
Revert "refactor: Improve File Contains precondition (#1016)"
This reverts commit c173596406
.
This commit is contained in:
parent
c173596406
commit
d419060247
|
@ -111,10 +111,12 @@ fn default_true() -> bool {
|
|||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
enum EntryType {
|
||||
#[serde(rename = "entries")]
|
||||
Entries(Vec<Entry>),
|
||||
#[serde(rename = "command")]
|
||||
Command(String),
|
||||
#[serde(rename = "script")]
|
||||
Script(PathBuf),
|
||||
}
|
||||
|
||||
|
@ -130,16 +132,15 @@ impl Entry {
|
|||
match data {
|
||||
SystemDataType::Environment(var_name) => std::env::var(var_name)
|
||||
.is_ok_and(|var| values.contains(&var) == *matches),
|
||||
SystemDataType::ContainingFile(file) => std::fs::read_to_string(file)
|
||||
.is_ok_and(|data| {
|
||||
values
|
||||
.iter()
|
||||
.all(|matching| data.contains(matching) == *matches)
|
||||
}),
|
||||
SystemDataType::File(path) => path.exists() == *matches,
|
||||
SystemDataType::CommandExists => values
|
||||
.iter()
|
||||
.all(|command| which::which(command).is_ok() == *matches),
|
||||
SystemDataType::FileExists => values.iter().all(|p| Path::new(p).is_file()),
|
||||
SystemDataType::FileContains { file, contains } => {
|
||||
std::fs::read_to_string(file)
|
||||
.map(|content| content.contains(contains) == *matches)
|
||||
.unwrap_or(false)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
|
@ -157,12 +158,15 @@ struct Precondition {
|
|||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
enum SystemDataType {
|
||||
#[serde(rename = "environment")]
|
||||
Environment(String),
|
||||
ContainingFile(PathBuf),
|
||||
FileExists,
|
||||
#[serde(rename = "file")]
|
||||
File(PathBuf),
|
||||
#[serde(rename = "command_exists")]
|
||||
CommandExists,
|
||||
#[serde(untagged)]
|
||||
FileContains { file: PathBuf, contains: String },
|
||||
}
|
||||
|
||||
fn filter_entries(entries: &mut Vec<Entry>) {
|
||||
|
|
|
@ -23,15 +23,15 @@ task_list = "I MP"
|
|||
multi_select = false
|
||||
|
||||
[[data.entries]]
|
||||
name = "Linux Neptune for SteamDeck"
|
||||
name ="Linux Neptune for SteamDeck"
|
||||
description = "Valve's fork of Linux Kernel for the SteamDeck"
|
||||
script = "arch/linux-neptune.sh"
|
||||
task_list = "I PFM K"
|
||||
|
||||
[[data.entries.preconditions]]
|
||||
matches = true
|
||||
data = { containing_file = "/sys/devices/virtual/dmi/id/board_vendor" }
|
||||
values = ["Valve"]
|
||||
data = { file = "/sys/devices/virtual/dmi/id/board_vendor" }
|
||||
values = [ "Valve" ]
|
||||
|
||||
[[data.entries]]
|
||||
name = "Nvidia Drivers && Hardware Acceleration"
|
||||
|
@ -62,8 +62,8 @@ name = "Debian"
|
|||
|
||||
[[data.preconditions]]
|
||||
matches = true
|
||||
data = { containing_file = "/etc/os-release" }
|
||||
values = ["ID=debian"]
|
||||
data = { file = "/etc/os-release", contains = "ID=debian" }
|
||||
values = []
|
||||
|
||||
[[data.entries]]
|
||||
name = "Hyprland JaKooLit"
|
||||
|
@ -130,15 +130,15 @@ task_list = "I PFM SS"
|
|||
[[data.preconditions]]
|
||||
matches = true
|
||||
data = "command_exists"
|
||||
values = ["btrfs"]
|
||||
values = [ "btrfs" ]
|
||||
|
||||
[[data]]
|
||||
name = "Ubuntu"
|
||||
|
||||
[[data.preconditions]]
|
||||
matches = true
|
||||
data = { containing_file = "/etc/os-release" }
|
||||
values = ["ID=ubuntu"]
|
||||
data = { file = "/etc/os-release", contains = "ID=ubuntu" }
|
||||
values = []
|
||||
|
||||
[[data.entries]]
|
||||
name = "Hyprland JaKooLit"
|
||||
|
@ -148,8 +148,8 @@ task_list = "I MP"
|
|||
|
||||
[[data.preconditions]]
|
||||
matches = true
|
||||
data = { containing_file = "/etc/os-release" }
|
||||
values = ['VERSION_ID="24.04"']
|
||||
data = { file = "/etc/os-release", contains = 'VERSION_ID="24.04"' }
|
||||
values = []
|
||||
|
||||
[[data]]
|
||||
name = "Build Prerequisites"
|
||||
|
|
Loading…
Reference in New Issue
Block a user