From d99c9e88a9ae2272a9f1bbaf04005afd058d6b25 Mon Sep 17 00:00:00 2001 From: lolpro11 Date: Fri, 26 Jan 2024 12:51:46 -0800 Subject: [PATCH 1/8] add rs versions of libs in order to pass static compiles --- Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 510df9ca..a6e3018b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ rust-version = "1.59.0" [dependencies] aes = { version = "0.8.2", optional = true } byteorder = "1.4.3" -bzip2 = { version = "0.4.3", optional = true } +bzip2-rs = { version = "0.1.2", optional = true } constant_time_eq = { version = "0.1.5", optional = true } crc32fast = "1.3.2" flate2 = { version = "1.0.23", default-features = false, optional = true } @@ -22,7 +22,7 @@ hmac = { version = "0.12.1", optional = true, features = ["reset"] } pbkdf2 = {version = "0.11.0", optional = true } sha1 = {version = "0.10.1", optional = true } time = { version = "0.3.7", optional = true, default-features = false, features = ["std"] } -zstd = { version = "0.11.2", optional = true } +zstud-sys = { version = "0.1.3", optional = true } [target.'cfg(any(all(target_arch = "arm", target_pointer_width = "32"), target_arch = "mips", target_arch = "powerpc"))'.dependencies] crossbeam-utils = "0.8.8" @@ -39,7 +39,7 @@ deflate = ["flate2/rust_backend"] deflate-miniz = ["flate2/default"] deflate-zlib = ["flate2/zlib"] unreserved = [] -default = ["aes-crypto", "bzip2", "deflate", "time", "zstd"] +default = ["aes-crypto", "bzip2-rs", "deflate", "time", "zstud-sys"] [[bench]] name = "read_entry" From 94ac6ab68b88f6b07eccbb463b52faea9fa11482 Mon Sep 17 00:00:00 2001 From: lolpro11 Date: Mon, 29 Jan 2024 09:58:08 -0800 Subject: [PATCH 2/8] add back zstd without default features --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a6e3018b..5924d212 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ hmac = { version = "0.12.1", optional = true, features = ["reset"] } pbkdf2 = {version = "0.11.0", optional = true } sha1 = {version = "0.10.1", optional = true } time = { version = "0.3.7", optional = true, default-features = false, features = ["std"] } -zstud-sys = { version = "0.1.3", optional = true } +zstd = { version = "0.11.2", default-features = false, optional = true } [target.'cfg(any(all(target_arch = "arm", target_pointer_width = "32"), target_arch = "mips", target_arch = "powerpc"))'.dependencies] crossbeam-utils = "0.8.8" @@ -39,7 +39,7 @@ deflate = ["flate2/rust_backend"] deflate-miniz = ["flate2/default"] deflate-zlib = ["flate2/zlib"] unreserved = [] -default = ["aes-crypto", "bzip2-rs", "deflate", "time", "zstud-sys"] +default = ["aes-crypto", "bzip2-rs", "deflate", "time", "zstd"] [[bench]] name = "read_entry" From 726c7af42b6dfac1ecb1302872c85c151957e2da Mon Sep 17 00:00:00 2001 From: Chris Hennick <4961925+Pr0methean@users.noreply.github.com> Date: Wed, 1 May 2024 15:12:19 -0700 Subject: [PATCH 3/8] fix: use is_dir in more places where Windows paths might be handled incorrectly --- examples/extract.rs | 2 +- examples/file_info.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/extract.rs b/examples/extract.rs index 30807162..7359b53e 100644 --- a/examples/extract.rs +++ b/examples/extract.rs @@ -30,7 +30,7 @@ fn real_main() -> i32 { } } - if (*file.name()).ends_with('/') { + if file.is_dir() { println!("File {} extracted to \"{}\"", i, outpath.display()); fs::create_dir_all(&outpath).unwrap(); } else { diff --git a/examples/file_info.rs b/examples/file_info.rs index 6a2adc58..84878c58 100644 --- a/examples/file_info.rs +++ b/examples/file_info.rs @@ -34,7 +34,7 @@ fn real_main() -> i32 { } } - if (*file.name()).ends_with('/') { + if file.is_dir() { println!( "Entry {} is a directory with name \"{}\"", i, From 01a8ff41b13c76fe1df28427a4dadf27ad65ce91 Mon Sep 17 00:00:00 2001 From: Chris Hennick <4961925+Pr0methean@users.noreply.github.com> Date: Wed, 1 May 2024 18:00:43 -0700 Subject: [PATCH 4/8] Make bzip2 a synonym of bzip2-rs Signed-off-by: Chris Hennick <4961925+Pr0methean@users.noreply.github.com> --- Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index d033b2e9..fbf4c7ae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,9 @@ getrandom = { version = "0.2.14", features = ["js"] } walkdir = "2.5.0" time = { workspace = true, features = ["formatting", "macros"] } anyhow = "1" + [features] +bzip2 = ["bzip2-rs"] aes-crypto = ["aes", "constant_time_eq", "hmac", "pbkdf2", "sha1"] chrono = ["chrono/default"] _deflate-any = [] From 5fbc9912a306c2611a418fe792474a888a080039 Mon Sep 17 00:00:00 2001 From: Chris Hennick <4961925+Pr0methean@users.noreply.github.com> Date: Thu, 2 May 2024 10:59:48 -0700 Subject: [PATCH 5/8] fix: Build was failing with bzip2 enabled --- src/read.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/read.rs b/src/read.rs index 0a39faef..6fceb374 100644 --- a/src/read.rs +++ b/src/read.rs @@ -29,7 +29,7 @@ use flate2::read::DeflateDecoder; use deflate64::Deflate64Decoder; #[cfg(feature = "bzip2")] -use bzip2::read::BzDecoder; +use bzip2_rs::decoder::DecoderReader; #[cfg(feature = "zstd")] use zstd::stream::read::Decoder as ZstdDecoder; @@ -145,7 +145,7 @@ pub(crate) enum ZipFileReader<'a> { #[cfg(feature = "deflate64")] Deflate64(Crc32Reader>>>), #[cfg(feature = "bzip2")] - Bzip2(Crc32Reader>>), + Bzip2(Crc32Reader>>), #[cfg(feature = "zstd")] Zstd(Crc32Reader>>>), #[cfg(feature = "lzma")] @@ -306,7 +306,7 @@ pub(crate) fn make_reader( } #[cfg(feature = "bzip2")] CompressionMethod::Bzip2 => { - let bzip2_reader = BzDecoder::new(reader); + let bzip2_reader = DecoderReader::new(reader); ZipFileReader::Bzip2(Crc32Reader::new(bzip2_reader, crc32, ae2_encrypted)) } #[cfg(feature = "zstd")] From 2309eb7b642af885025c01bc1b834b1ad72988dc Mon Sep 17 00:00:00 2001 From: Chris Hennick <4961925+Pr0methean@users.noreply.github.com> Date: Thu, 2 May 2024 11:22:56 -0700 Subject: [PATCH 6/8] Revert "fix: Build was failing with bzip2 enabled" This reverts commit 5fbc9912a306c2611a418fe792474a888a080039. --- src/read.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/read.rs b/src/read.rs index 6fceb374..0a39faef 100644 --- a/src/read.rs +++ b/src/read.rs @@ -29,7 +29,7 @@ use flate2::read::DeflateDecoder; use deflate64::Deflate64Decoder; #[cfg(feature = "bzip2")] -use bzip2_rs::decoder::DecoderReader; +use bzip2::read::BzDecoder; #[cfg(feature = "zstd")] use zstd::stream::read::Decoder as ZstdDecoder; @@ -145,7 +145,7 @@ pub(crate) enum ZipFileReader<'a> { #[cfg(feature = "deflate64")] Deflate64(Crc32Reader>>>), #[cfg(feature = "bzip2")] - Bzip2(Crc32Reader>>), + Bzip2(Crc32Reader>>), #[cfg(feature = "zstd")] Zstd(Crc32Reader>>>), #[cfg(feature = "lzma")] @@ -306,7 +306,7 @@ pub(crate) fn make_reader( } #[cfg(feature = "bzip2")] CompressionMethod::Bzip2 => { - let bzip2_reader = DecoderReader::new(reader); + let bzip2_reader = BzDecoder::new(reader); ZipFileReader::Bzip2(Crc32Reader::new(bzip2_reader, crc32, ae2_encrypted)) } #[cfg(feature = "zstd")] From b5bc43857a926e63d2c7c91fe65bb4b8ddd0cfb9 Mon Sep 17 00:00:00 2001 From: Chris Hennick <4961925+Pr0methean@users.noreply.github.com> Date: Thu, 2 May 2024 11:23:32 -0700 Subject: [PATCH 7/8] Revert "Make bzip2 a synonym of bzip2-rs" This reverts commit 01a8ff41b13c76fe1df28427a4dadf27ad65ce91. --- Cargo.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fbf4c7ae..d033b2e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,9 +52,7 @@ getrandom = { version = "0.2.14", features = ["js"] } walkdir = "2.5.0" time = { workspace = true, features = ["formatting", "macros"] } anyhow = "1" - [features] -bzip2 = ["bzip2-rs"] aes-crypto = ["aes", "constant_time_eq", "hmac", "pbkdf2", "sha1"] chrono = ["chrono/default"] _deflate-any = [] From 2c3a3f5aa01ba8e5c6ae9d3ed8c36f0137cc0781 Mon Sep 17 00:00:00 2001 From: Chris Hennick <4961925+Pr0methean@users.noreply.github.com> Date: Thu, 2 May 2024 11:26:14 -0700 Subject: [PATCH 8/8] revert: #58 (partial): `bzip2-rs` can't replace `bzip2` because it's decompress-only --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d033b2e9..de163c4c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ time = { version = "0.3.36", default-features = false } [dependencies] aes = { version = "0.8.4", optional = true } byteorder = "1.5.0" -bzip2-rs = { version = "0.1.2", optional = true } +bzip2 = { version = "0.4.4", optional = true } chrono = { version = "0.4.38", optional = true } constant_time_eq = { version = "0.3.0", optional = true } crc32fast = "1.4.0" @@ -68,7 +68,7 @@ lzma = ["lzma-rs/stream"] unreserved = [] default = [ "aes-crypto", - "bzip2-rs", + "bzip2", "deflate", "deflate64", "deflate-zlib-ng",