From 053ce852d57c0f243bcc2f8adc03a58480a409ab Mon Sep 17 00:00:00 2001 From: kpcyrd Date: Mon, 11 Nov 2024 20:58:43 +0100 Subject: [PATCH] Refactor xz/lzma decompression code --- Cargo.lock | 46 ++++-------------------------------- tools/Cargo.toml | 5 ++-- tools/src/decompress.rs | 2 +- tools/src/schedule/debian.rs | 4 ++-- 4 files changed, 9 insertions(+), 48 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8a11c10..ba4334f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -55,7 +55,7 @@ dependencies = [ "tokio", "tokio-util", "tracing", - "zstd 0.13.2", + "zstd", ] [[package]] @@ -1622,7 +1622,6 @@ dependencies = [ "rebuilderd-common", "regex", "reqwest", - "rust-lzma", "serde", "serde_json", "structopt", @@ -1631,8 +1630,8 @@ dependencies = [ "toml 0.5.11", "tree_magic_mini", "url", - "xz", - "zstd 0.11.2+zstd.1.5.2", + "xz2", + "zstd", ] [[package]] @@ -1819,15 +1818,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rust-lzma" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "895dc04daeaeee338bb96e229797902ed3f0675bfc59d5b42e0f0b0c13ac54da" -dependencies = [ - "pkg-config", -] - [[package]] name = "rustc-demangle" version = "0.1.24" @@ -2803,15 +2793,6 @@ dependencies = [ "rustix", ] -[[package]] -name = "xz" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c887690ff2a2e233e8e49633461521f98ec57fbff9d59a884c9a4f04ec1da34" -dependencies = [ - "xz2", -] - [[package]] name = "xz2" version = "0.1.7" @@ -2842,32 +2823,13 @@ dependencies = [ "syn 2.0.77", ] -[[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.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcf2b778a664581e31e389454a7072dab1647606d44f7feea22cd5abb9c9f3f9" 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/tools/Cargo.toml b/tools/Cargo.toml index abde0a8..7123850 100644 --- a/tools/Cargo.toml +++ b/tools/Cargo.toml @@ -21,7 +21,6 @@ structopt = "0.3.26" env_logger = "0.9.0" reqwest = { version="0.11.11", features=["json"] } chrono = { version = "0.4.19", features=["serde"] } -rust-lzma = "0.5.1" tar = "0.4.38" flate2 = "1.0.24" serde = { version="1.0.137", features=["derive"] } @@ -35,8 +34,8 @@ tokio = { version="1.19.2", features=["macros", "rt-multi-thread", "io-std", "io atty = "0.2.14" tree_magic_mini = "3.0.3" bzip2 = "0.4.3" -xz = "0.1.0" -zstd = { version = "0.11.2", features = ["pkg-config"] } +xz2 = "0.1" +zstd = { version = "0.13", features = ["pkg-config"] } regex = "1.5.6" url = "2.2.2" diff --git a/tools/src/decompress.rs b/tools/src/decompress.rs index b418497..5b010a4 100644 --- a/tools/src/decompress.rs +++ b/tools/src/decompress.rs @@ -2,7 +2,7 @@ use rebuilderd_common::errors::*; use std::io::Read; use flate2::read::GzDecoder; use bzip2::read::BzDecoder; -use xz::read::XzDecoder; +use xz2::read::XzDecoder; #[derive(Debug, PartialEq, Eq)] pub enum CompressedWith { diff --git a/tools/src/schedule/debian.rs b/tools/src/schedule/debian.rs index bdcf3d3..0b1660b 100644 --- a/tools/src/schedule/debian.rs +++ b/tools/src/schedule/debian.rs @@ -1,6 +1,6 @@ use crate::args::PkgsSync; use crate::schedule::{Pkg, fetch_url_or_path}; -use lzma::LzmaReader; +use xz2::read::XzDecoder; use rebuilderd_common::{PkgGroup, PkgArtifact}; use rebuilderd_common::errors::*; use std::collections::HashMap; @@ -194,7 +194,7 @@ impl AnyhowTryFrom for DebianBinPkg { } pub fn extract_pkg>(bytes: &[u8]) -> Result> { - let r = LzmaReader::new_decompressor(bytes)?; + let r = XzDecoder::new(bytes); let r = BufReader::new(r); extract_pkgs_uncompressed(r) }