Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 15 additions & 0 deletions src/installer/unpack.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -37,6 +38,7 @@ pub enum ArchiveExtension {
GZ,
ZIP,
XZ,
BZ2,
Unknown,
}

Expand All @@ -51,6 +53,7 @@ impl ArchiveExtension {
".gz" | ".tgz" => Self::GZ,
".zip" => Self::ZIP,
".xz" => Self::XZ,
".bz2" => Self::BZ2,
_ => Self::Unknown,
}
}
Expand All @@ -75,6 +78,7 @@ pub fn unpack<P: AsRef<Path>>(
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),
}
}
Expand Down Expand Up @@ -109,3 +113,14 @@ fn unpack_zip<P: AsRef<Path>>(reader: ReaderWithProgress<Cursor<Bytes>>, destina

Ok(())
}

/// Unpacks bzip2 archives into the provided destination directory.
/// Could return an IO error.
fn unpack_bzip2<P: AsRef<Path>>(reader: ReaderWithProgress<Cursor<Bytes>>, 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(())
}
Loading