From d39030b0dccad3e6edba118fdfc00b7e69e182f5 Mon Sep 17 00:00:00 2001 From: Max Rijkers Date: Mon, 2 Nov 2026 18:12:06 +0100 Subject: [PATCH 1/2] Add support for unpacking bzip2 formats --- Cargo.lock | 16 ++++++++++++++++ Cargo.toml | 1 + src/installer/unpack.rs | 15 +++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 137bd787..4a4d011e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -200,6 +200,15 @@ version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" +[[package]] +name = "bzip2" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a53fac24f34a81bc9954b5d6cfce0c21e18ec6959f44f56e8e90e4bb7c346c" +dependencies = [ + "libbz2-rs-sys", +] + [[package]] name = "cc" version = "1.4.7" @@ -1180,6 +1189,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "libbz2-rs-sys" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32f454fd6831a29c0e827ed075bca2a15be201bd57f4168f0fd1041124eab17e" + [[package]] name = "libc" version = "0.2.189" @@ -1475,6 +1490,7 @@ version = "0.0.5" dependencies = [ "assert_cmd", "bytes", + "bzip2", "chrono", "clap", "colored", diff --git a/Cargo.toml b/Cargo.toml index 5cd5349a..48acb772 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,7 @@ tempfile = "3.27.0" sha2 = { version = "0.11.0", default-features = false, features = ["alloc"] } hex = "0.4.3" zip = { version = "8.6.0", default-features = false, features = ["deflate", "deflate64"] } +bzip2 = "0.6.1" regex = "1.13.1" lzma-rust2 = { version = "0.23.0", default-features = false, features = ["std", "xz"]} lief = "1.0.0" diff --git a/src/installer/unpack.rs b/src/installer/unpack.rs index 4dccfa0b..074f96ca 100644 --- a/src/installer/unpack.rs +++ b/src/installer/unpack.rs @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-only use bytes::Bytes; +use bzip2::read::BzDecoder; use flate2::read::GzDecoder; use lzma_rust2::XzReader; use std::{io::Cursor, path::Path}; @@ -37,6 +38,7 @@ pub enum ArchiveExtension { GZ, ZIP, XZ, + BZ2, Unknown, } @@ -51,6 +53,7 @@ impl ArchiveExtension { ".gz" | ".tgz" => Self::GZ, ".zip" => Self::ZIP, ".xz" => Self::XZ, + ".bz2" => Self::BZ2, _ => Self::Unknown, } } @@ -75,6 +78,7 @@ pub fn unpack>( ArchiveExtension::GZ => unpack_gz(reader, destination_directory, keep_timestamp), ArchiveExtension::XZ => unpack_xz(reader, destination_directory, keep_timestamp), ArchiveExtension::ZIP => unpack_zip(reader, destination_directory), + ArchiveExtension::BZ2 => unpack_bzip2(reader, destination_directory, keep_timestamp), _ => Err(UnpackError::ExtensionNotSupported), } } @@ -109,3 +113,14 @@ fn unpack_zip>(reader: ReaderWithProgress>, destina Ok(()) } + +/// Unpacks bzip2 archives into the provided destination directory. +/// Could return an IO error. +fn unpack_bzip2>(reader: ReaderWithProgress>, destination_directory: P, keep_timestamp: bool) -> Result<()> { + let tar = BzDecoder::new(reader); + let mut archive = Archive::new(tar); + archive.set_preserve_mtime(keep_timestamp); + archive.unpack(&destination_directory).err_with_path("unpack bzip2 to", destination_directory.as_ref())?; + + Ok(()) +} From 1cb4059ae750e31bc6145a03e3e35f579a586fca Mon Sep 17 00:00:00 2001 From: Max Rijkers Date: Mon, 2 Nov 2026 21:16:48 +0100 Subject: [PATCH 2/2] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3419ae79..a9c69ba8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ### Added - The metadata repositories can now contain source files. +- Support for unpacking bzip2 file formats. ### Changes - The test environment now uses a fresh environment for each test and can be used in parallel.