From 8b19e40253b36878201d79b5eaa81924b6591d08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20K=C3=B6hl?= Date: Thu, 9 May 2024 19:14:07 +0200 Subject: [PATCH] feat: explicit image sizes --- crates/rugpi-bakery/src/bake/image.rs | 7 ++++++- crates/rugpi-bakery/src/project/images.rs | 1 + tests/bootstrap/recipes/setup-boot/steps/02-run.sh | 2 +- tests/bootstrap/rugpi-bakery.toml | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/rugpi-bakery/src/bake/image.rs b/crates/rugpi-bakery/src/bake/image.rs index 88c2b11..41a5099 100644 --- a/crates/rugpi-bakery/src/bake/image.rs +++ b/crates/rugpi-bakery/src/bake/image.rs @@ -32,7 +32,12 @@ pub fn make_image(image_config: &ImageConfig, src: &Path, image: &Path) -> Anyho fs::create_dir_all(parent).ok(); } info!("creating image (size: {} bytes)", size); - run!(["fallocate", "-l", "{size}", image])?; + if let Some(size) = &image_config.size { + println!("Allocate image of size {size}."); + run!(["fallocate", "-l", "{size}", image])?; + } else { + run!(["fallocate", "-l", "{size}", image])?; + } let layout = image_config.layout.clone().unwrap_or_else(pi_image_layout); sfdisk_apply_layout(image, layout.sfdisk_render())?; let disk_id = get_disk_id(image)?; diff --git a/crates/rugpi-bakery/src/project/images.rs b/crates/rugpi-bakery/src/project/images.rs index 10e5154..65aef9e 100644 --- a/crates/rugpi-bakery/src/project/images.rs +++ b/crates/rugpi-bakery/src/project/images.rs @@ -17,6 +17,7 @@ pub struct ImageConfig { /// Indicates which boot flow to use for the image. #[serde(default)] pub boot_flow: BootFlow, + pub size: Option, pub layout: Option, } diff --git a/tests/bootstrap/recipes/setup-boot/steps/02-run.sh b/tests/bootstrap/recipes/setup-boot/steps/02-run.sh index b971d95..9af9980 100755 --- a/tests/bootstrap/recipes/setup-boot/steps/02-run.sh +++ b/tests/bootstrap/recipes/setup-boot/steps/02-run.sh @@ -22,7 +22,7 @@ cat >"${RUGPI_ROOT_DIR}/boot/efi/loader/entries/rugpi-a.conf" <