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)]
|
#[derive(Deserialize)]
|
||||||
#[serde(rename_all = "snake_case")]
|
|
||||||
enum EntryType {
|
enum EntryType {
|
||||||
|
#[serde(rename = "entries")]
|
||||||
Entries(Vec<Entry>),
|
Entries(Vec<Entry>),
|
||||||
|
#[serde(rename = "command")]
|
||||||
Command(String),
|
Command(String),
|
||||||
|
#[serde(rename = "script")]
|
||||||
Script(PathBuf),
|
Script(PathBuf),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,16 +132,15 @@ impl Entry {
|
||||||
match data {
|
match data {
|
||||||
SystemDataType::Environment(var_name) => std::env::var(var_name)
|
SystemDataType::Environment(var_name) => std::env::var(var_name)
|
||||||
.is_ok_and(|var| values.contains(&var) == *matches),
|
.is_ok_and(|var| values.contains(&var) == *matches),
|
||||||
SystemDataType::ContainingFile(file) => std::fs::read_to_string(file)
|
SystemDataType::File(path) => path.exists() == *matches,
|
||||||
.is_ok_and(|data| {
|
|
||||||
values
|
|
||||||
.iter()
|
|
||||||
.all(|matching| data.contains(matching) == *matches)
|
|
||||||
}),
|
|
||||||
SystemDataType::CommandExists => values
|
SystemDataType::CommandExists => values
|
||||||
.iter()
|
.iter()
|
||||||
.all(|command| which::which(command).is_ok() == *matches),
|
.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)]
|
#[derive(Deserialize)]
|
||||||
#[serde(rename_all = "snake_case")]
|
|
||||||
enum SystemDataType {
|
enum SystemDataType {
|
||||||
|
#[serde(rename = "environment")]
|
||||||
Environment(String),
|
Environment(String),
|
||||||
ContainingFile(PathBuf),
|
#[serde(rename = "file")]
|
||||||
FileExists,
|
File(PathBuf),
|
||||||
|
#[serde(rename = "command_exists")]
|
||||||
CommandExists,
|
CommandExists,
|
||||||
|
#[serde(untagged)]
|
||||||
|
FileContains { file: PathBuf, contains: String },
|
||||||
}
|
}
|
||||||
|
|
||||||
fn filter_entries(entries: &mut Vec<Entry>) {
|
fn filter_entries(entries: &mut Vec<Entry>) {
|
||||||
|
|
|
@ -23,15 +23,15 @@ task_list = "I MP"
|
||||||
multi_select = false
|
multi_select = false
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
name = "Linux Neptune for SteamDeck"
|
name ="Linux Neptune for SteamDeck"
|
||||||
description = "Valve's fork of Linux Kernel for the SteamDeck"
|
description = "Valve's fork of Linux Kernel for the SteamDeck"
|
||||||
script = "arch/linux-neptune.sh"
|
script = "arch/linux-neptune.sh"
|
||||||
task_list = "I PFM K"
|
task_list = "I PFM K"
|
||||||
|
|
||||||
[[data.entries.preconditions]]
|
[[data.entries.preconditions]]
|
||||||
matches = true
|
matches = true
|
||||||
data = { containing_file = "/sys/devices/virtual/dmi/id/board_vendor" }
|
data = { file = "/sys/devices/virtual/dmi/id/board_vendor" }
|
||||||
values = ["Valve"]
|
values = [ "Valve" ]
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
name = "Nvidia Drivers && Hardware Acceleration"
|
name = "Nvidia Drivers && Hardware Acceleration"
|
||||||
|
@ -62,8 +62,8 @@ name = "Debian"
|
||||||
|
|
||||||
[[data.preconditions]]
|
[[data.preconditions]]
|
||||||
matches = true
|
matches = true
|
||||||
data = { containing_file = "/etc/os-release" }
|
data = { file = "/etc/os-release", contains = "ID=debian" }
|
||||||
values = ["ID=debian"]
|
values = []
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
name = "Hyprland JaKooLit"
|
name = "Hyprland JaKooLit"
|
||||||
|
@ -130,15 +130,15 @@ task_list = "I PFM SS"
|
||||||
[[data.preconditions]]
|
[[data.preconditions]]
|
||||||
matches = true
|
matches = true
|
||||||
data = "command_exists"
|
data = "command_exists"
|
||||||
values = ["btrfs"]
|
values = [ "btrfs" ]
|
||||||
|
|
||||||
[[data]]
|
[[data]]
|
||||||
name = "Ubuntu"
|
name = "Ubuntu"
|
||||||
|
|
||||||
[[data.preconditions]]
|
[[data.preconditions]]
|
||||||
matches = true
|
matches = true
|
||||||
data = { containing_file = "/etc/os-release" }
|
data = { file = "/etc/os-release", contains = "ID=ubuntu" }
|
||||||
values = ["ID=ubuntu"]
|
values = []
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
name = "Hyprland JaKooLit"
|
name = "Hyprland JaKooLit"
|
||||||
|
@ -148,8 +148,8 @@ task_list = "I MP"
|
||||||
|
|
||||||
[[data.preconditions]]
|
[[data.preconditions]]
|
||||||
matches = true
|
matches = true
|
||||||
data = { containing_file = "/etc/os-release" }
|
data = { file = "/etc/os-release", contains = 'VERSION_ID="24.04"' }
|
||||||
values = ['VERSION_ID="24.04"']
|
values = []
|
||||||
|
|
||||||
[[data]]
|
[[data]]
|
||||||
name = "Build Prerequisites"
|
name = "Build Prerequisites"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user