Skip to content

Commit

Permalink
Move to liblzma
Browse files Browse the repository at this point in the history
  • Loading branch information
ajeetdsouza committed Sep 7, 2024
1 parent acf10d2 commit a5854ad
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 29 deletions.
38 changes: 21 additions & 17 deletions rust/Cargo.lock

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

2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ clap = { version = "4.2.1", features = ["derive"] }
color-print = "0.3.4"
hex = "0.4.3"
indicatif = "0.17.3"
liblzma = { version = "0.3.4", features = ["static"] }
memmap2 = "0.7.0"
nom = "7.1.3"
nom-derive = "0.10.1"
prost = "0.11.8"
rayon = "1.7.0"
rust-lzma = { version = "0.6.0", features = ["static"] }
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.115"
sha2 = "0.10.6"
Expand Down
15 changes: 9 additions & 6 deletions rust/src/core/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::sync::{Arc, Mutex};

use anyhow::{bail, ensure, Context as _, Result};
use bzip2::read::BzDecoder;
use lzma::LzmaReader;
// use lzma::LzmaReader;
use memmap2::{Mmap, MmapMut};
use prost::Message as _;
use rayon::ThreadPoolBuilder;
Expand Down Expand Up @@ -251,11 +251,14 @@ impl ExtractOptions {
.context("Error in REPLACE_BZ operation")
}
Some(Type::ReplaceXz) => {
let data = Self::extract_data(op, payload).context("Error extracting data")?;
let mut decoder = LzmaReader::new_decompressor(data)
.context("Unable to initialize lzma decoder")?;
Self::run_op_replace(&mut decoder, &mut dst_extents, block_size)
.context("Error in REPLACE_XZ operation")
todo!()
// let data = Self::extract_data(op, payload).context("Error
// extracting data")?; let mut decoder =
// LzmaReader::new_decompressor(data)
// .context("Unable to initialize lzma decoder")?;
// Self::run_op_replace(&mut decoder, &mut dst_extents,
// block_size) .context("Error in REPLACE_XZ
// operation")
}
Some(Type::Zero) => Ok(()), // This is a no-op since the partition is already zeroed
Some(op) => bail!("Unimplemented operation: {op:?}"),
Expand Down
8 changes: 3 additions & 5 deletions rust/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ use anyhow::{bail, ensure, Context as _, Error, Result};
use bzip2::read::BzDecoder;
use chromeos_update_engine::install_operation::Type;
use chromeos_update_engine::{DeltaArchiveManifest, InstallOperation, PartitionUpdate};
use clap::Parser;
pub use extract::ExtractOptions;
use lzma::LzmaReader;
use liblzma::read::XzDecoder;
use memmap2::{Mmap, MmapMut};
use payload::Payload;
use prost::Message as _;
Expand Down Expand Up @@ -155,7 +154,7 @@ impl<'a> ExtractOptions2<'a> {
partition: SyncUnsafeCell::new(partition),
total_ops,
total_ops_completed: &total_ops_completed,
progress_reporter: &*self.progress_reporter,
progress_reporter: self.progress_reporter,
error: &error,
};
scope.spawn_broadcast(move |_, ctx| {
Expand Down Expand Up @@ -342,8 +341,7 @@ impl Task<'_> {
}
Some(Type::ReplaceXz) => {
let data = self.extract_data(op).context("Error extracting data")?;
let mut decoder = LzmaReader::new_decompressor(data)
.context("Unable to initialize lzma decoder")?;
let mut decoder = XzDecoder::new(data);
self.run_op_replace(&mut decoder, &mut dst_extents)
.context("Error in REPLACE_XZ operation")
}
Expand Down

0 comments on commit a5854ad

Please sign in to comment.