diff --git a/Cargo.lock b/Cargo.lock index 3e55226..4b20239 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -200,12 +200,6 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "bitflags" version = "1.3.2" @@ -236,28 +230,12 @@ version = "3.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - [[package]] name = "bytes" version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" -[[package]] -name = "bzip2" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8" -dependencies = [ - "bzip2-sys", - "libc", -] - [[package]] name = "bzip2" version = "0.6.1" @@ -267,17 +245,6 @@ dependencies = [ "libbz2-rs-sys", ] -[[package]] -name = "bzip2-sys" -version = "0.1.11+1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" -dependencies = [ - "cc", - "libc", - "pkg-config", -] - [[package]] name = "cc" version = "1.2.57" @@ -463,12 +430,6 @@ dependencies = [ "tiny-keccak", ] -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - [[package]] name = "constant_time_eq" version = "0.4.2" @@ -528,12 +489,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crossbeam-utils" -version = "0.8.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" - [[package]] name = "crossterm" version = "0.27.0" @@ -1006,6 +961,7 @@ dependencies = [ "fs4", "futures-util", "indicatif", + "liblzma", "miette", "nix", "regex", @@ -1019,10 +975,8 @@ dependencies = [ "tracing", "tracing-indicatif", "tracing-subscriber", - "xz2", "yansi", - "zip 8.3.0", - "zip-extract", + "zip", ] [[package]] @@ -1271,6 +1225,26 @@ version = "0.2.183" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d" +[[package]] +name = "liblzma" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6033b77c21d1f56deeae8014eb9fbe7bdf1765185a6c508b5ca82eeaed7f899" +dependencies = [ + "liblzma-sys", +] + +[[package]] +name = "liblzma-sys" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f2db66f3268487b5033077f266da6777d057949b8f93c8ad82e441df25e6186" +dependencies = [ + "cc", + "libc", + "pkg-config", +] + [[package]] name = "libredox" version = "0.1.3" @@ -1318,17 +1292,6 @@ dependencies = [ "sha2", ] -[[package]] -name = "lzma-sys" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fda04ab3764e6cde78b9974eec4f779acaba7c4e84b36eca3cf77c581b85d27" -dependencies = [ - "cc", - "libc", - "pkg-config", -] - [[package]] name = "memchr" version = "2.7.2" @@ -1528,35 +1491,12 @@ dependencies = [ "windows-targets 0.52.5", ] -[[package]] -name = "password-hash" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" -dependencies = [ - "base64ct", - "rand_core 0.6.4", - "subtle", -] - [[package]] name = "pathdiff" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" -[[package]] -name = "pbkdf2" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" -dependencies = [ - "digest", - "hmac", - "password-hash", - "sha2", -] - [[package]] name = "pbkdf2" version = "0.12.2" @@ -1761,7 +1701,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" dependencies = [ "rand_chacha", - "rand_core 0.9.5", + "rand_core", ] [[package]] @@ -1771,15 +1711,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", - "rand_core 0.9.5", + "rand_core", ] -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" - [[package]] name = "rand_core" version = "0.9.5" @@ -3402,15 +3336,6 @@ dependencies = [ "rustix", ] -[[package]] -name = "xz2" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388c44dc09d76f1536602ead6d325eb532f5c122f17782bd57fb47baeeb767e2" -dependencies = [ - "lzma-sys", -] - [[package]] name = "yaml-rust2" version = "0.10.4" @@ -3434,25 +3359,6 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" -[[package]] -name = "zip" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" -dependencies = [ - "aes", - "byteorder", - "bzip2 0.4.4", - "constant_time_eq 0.1.5", - "crc32fast", - "crossbeam-utils", - "flate2", - "hmac", - "pbkdf2 0.11.0", - "sha1", - "zstd 0.11.2+zstd.1.5.2", -] - [[package]] name = "zip" version = "8.3.0" @@ -3460,8 +3366,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a243cfad17427fc077f529da5a95abe4e94fd2bfdb601611870a6557cc67657" dependencies = [ "aes", - "bzip2 0.6.1", - "constant_time_eq 0.4.2", + "bzip2", + "constant_time_eq", "crc32fast", "deflate64", "flate2", @@ -3470,25 +3376,14 @@ dependencies = [ "indexmap", "lzma-rust2", "memchr", - "pbkdf2 0.12.2", + "pbkdf2", "ppmd-rust", "sha1", "time", "typed-path", "zeroize", "zopfli", - "zstd 0.13.3", -] - -[[package]] -name = "zip-extract" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e109e5a291403b4c1e514d39f8a22d3f98d257e691a52bb1f16051bb1ffed63e" -dependencies = [ - "log", - "thiserror 1.0.63", - "zip 0.6.6", + "zstd", ] [[package]] @@ -3515,32 +3410,13 @@ dependencies = [ "simd-adler32", ] -[[package]] -name = "zstd" -version = "0.11.2+zstd.1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" -dependencies = [ - "zstd-safe 5.0.2+zstd.1.5.2", -] - [[package]] name = "zstd" version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" dependencies = [ - "zstd-safe 7.2.1", -] - -[[package]] -name = "zstd-safe" -version = "5.0.2+zstd.1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" -dependencies = [ - "libc", - "zstd-sys", + "zstd-safe", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index c2e3e2b..656f080 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,8 +28,7 @@ fs4 = "0.7.0" flate2 = "1.0.30" tar = "0.4.41" zip = "8.3.0" -zip-extract = "0.1.3" -xz2 = "0.1.7" +liblzma = "0.4.1" signal-hook = "0.3.17" nix = { version = "0.29.0", features = ["signal"] } serde = { version = "1.0.204", features = ["derive"] } diff --git a/src/adapters/archive.rs b/src/adapters/archive.rs index 2e05b27..e50a950 100644 --- a/src/adapters/archive.rs +++ b/src/adapters/archive.rs @@ -1,11 +1,9 @@ use std::fs; -use std::io; -use std::path::Path; use anyhow::anyhow; use anyhow::Result; -use xz2::read::XzDecoder; -use zip_extract::extract; +use liblzma::read::XzDecoder; +use zip::ZipArchive as ZipReader; use crate::domain::package::Package; use crate::domain::version::LocalVersion; @@ -52,12 +50,6 @@ fn expand(package: Package, tmp: LocalVersion) -> Result<()> { })?; let output = format!("{}/{}", tmp.path, tmp.file_name); - let decompress_stream: Box = match tmp.file_format.as_str() { - "tar.gz" => Box::new(GzDecoder::new(&file)), - "tar.xz" => Box::new(XzDecoder::new(&file)), - "zip" => Box::new(io::empty()), - _ => return Err(anyhow!("Unsupported file format")), - }; let context_msg = format!( "Failed to decompress or extract file {}.{}", @@ -65,12 +57,20 @@ fn expand(package: Package, tmp: LocalVersion) -> Result<()> { ); match tmp.file_format.as_str() { - "tar.gz" | "tar.xz" => { + "tar.gz" => { + let decompress_stream = GzDecoder::new(file); + let mut archive = Archive::new(decompress_stream); + archive.unpack(&output).with_context(|| context_msg)?; + } + "tar.xz" => { + let decompress_stream = XzDecoder::new(file); let mut archive = Archive::new(decompress_stream); archive.unpack(&output).with_context(|| context_msg)?; } "zip" => { - extract(&file, Path::new(&output), true).with_context(|| context_msg)?; + let mut archive = ZipReader::new(file) + .map_err(|error| anyhow!("{context_msg}. additional info: {error}"))?; + archive.extract(&output).with_context(|| context_msg)?; } _ => return Err(anyhow!("Unsupported file format")), }