From 67bd32e84452bf955d339f4941adcfe5efc3aa88 Mon Sep 17 00:00:00 2001 From: Mathias-Boulay Date: Tue, 23 Apr 2024 10:28:38 +0200 Subject: [PATCH] refactor: use a subfolder by default Signed-off-by: Mathias-Boulay --- src/fs-gen/src/image_builder.rs | 2 +- src/fs-gen/src/main.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fs-gen/src/image_builder.rs b/src/fs-gen/src/image_builder.rs index 278a4ff..4566f5a 100644 --- a/src/fs-gen/src/image_builder.rs +++ b/src/fs-gen/src/image_builder.rs @@ -44,7 +44,7 @@ fn new_passthroughfs_layer(rootdir: &str) -> Result { /// Ensure a destination folder is created fn ensure_folder_created(output_folder: &Path) -> Result<()> { - let result = fs::create_dir(output_folder); + let result = fs::create_dir_all(output_folder); // If the file already exists, we're fine if result.is_err() { diff --git a/src/fs-gen/src/main.rs b/src/fs-gen/src/main.rs index 618d0cd..3a68fb0 100644 --- a/src/fs-gen/src/main.rs +++ b/src/fs-gen/src/main.rs @@ -13,6 +13,7 @@ fn main() { println!("Hello, world!, {:?}", args); let layers_subdir = args.temp_directory.clone().join("layers/"); + let output_subdir = args.temp_directory.clone().join("output/"); let overlay_subdir = args.temp_directory.clone().join("overlay/"); // TODO: better organise layers and OverlayFS build in the temp directory @@ -28,10 +29,9 @@ fn main() { } // FIXME: use a subdir of the temp directory instead - let path = Path::new(overlay_subdir.as_path()); + let path = Path::new(output_subdir.as_path()); - merge_layer(&layers_paths, path, &args.temp_directory.clone()) - .expect("Merging layers failed"); + merge_layer(&layers_paths, path, &overlay_subdir).expect("Merging layers failed"); create_init_file(path); generate_initramfs(path, Path::new(args.output_file.as_path())); }