feat(core): use whatadistro library to identify package manager in first run window

Patch's dev has pacman gui game which executable is called `pacman`,
so with current checks this game was launching all the time on his pc lmao
This commit is contained in:
Observer KRypt0n_ 2023-05-19 22:21:10 +02:00
parent 3ad7993bd3
commit 4676ac3a81
3 changed files with 27 additions and 27 deletions

15
Cargo.lock generated
View file

@ -48,8 +48,8 @@ dependencies = [
[[package]]
name = "anime-game-core"
version = "1.8.1"
source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.8.1#774409afb9453fac78038d783c6d36c1181a3945"
version = "1.8.2"
source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.8.2#03235447d7df4aa16679fa3fad2a454f1b7cfc74"
dependencies = [
"anyhow",
"bzip2",
@ -91,12 +91,13 @@ dependencies = [
"tracing",
"tracing-subscriber",
"unic-langid",
"whatadistro",
]
[[package]]
name = "anime-launcher-sdk"
version = "1.2.4"
source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=1.2.4#44080a0735c12bd0854d7514c6733879bc11be6b"
version = "1.2.5"
source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=1.2.5#c26fe8a3d52afbb4219820c4812305c0a6d76508"
dependencies = [
"anime-game-core",
"anyhow",
@ -3000,6 +3001,12 @@ dependencies = [
"webpki",
]
[[package]]
name = "whatadistro"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c97ebad4f59809511083f2161587445631bff21bb78d9e046b9ca5b2d05d913"
[[package]]
name = "winapi"
version = "0.3.9"

View file

@ -17,7 +17,7 @@ glib-build-tools = "0.17"
[dependencies.anime-launcher-sdk]
git = "https://github.com/an-anime-team/anime-launcher-sdk"
tag = "1.2.4"
tag = "1.2.5"
features = ["all", "genshin"]
# path = "../anime-launcher-sdk" # ! for dev purposes only
@ -29,6 +29,7 @@ adw = { package = "libadwaita", version = "0.3", features = ["v1_2"] }
rfd = { version = "0.11", features = ["xdg-portal"], default-features = false }
open = "4.0"
whatadistro = "0.1.0"
serde_json = "1.0"
anyhow = "1.0"

View file

@ -5,8 +5,6 @@ use adw::prelude::*;
use anime_launcher_sdk::is_available;
use std::process::{Command, Stdio};
use crate::i18n::*;
use super::main::FirstRunAppMsg;
@ -143,30 +141,24 @@ impl SimpleAsyncComponent for DependenciesApp {
root: Self::Root,
_sender: AsyncComponentSender<Self>,
) -> AsyncComponentParts<Self> {
let mut model = Self {
show_arch: false,
show_debian: false,
show_fedora: false
};
let distro = whatadistro::identify();
// Decide which packaging format used in system
match Command::new("pacman").stdout(Stdio::null()).stderr(Stdio::null()).spawn() {
Ok(_) => model.show_arch = true,
let model = Self {
show_arch: match &distro {
Some(distro) => distro.is_similar("arch"),
None => false
},
Err(_) => match Command::new("apt").stdout(Stdio::null()).stderr(Stdio::null()).spawn() {
Ok(_) => model.show_debian = true,
show_debian: match &distro {
Some(distro) => distro.is_similar("debian"),
None => false
},
Err(_) => match Command::new("dnf").stdout(Stdio::null()).stderr(Stdio::null()).spawn() {
Ok(_) => model.show_fedora = true,
Err(_) => {
model.show_arch = true;
model.show_debian = true;
model.show_fedora = true;
}
}
show_fedora: match &distro {
Some(distro) => distro.is_similar("fedora"),
None => false
}
}
};
let widgets = view_output!();