diff options
| author | 2025-02-03 00:41:44 -0600 | |
|---|---|---|
| committer | 2025-02-03 00:41:44 -0600 | |
| commit | 5dd7003abf6c07fa491f52ee0c0d661903bb66fe (patch) | |
| tree | 244ca269a9c2aff2a1fc439bfe7ca37485445b99 | |
| parent | random ahh changes before I make the actual thing (diff) | |
mess with stuff
| -rw-r--r-- | Cargo.lock | 141 | ||||
| -rw-r--r-- | Cargo.toml | 7 | ||||
| -rw-r--r-- | ozone-cli/Cargo.toml | 1 | ||||
| -rw-r--r-- | ozone-cli/src/main.rs | 9 | ||||
| -rw-r--r-- | ozone/Cargo.toml | 1 | ||||
| -rw-r--r-- | ozone/src/launcher.rs | 13 | ||||
| -rw-r--r-- | ozone/src/launcher/constants.rs | 6 | ||||
| -rw-r--r-- | ozone/src/launcher/jre.rs | 2 | ||||
| -rw-r--r-- | ozone/src/util.rs | 1 |
9 files changed, 165 insertions, 16 deletions
@@ -196,6 +196,56 @@ dependencies = [ ] [[package]] +name = "anstream" +version = "0.6.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" + +[[package]] +name = "anstyle-parse" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" +dependencies = [ + "anstyle", + "once_cell", + "windows-sys 0.59.0", +] + +[[package]] name = "arbitrary" version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -755,6 +805,33 @@ dependencies = [ ] [[package]] +name = "clap" +version = "4.5.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "769b0145982b4b48713e01ec42d61614425f27b7058bda7180a3a41f30104796" +dependencies = [ + "clap_builder", +] + +[[package]] +name = "clap_builder" +version = "4.5.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b26884eb4b57140e4d2d93652abfa49498b938b3c9179f9fc487b0acc3edad7" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_lex" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" + +[[package]] name = "clipboard-win" version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -793,6 +870,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" [[package]] +name = "colorchoice" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" + +[[package]] name = "colored" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1168,6 +1251,27 @@ dependencies = [ ] [[package]] +name = "dirs" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.59.0", +] + +[[package]] name = "dispatch" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2506,6 +2610,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" [[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + +[[package]] name = "itertools" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3325,6 +3435,12 @@ dependencies = [ ] [[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] name = "orbclient" version = "0.3.48" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3358,6 +3474,7 @@ version = "0.1.0" dependencies = [ "cfg-if", "chrono", + "dirs", "futures", "indexmap", "lazy_static", @@ -3384,6 +3501,7 @@ dependencies = [ name = "ozone-cli" version = "0.1.0" dependencies = [ + "clap", "log", "ozone", "simple_logger", @@ -3741,6 +3859,17 @@ dependencies = [ ] [[package]] +name = "redox_users" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b" +dependencies = [ + "getrandom 0.2.15", + "libredox", + "thiserror 2.0.11", +] + +[[package]] name = "regex" version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -4456,6 +4585,12 @@ dependencies = [ ] [[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] name = "strum" version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -5098,6 +5233,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" [[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] name = "uuid" version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1,3 +1,10 @@ [workspace] resolver = "2" members = [ "ozone", "ozone-cli", "ozone-helpers", "ozone-ui" ] + +[profile.release] +opt-level = 'z' # Optimize for size +lto = true # Enable link-time optimization +codegen-units = 1 # Reduce number of codegen units to increase optimizations +panic = 'abort' # Abort on panic +strip = true # Strip symbols from binary* diff --git a/ozone-cli/Cargo.toml b/ozone-cli/Cargo.toml index 61b7808..e793eaa 100644 --- a/ozone-cli/Cargo.toml +++ b/ozone-cli/Cargo.toml @@ -9,3 +9,4 @@ ozone = { path = "../ozone" } tokio = { version = "1.43.0", features = ["rt", "rt-multi-thread", "macros"] } simple_logger = { version = "5.0.0", features = ["colors"] } log = "0.4.25" +clap = "4.5.27" diff --git a/ozone-cli/src/main.rs b/ozone-cli/src/main.rs index f94fbe6..a17979e 100644 --- a/ozone-cli/src/main.rs +++ b/ozone-cli/src/main.rs @@ -1,19 +1,12 @@ -use std::env::consts::{ARCH, OS}; use std::error::Error; use log::{error, info}; -use sysinfo::System; use ozone::launcher::{Launcher, Settings}; #[tokio::main] async fn main() -> Result<(), Box<dyn Error>> { simple_logger::SimpleLogger::new().env().init().unwrap(); - - info!("Hello, world!"); - info!("stuff: {:?} {:?} {:?} {:?} {:?}", System::name(), System::os_version(), System::long_os_version(), System::kernel_version(), System::cpu_arch()); - info!("stuff: {:?} {:?} {:?} {}", System::distribution_id(), OS, ARCH, size_of::<*const i32>()); - - + info!("Sensible home could be {:?}", Launcher::sensible_home()); let settings = Settings::load("./work/ozone.json").await?; settings.save().await?; diff --git a/ozone/Cargo.toml b/ozone/Cargo.toml index a6fbb23..b05f066 100644 --- a/ozone/Cargo.toml +++ b/ozone/Cargo.toml @@ -25,6 +25,7 @@ tokio-stream = { version = "0.1.17", features = ["fs"] } uuid = { version = "1.12.1", features = ["v4", "serde"] } walkdir = "2.5.0" zip = { version = "2.2.2", default-features = false, features = ["bzip2", "deflate", "deflate64", "lzma", "xz"] } +dirs = "6.0.0" [dev-dependencies] simple_logger = "5.0.0" diff --git a/ozone/src/launcher.rs b/ozone/src/launcher.rs index d1fbd04..8d22d3b 100644 --- a/ozone/src/launcher.rs +++ b/ozone/src/launcher.rs @@ -237,7 +237,12 @@ impl FeatureMatcher for ProfileFeatureMatcher<'_> { } impl Launcher { - // FIXME: more descriptive error type por favor + pub fn sensible_home() -> Option<PathBuf> { + env::var_os("OZONE_HOME") + .map(PathBuf::from) + .or_else(|| dirs::data_dir().map(|mut d| { d.push("ozone"); d } )) + } + pub async fn new(home: impl AsRef<Path>, online: bool) -> Result<Launcher, LaunchError> { match tokio::fs::create_dir_all(home.as_ref()).await { Err(e) if e.kind() != AlreadyExists => { @@ -543,7 +548,7 @@ impl Launcher { Ok(Launch { jvm_args, game_args, - main_class: main_class.to_string(), + main_class: main_class.clone(), instance_path: inst_home, runtime_path: runtime_exe_path, jni_launch: profile.is_jni_launch() @@ -687,8 +692,8 @@ impl LibraryRepository { debug!("Extracting natives for {}", job.source.display()); tally += extract::extract_zip(&job.source, &natives_dir, |name| job.rule.as_ref().is_none_or(|rules| - rules.exclude.iter().any(|ex| - name.starts_with(ex.as_str()))))?; + rules.exclude.iter().all(|ex| + !name.starts_with(ex.as_str()))))?; } Ok((natives_dir, tally)) diff --git a/ozone/src/launcher/constants.rs b/ozone/src/launcher/constants.rs index 4506ab5..d370f32 100644 --- a/ozone/src/launcher/constants.rs +++ b/ozone/src/launcher/constants.rs @@ -1,8 +1,10 @@ use lazy_static::lazy_static; use regex::Regex; -pub const URL_VERSION_MANIFEST: &str = "https://piston-meta.mojang.com/mc/game/version_manifest_v2.json"; -pub const URL_RESOURCE_BASE: &str = "https://resources.download.minecraft.net/"; +//pub const URL_VERSION_MANIFEST: &str = "https://piston-meta.mojang.com/mc/game/version_manifest_v2.json"; +pub const URL_VERSION_MANIFEST: &str = "https://meta.omniarchive.uk/v1/manifest.json"; +//pub const URL_RESOURCE_BASE: &str = "https://resources.download.minecraft.net/"; +pub const URL_RESOURCE_BASE: &str = "https://meta.omniarchive.uk/resources/"; pub const URL_JRE_MANIFEST: &str = "https://piston-meta.mojang.com/v1/products/java-runtime/2ec0cc96c44e5a76b9c8b7c39df7210883d12871/all.json"; pub const NATIVES_PREFIX: &str = "natives-"; diff --git a/ozone/src/launcher/jre.rs b/ozone/src/launcher/jre.rs index a5cc166..5956f4e 100644 --- a/ozone/src/launcher/jre.rs +++ b/ozone/src/launcher/jre.rs @@ -102,7 +102,7 @@ impl JavaRuntimeRepository { let entry = entry?; let rel_path = entry.path().strip_prefix(path).expect("walkdir escaped root (???)"); - if !rel_path.components().any(|c| !matches!(&c, Component::CurDir)) { + if rel_path.components().all(|c| matches!(&c, Component::CurDir)) { // if this path is trivial (points at the root), ignore it continue; } diff --git a/ozone/src/util.rs b/ozone/src/util.rs index 0444454..a15a4fd 100644 --- a/ozone/src/util.rs +++ b/ozone/src/util.rs @@ -231,7 +231,6 @@ pub async fn ensure_file(path: impl AsRef<Path>, url: Option<&str>, expect_size: let del_file_silent = || async { debug!("Deleting downloaded file {} since its integrity doesn't match :(", path.display()); let _ = fs::remove_file(path).await.map_err(|e| warn!("failed to delete invalid downloaded file: {}", e)); - () }; if expect_size.is_some_and(|s| s != tally) { |
