mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Friendlier error when glibc too old, and properly declare min macOS
This commit is contained in:
parent
ad34b76fa9
commit
bce3cabf9b
5 changed files with 45 additions and 1 deletions
|
@ -14,6 +14,9 @@ anyhow.workspace = true
|
||||||
camino.workspace = true
|
camino.workspace = true
|
||||||
dirs.workspace = true
|
dirs.workspace = true
|
||||||
|
|
||||||
|
[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies]
|
||||||
|
libc.workspace = true
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
windows.workspace = true
|
windows.workspace = true
|
||||||
widestring.workspace = true
|
widestring.workspace = true
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.0</string>
|
<string>1.0</string>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
<string>11</string>
|
<string>12</string>
|
||||||
<key>CFBundleDocumentTypes</key>
|
<key>CFBundleDocumentTypes</key>
|
||||||
<array>
|
<array>
|
||||||
<dict>
|
<dict>
|
||||||
|
|
|
@ -22,6 +22,7 @@ use anki_process::CommandExt as AnkiCommandExt;
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
|
use crate::platform::ensure_os_supported;
|
||||||
use crate::platform::ensure_terminal_shown;
|
use crate::platform::ensure_terminal_shown;
|
||||||
use crate::platform::get_exe_and_resources_dirs;
|
use crate::platform::get_exe_and_resources_dirs;
|
||||||
use crate::platform::get_uv_binary_name;
|
use crate::platform::get_uv_binary_name;
|
||||||
|
@ -143,6 +144,8 @@ fn run() -> Result<()> {
|
||||||
print!("\x1B[2J\x1B[H"); // Clear screen and move cursor to top
|
print!("\x1B[2J\x1B[H"); // Clear screen and move cursor to top
|
||||||
println!("\x1B[1mAnki Launcher\x1B[0m\n");
|
println!("\x1B[1mAnki Launcher\x1B[0m\n");
|
||||||
|
|
||||||
|
ensure_os_supported()?;
|
||||||
|
|
||||||
check_versions(&mut state);
|
check_versions(&mut state);
|
||||||
|
|
||||||
main_menu_loop(&state)?;
|
main_menu_loop(&state)?;
|
||||||
|
|
|
@ -128,3 +128,10 @@ pub fn ensure_terminal_shown() -> Result<()> {
|
||||||
print!("\x1b]2;Anki Launcher\x07");
|
print!("\x1b]2;Anki Launcher\x07");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn ensure_os_supported() -> Result<()> {
|
||||||
|
#[cfg(all(unix, not(target_os = "macos")))]
|
||||||
|
unix::ensure_glibc_supported()?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
|
@ -65,3 +65,34 @@ pub fn finalize_uninstall() {
|
||||||
let mut input = String::new();
|
let mut input = String::new();
|
||||||
let _ = stdin().read_line(&mut input);
|
let _ = stdin().read_line(&mut input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn ensure_glibc_supported() -> Result<()> {
|
||||||
|
use std::ffi::CStr;
|
||||||
|
let get_glibc_version = || -> Option<(u32, u32)> {
|
||||||
|
let version_ptr = unsafe { libc::gnu_get_libc_version() };
|
||||||
|
if version_ptr.is_null() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
let version_cstr = unsafe { CStr::from_ptr(version_ptr) };
|
||||||
|
let version_str = version_cstr.to_str().ok()?;
|
||||||
|
|
||||||
|
// Parse version string (format: "2.36" or "2.36.1")
|
||||||
|
let version_parts: Vec<&str> = version_str.split('.').collect();
|
||||||
|
if version_parts.len() < 2 {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
let major: u32 = version_parts[0].parse().ok()?;
|
||||||
|
let minor: u32 = version_parts[1].parse().ok()?;
|
||||||
|
|
||||||
|
Some((major, minor))
|
||||||
|
};
|
||||||
|
|
||||||
|
let (major, minor) = get_glibc_version().unwrap_or_default();
|
||||||
|
if major < 3 || (major == 2 && minor < 36) {
|
||||||
|
anyhow::bail!("Anki requires a modern Linux distro with glibc 2.36 or later.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue