-
-
Notifications
You must be signed in to change notification settings - Fork 83
Description
gzip'ed cpio is what installer expects for the Payload entry in .pkg's.
I've tried my best to combine flate2 with cpio-archive.
Would it be possible to demo proper integration of cpio, wrapped inside of gzip compression?
I've been doing like:
let payload_file =
fs::File::create(&payload_pth)?;
let payload_gzencoder = flate2::GzBuilder::new()
.write(payload_file, flate2::Compression::default());
let mut payload_cpio_builder = cpio_archive::odc::OdcBuilder::new(payload_gzencoder);
// ...
payload_cpio_builder
.append_file_from_path(target_pth_cpio, p)?;
// ...
payload_cpio_builder
.into_inner()?
.finish()?;But I'm not sure if flate2 is properly using the lifetime to automatically close the gzencoder writer. Or maybe it's closing it too early?
If I change the code to pass &mut payload_gzencoder to the cpio builder constructor so that I can then call .finish() on that after finishing the cpio builder... But then I still get Rust compilation errors. odc builder seems to want to entirely own the writer.
everything looks good as far as the xar, gunzip, tar tzvf, and cpio commands are concerned. I am able to manually extract all the files without issue. And yet, the darn installer continues to trigger strange cpio read errors.