MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / create_rootfs_archive_from_dir

Function create_rootfs_archive_from_dir

crates/openshell-driver-vm/src/rootfs.rs:62–81  ·  view source on GitHub ↗
(source: &Path, archive_path: &Path)

Source from the content-addressed store, hash-verified

60
61#[cfg(test)]
62pub fn create_rootfs_archive_from_dir(source: &Path, archive_path: &Path) -> Result<(), String> {
63 if let Some(parent) = archive_path.parent() {
64 fs::create_dir_all(parent).map_err(|e| format!("create {}: {e}", parent.display()))?;
65 }
66
67 let file = File::create(archive_path)
68 .map_err(|e| format!("create {}: {e}", archive_path.display()))?;
69 let writer = BufWriter::new(file);
70 let mut builder = tar::Builder::new(writer);
71 append_rootfs_tree_to_archive(&mut builder, source, Path::new("")).map_err(|e| {
72 format!(
73 "archive {} into {}: {e}",
74 source.display(),
75 archive_path.display()
76 )
77 })?;
78 builder
79 .finish()
80 .map_err(|e| format!("finalize {}: {e}", archive_path.display()))
81}
82
83pub fn create_rootfs_image_from_dir(source: &Path, image_path: &Path) -> Result<(), String> {
84 let image_size = rootfs_image_size_bytes(source)?;

Calls 1