diff options
author | Salmon <99826409+TH3-S4LM0N@users.noreply.github.com> | 2022-10-18 08:26:14 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-18 15:26:14 +0200 |
commit | c4ce52bb45f0dcda8ea924694b48a8e0501d57c0 (patch) | |
tree | 6bd3aa2699d59ff7831fdd45df861be886ec0ba0 | |
parent | c1df0ef8f556eb9d3d8f2f7fcf8f814ae8a56780 (diff) | |
download | FlightCore-c4ce52bb45f0dcda8ea924694b48a8e0501d57c0.tar.gz FlightCore-c4ce52bb45f0dcda8ea924694b48a8e0501d57c0.zip |
Add ldd --version check for Linux (#10)
-rw-r--r-- | src-tauri/src/lib.rs | 17 | ||||
-rw-r--r-- | src-tauri/src/main.rs | 15 | ||||
-rw-r--r-- | src-tauri/src/platform_specific/linux.rs | 63 | ||||
-rw-r--r-- | src-tauri/src/platform_specific/mod.rs | 3 | ||||
-rw-r--r-- | src-vue/src/views/DeveloperView.vue | 22 |
5 files changed, 118 insertions, 2 deletions
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index d3086e2f..38acf069 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -6,6 +6,8 @@ mod platform_specific; #[cfg(target_os = "windows")] use platform_specific::windows; +use platform_specific::linux; + use serde::{Deserialize, Serialize}; use sysinfo::SystemExt; use zip::ZipArchive; @@ -40,6 +42,21 @@ pub fn check_mod_version_number(path_to_mod_folder: String) -> Result<String, an Ok(mod_version_number.to_string()) } +// I intend to add more linux related stuff to check here, so making a func +// for now tho it only checks `ldd --version` +// - salmon + +pub fn linux_checks_librs() -> bool { + let mut linux_compatible: bool = true; // a variable that starts true and will be set to false if any of the checks arent met + + // check `ldd --version` to see if glibc is up to date for northstar proton + let lddv = linux::check_glibc_v(); + if lddv < 2.33 { linux_compatible = false }; + + return linux_compatible; +} + + /// Attempts to find the game install location pub fn find_game_install_location() -> Result<GameInstall, anyhow::Error> { // Attempt parsing Steam library directly diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 9cbef850..a33f836c 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -13,7 +13,7 @@ use app::{ check_is_flightcore_outdated, check_is_valid_game_path, check_northstar_running, check_origin_running, convert_release_candidate_number, find_game_install_location, get_enabled_mods, get_host_os, get_log_list, get_northstar_version_number, install_northstar, - launch_northstar, set_mod_enabled_status, GameInstall, + launch_northstar, set_mod_enabled_status, GameInstall, linux_checks_librs }; mod repair_and_verify; @@ -87,7 +87,8 @@ fn main() { get_enabled_mods_caller, set_mod_enabled_status_caller, disable_all_but_core_caller, - is_debug_mode + is_debug_mode, + linux_checks ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); @@ -118,6 +119,16 @@ fn is_debug_mode() -> bool { } #[tauri::command] +/// Returns true if linux compatible +fn linux_checks() -> bool { + if get_host_os() == "windows" { + false + } else { + linux_checks_librs() + } +} + +#[tauri::command] /// Returns the current version number as a string fn get_version_number() -> String { let version = env!("CARGO_PKG_VERSION"); diff --git a/src-tauri/src/platform_specific/linux.rs b/src-tauri/src/platform_specific/linux.rs new file mode 100644 index 00000000..a6d37f22 --- /dev/null +++ b/src-tauri/src/platform_specific/linux.rs @@ -0,0 +1,63 @@ +// Linux specific code + +use std::process::Command; +use regex::Regex; + +pub fn check_glibc_v() -> f32 { + let out = Command::new("/bin/ldd") + .arg("--version") + .output() + .expect("failed to run 'ldd --version'"); + + // parse the output down to just the first line + let lddva = String::from_utf8_lossy(&out.stdout); + let lddvl: Vec<&str> = lddva.split('\n').collect(); + let lddvlo = &lddvl[0]; + let reg = Regex::new(r"(2.\d{2}$)").unwrap(); + for caps in reg.captures_iter(lddvlo) { + return caps.get(1).unwrap().as_str().parse::<f32>().unwrap(); // theres prolly a better way ijdk how tho + } + return 0.0; // this shouldnt ever be reached but it has to be here +} + +/* +Outputs of ldd --verssion from distros, all we care about is the first line so trimmed, also removed all duplicates +Thanks tony +Distros not included: AmazonLinux, Gentoo, Kali, Debian before 11, Oracle Linux, Scientific Linux, Slackware, Mageia, Neurodebian, RHEL 8 and 9 (Same as AlmaLinux), RockyLinux (Same as AlmaLinux), Ubuntu before 20.04 + +AlmaLinux 8 +ldd (GNU libc) 2.35 + +Centos Stream 8 +ldd (GNU libc) 2.28 + +Centos Stream 9 +ldd (GNU libc) 2.34 + +Centos 7 +ldd (GNU libc) 2.17 + +Debian 11 +ldd (Debian GLIBC 2.31-13+deb11u4) 2.31 + +Debian Testing +ldd (Debian GLIBC 2.35-1) 2.35 + +Debian Unstable +ldd (Debian GLIBC 2.35-3) 2.35 + +Fedora 37 +ldd (GNU libc) 2.36 + +Opensuse Leap +ldd (GNU libc) 2.31 + +Ubuntu 20.04 +ldd (Ubuntu GLIBC 2.31-0ubuntu9.9) 2.31 + +Ubuntu 22.04 +ldd (Ubuntu GLIBC 2.35-0ubuntu3.1) 2.35 + +Ubuntu 22.10 +ldd (Ubuntu GLIBC 2.36-0ubuntu2) 2.36 +*/ diff --git a/src-tauri/src/platform_specific/mod.rs b/src-tauri/src/platform_specific/mod.rs index 581af77f..21cac9c2 100644 --- a/src-tauri/src/platform_specific/mod.rs +++ b/src-tauri/src/platform_specific/mod.rs @@ -1,2 +1,5 @@ #[cfg(target_os = "windows")] pub mod windows; + +pub mod linux; + diff --git a/src-vue/src/views/DeveloperView.vue b/src-vue/src/views/DeveloperView.vue index f08908a6..92364679 100644 --- a/src-vue/src/views/DeveloperView.vue +++ b/src-vue/src/views/DeveloperView.vue @@ -8,6 +8,10 @@ Panic button </el-button> + <el-button type="primary" @click="checkLinuxCompatibility"> + Check NSProton Compatibility + </el-button> + <el-button type="primary" @click="toggleReleaseCandidate"> Toggle Release Candidate </el-button> @@ -43,6 +47,24 @@ export default defineComponent({ position: 'bottom-right' }); }, + async checkLinuxCompatibility() { + let LinuxCompatible = await invoke("linux_checks"); + if (!LinuxCompatible) { + ElNotification({ + title: 'Not linux compatible', + message: 'GLIBC is not version 2.33 or greater', + type: 'error', + position: 'bottom-right' + }); + } else { + ElNotification({ + title: 'Linux compatible', + message: 'No error reported', + type: 'success', + position: 'bottom-right' + }); + } + }, async toggleReleaseCandidate() { // Flip between RELEASE and RELEASE_CANDIDATE this.$store.state.release_canal = this.$store.state.release_canal === ReleaseCanal.RELEASE |