Create tar node for package.ron
directly from in memory data
This commit is contained in:
parent
b9116951d5
commit
26af277e28
@ -3,7 +3,7 @@ use {
|
|||||||
cli::cli,
|
cli::cli,
|
||||||
hpk::{Dependency, Specs, Version},
|
hpk::{Dependency, Specs, Version},
|
||||||
ron::ser::{to_writer_pretty, PrettyConfig},
|
ron::ser::{to_writer_pretty, PrettyConfig},
|
||||||
std::{error::Error, env, fs::File, io::BufWriter, path::PathBuf},
|
std::{env, error::Error, fs::File, io::BufWriter, path::PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use crate::Item;
|
use crate::Item;
|
||||||
use std::{path::PathBuf, fs};
|
use std::{fs, path::PathBuf};
|
||||||
|
use tar::Owner;
|
||||||
use zstd::Encoder;
|
use zstd::Encoder;
|
||||||
|
|
||||||
mod dependency;
|
mod dependency;
|
||||||
@ -101,10 +102,12 @@ impl Package {
|
|||||||
writer.write_all(s.as_bytes())?;
|
writer.write_all(s.as_bytes())?;
|
||||||
writer.flush()?;
|
writer.flush()?;
|
||||||
println!("{} written", outfile.display());
|
println!("{} written", outfile.display());
|
||||||
let dir = env::current_dir()?;
|
let node = Node::read_data_to_tar(
|
||||||
env::set_current_dir(outdir)?;
|
s.as_bytes(),
|
||||||
let node = Node::read_file_to_tar("package.ron")?;
|
"package.ron",
|
||||||
env::set_current_dir(dir)?;
|
&outfile.metadata()?,
|
||||||
|
Some(Owner::default()),
|
||||||
|
)?;
|
||||||
Ok(node)
|
Ok(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,9 +127,7 @@ pub fn create(path: &Path, specs: Specs, outdir: &Path) -> Result<(), Box<dyn Er
|
|||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.par_iter()
|
.par_iter()
|
||||||
.filter(|x| x.is_ok())
|
.filter(|x| x.is_ok())
|
||||||
.filter_map(|x| {
|
.filter_map(|x| Item::try_create(x.as_ref().unwrap().path().to_path_buf().as_path()).ok())
|
||||||
Item::try_create(x.as_ref().unwrap().path().to_path_buf().as_path()).ok()
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let mut plist = Plist::default();
|
let mut plist = Plist::default();
|
||||||
let mut archive = vec![];
|
let mut archive = vec![];
|
||||||
@ -147,10 +148,8 @@ pub fn create(path: &Path, specs: Specs, outdir: &Path) -> Result<(), Box<dyn Er
|
|||||||
let mut package: Package = specs.into();
|
let mut package: Package = specs.into();
|
||||||
package.plist = plist;
|
package.plist = plist;
|
||||||
package.size = totalsize;
|
package.size = totalsize;
|
||||||
println!("creating package.ron");
|
|
||||||
let node = package.save_ron_and_create_tar_node(&outdir)?.to_vec()?;
|
let node = package.save_ron_and_create_tar_node(&outdir)?.to_vec()?;
|
||||||
archive.extend(node);
|
archive.extend(node);
|
||||||
//archive.write_all(&[0; 9216])?;
|
|
||||||
let name = package.fullname();
|
let name = package.fullname();
|
||||||
let mut path = PathBuf::from(&name);
|
let mut path = PathBuf::from(&name);
|
||||||
path.set_extension("tar.zst");
|
path.set_extension("tar.zst");
|
||||||
|
Loading…
Reference in New Issue
Block a user