added .deb extraction
This commit is contained in:
parent
0ed105ba4a
commit
1a4e6ddb3f
5 changed files with 42 additions and 9 deletions
11
Cargo.lock
generated
11
Cargo.lock
generated
|
|
@ -1,6 +1,6 @@
|
||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "adler"
|
name = "adler"
|
||||||
|
|
@ -28,6 +28,12 @@ dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ar"
|
||||||
|
version = "0.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d67af77d68a931ecd5cbd8a3b5987d63a1d1d1278f7f6a60ae33db485cdebb69"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
|
@ -832,8 +838,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sk_extract"
|
name = "sk_extract"
|
||||||
version = "0.9.0"
|
version = "1.0.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"ar",
|
||||||
"bzip2",
|
"bzip2",
|
||||||
"data-encoding",
|
"data-encoding",
|
||||||
"flate2",
|
"flate2",
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
ar = "0.9.0"
|
||||||
bzip2 = "0.4.4"
|
bzip2 = "0.4.4"
|
||||||
data-encoding = "2.4.0"
|
data-encoding = "2.4.0"
|
||||||
flate2 = "1.0.27"
|
flate2 = "1.0.27"
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ use lzma::reader::LzmaReader;
|
||||||
use flate2::read::GzDecoder;
|
use flate2::read::GzDecoder;
|
||||||
use bzip2::read::BzDecoder;
|
use bzip2::read::BzDecoder;
|
||||||
use unrar::Archive;
|
use unrar::Archive;
|
||||||
|
use ar;
|
||||||
|
|
||||||
/// Extracts files from a ZIP archive.
|
/// Extracts files from a ZIP archive.
|
||||||
///
|
///
|
||||||
|
|
@ -366,3 +367,21 @@ pub fn extract_txz(input_path: &Path, output_directory: &Path) -> Result<(), io:
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn extract_deb(input_path: &Path,) -> Result<(),io::Error>{
|
||||||
|
let input_file =File::open(&input_path).unwrap();
|
||||||
|
// Read an archive from the file foo.a:
|
||||||
|
let mut archive = ar::Archive::new(&input_file);
|
||||||
|
// Iterate over all entries in the archive:
|
||||||
|
while let Some(entry_result) = archive.next_entry() {
|
||||||
|
let mut entry = entry_result.unwrap();
|
||||||
|
// Create a new file with the same name as the archive entry:
|
||||||
|
let mut file = File::create(
|
||||||
|
str::from_utf8(entry.header().identifier()).unwrap(),
|
||||||
|
).unwrap();
|
||||||
|
// The Entry object also acts as an io::Read, so we can easily copy the
|
||||||
|
// contents of the archive entry into the file:
|
||||||
|
io::copy(&mut entry, &mut file).unwrap();
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
|
||||||
20
src/main.rs
20
src/main.rs
|
|
@ -14,7 +14,7 @@ use sk_extract::extractors::{
|
||||||
// extract_arj,
|
// extract_arj,
|
||||||
// extract_cab,
|
// extract_cab,
|
||||||
// extract_chm,
|
// extract_chm,
|
||||||
// extract_deb,
|
extract_deb,
|
||||||
// extract_dmg,
|
// extract_dmg,
|
||||||
// extract_iso,
|
// extract_iso,
|
||||||
// extract_lzh,
|
// extract_lzh,
|
||||||
|
|
@ -186,6 +186,17 @@ fn run() -> i32 {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
"deb" => {
|
||||||
|
let output_directory = Path::new("output_directory"); // Change this to your desired output directory
|
||||||
|
if let Err(err) = fs::create_dir_all(&output_directory) {
|
||||||
|
println!("Error creating output directory: {}", err);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if let Err(err) = extract_deb(&fname) {
|
||||||
|
println!("Error extracting DEB: {}", err);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
|
|
||||||
"arj" => {
|
"arj" => {
|
||||||
|
|
@ -206,12 +217,7 @@ fn run() -> i32 {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"deb" => {
|
|
||||||
if let Err(err) = extract_deb(&fname) {
|
|
||||||
println!("Error extracting DEB: {}", err);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"dmg" => {
|
"dmg" => {
|
||||||
if let Err(err) = extract_dmg(&fname) {
|
if let Err(err) = extract_dmg(&fname) {
|
||||||
println!("Error extracting DMG: {}", err);
|
println!("Error extracting DMG: {}", err);
|
||||||
|
|
|
||||||
BIN
test_data/busybox_1.35.0-4+b3_amd64.deb
Normal file
BIN
test_data/busybox_1.35.0-4+b3_amd64.deb
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue