From 7c5d5bf9f2521b970b8ddb29e744b4c53ba8828b Mon Sep 17 00:00:00 2001 From: Truman Kilen Date: Sat, 16 Dec 2023 18:54:39 -0600 Subject: [PATCH] Update repak --- Cargo.lock | 57 ++++++++++++++++++++++--- Cargo.toml | 6 +-- mint_lib/Cargo.toml | 1 + src/integrate.rs | 33 ++++++++------ src/lib.rs | 2 +- src/mod_lints/mod.rs | 4 +- src/mod_lints/unmodified_game_assets.rs | 2 +- 7 files changed, 79 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index afd0d8ff..f69cc9f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -958,6 +958,21 @@ dependencies = [ "libc", ] +[[package]] +name = "crc" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + [[package]] name = "crc32fast" version = "1.3.2" @@ -2478,6 +2493,16 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +[[package]] +name = "lzma-rs" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "297e814c836ae64db86b36cf2a557ba54368d03f6afcd7d947c266692f71115e" +dependencies = [ + "byteorder", + "crc", +] + [[package]] name = "mach" version = "0.3.2" @@ -2648,6 +2673,7 @@ name = "mint_lib" version = "0.2.10" dependencies = [ "anyhow", + "repak", "steamlocate", ] @@ -3018,6 +3044,23 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +[[package]] +name = "oodle_loader" +version = "0.1.8" +source = "git+https://github.com/trumank/repak#9362db07e2dbf9676dedbd4619caf11d2bcb4a38" +dependencies = [ + "anyhow", + "hex", + "hex-literal", + "libc", + "libloading 0.7.4", + "lzma-rs", + "object", + "seq-macro", + "sha1", + "ureq", +] + [[package]] name = "opener" version = "0.6.1" @@ -3605,19 +3648,15 @@ dependencies = [ [[package]] name = "repak" version = "0.1.8" -source = "git+https://github.com/trumank/repak#d8e82a2d275282dbc22f71d3155337cd020b78f3" +source = "git+https://github.com/trumank/repak#9362db07e2dbf9676dedbd4619caf11d2bcb4a38" dependencies = [ "aes", "byteorder", "flate2", - "hex", - "hex-literal", - "libloading 0.7.4", - "once_cell", + "oodle_loader", "sha1", "strum 0.24.1", "thiserror", - "ureq", "zstd", ] @@ -3951,6 +3990,12 @@ version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" +[[package]] +name = "seq-macro" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3f0bf26fd526d2a95683cd0f87bf103b8539e2ca1ef48ce002d67aad59aa0b4" + [[package]] name = "serde" version = "1.0.193" diff --git a/Cargo.toml b/Cargo.toml index be15396e..1c210bd0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,7 @@ edition = "2021" anyhow = { version = "1.0.75", features = ["backtrace"] } patternsleuth = { git = "https://github.com/trumank/patternsleuth" } steamlocate = "2.0.0-alpha.0" +repak = { git = "https://github.com/trumank/repak" } [package] name = "mint" @@ -76,11 +77,8 @@ uasset_utils = { git = "https://github.com/trumank/uasset_utils" } unreal_asset = { git = "https://github.com/trumank/unrealmodding", branch = "patches" } url = "2.5.0" zip = { version = "0.6.6", default-features = false, features = ["aes-crypto", "deflate", "time"] } +repak = { workspace = true, features = ["oodle", "oodle_loader"] } -[target.'cfg(windows)'.dependencies] -repak = { git = "https://github.com/trumank/repak", features = ["oodle"] } -[target.'cfg(not(windows))'.dependencies] -repak = { git = "https://github.com/trumank/repak" } [target.'cfg(target_env = "msvc")'.dependencies] hook = { path = "hook", artifact = "cdylib", optional = true, target = "x86_64-pc-windows-msvc"} [target.'cfg(not(target_env = "msvc"))'.dependencies] diff --git a/mint_lib/Cargo.toml b/mint_lib/Cargo.toml index 2ca43dd5..4ad85ab8 100644 --- a/mint_lib/Cargo.toml +++ b/mint_lib/Cargo.toml @@ -9,3 +9,4 @@ edition.workspace = true [dependencies] anyhow.workspace = true steamlocate.workspace = true +repak.workspace = true diff --git a/src/integrate.rs b/src/integrate.rs index 20db18ef..2e0edf19 100644 --- a/src/integrate.rs +++ b/src/integrate.rs @@ -169,10 +169,12 @@ pub fn integrate>( kind: IntegrationErrKind::Generic(e), })?; let mut fsd_pak_reader = BufReader::new(fsd_pak_file); - let fsd_pak = repak::PakReader::new_any(&mut fsd_pak_reader).map_err(|e| IntegrationErr { - mod_ctxt: None, - kind: IntegrationErrKind::Repak(e), - })?; + let fsd_pak = repak::PakBuilder::new() + .reader(&mut fsd_pak_reader) + .map_err(|e| IntegrationErr { + mod_ctxt: None, + kind: IntegrationErrKind::Repak(e), + })?; #[derive(Debug, Default)] struct Dir<'a> { @@ -309,7 +311,7 @@ pub fn integrate>( })?; } - let mut mod_pak = repak::PakWriter::new( + let mut mod_pak = repak::PakBuilder::new().writer( BufWriter::new( OpenOptions::new() .write(true) @@ -362,10 +364,13 @@ pub fn integrate>( kind: IntegrationErrKind::Generic(e), } })?; - let pak = repak::PakReader::new_any(&mut buf).map_err(|e| IntegrationErr { - mod_ctxt: Some(mod_info.clone()), - kind: IntegrationErrKind::Repak(e), - })?; + let pak = repak::PakBuilder::new() + .oodle(repak::oodle_loader::decompress) + .reader(&mut buf) + .map_err(|e| IntegrationErr { + mod_ctxt: Some(mod_info.clone()), + kind: IntegrationErrKind::Repak(e), + })?; let mount = Path::new(pak.mount_point()); @@ -466,10 +471,12 @@ pub fn integrate>( patch_deferred(modding_tab_path, patch_modding_tab_item)?; let mut int_pak_reader = Cursor::new(include_bytes!("../assets/integration.pak")); - let int_pak = repak::PakReader::new_any(&mut int_pak_reader).map_err(|e| IntegrationErr { - mod_ctxt: None, - kind: IntegrationErrKind::Repak(e), - })?; + let int_pak = repak::PakBuilder::new() + .reader(&mut int_pak_reader) + .map_err(|e| IntegrationErr { + mod_ctxt: None, + kind: IntegrationErrKind::Repak(e), + })?; let mount = Path::new(int_pak.mount_point()); let files = int_pak.files(); diff --git a/src/lib.rs b/src/lib.rs index f15147e5..8f02af5e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -89,7 +89,7 @@ pub fn write_file, C: AsRef<[u8]>>(path: P, data: C) -> Result<() pub fn is_drg_pak>(path: P) -> Result<()> { let mut reader = std::io::BufReader::new(open_file(path)?); - let pak = repak::PakReader::new_any(&mut reader)?; + let pak = repak::PakBuilder::new().reader(&mut reader)?; pak.get("FSD/FSD.uproject", &mut reader)?; Ok(()) } diff --git a/src/mod_lints/mod.rs b/src/mod_lints/mod.rs index c076caa5..fa2c320b 100644 --- a/src/mod_lints/mod.rs +++ b/src/mod_lints/mod.rs @@ -96,7 +96,9 @@ impl LintCtxt { } let mut first_pak_read_seek = individual_pak_readers.remove(0); - let pak_reader = repak::PakReader::new_any(&mut first_pak_read_seek)?; + let pak_reader = repak::PakBuilder::new() + .oodle(repak::oodle_loader::decompress) + .reader(&mut first_pak_read_seek)?; f(mod_spec.clone(), &mut first_pak_read_seek, &pak_reader)? } diff --git a/src/mod_lints/unmodified_game_assets.rs b/src/mod_lints/unmodified_game_assets.rs index 61ff0bdc..53f89758 100644 --- a/src/mod_lints/unmodified_game_assets.rs +++ b/src/mod_lints/unmodified_game_assets.rs @@ -29,7 +29,7 @@ impl Lint for UnmodifiedGameAssetsLint { // Adapted from // . let mut reader = BufReader::new(open_file(game_pak_path)?); - let pak = repak::PakReader::new_any(&mut reader)?; + let pak = repak::PakBuilder::new().reader(&mut reader)?; let mount_point = PathBuf::from(pak.mount_point());