diff --git a/crates/rugpi-bakery/src/bake/image.rs b/crates/rugpi-bakery/src/bake/image.rs index 5cb1ab1..c6e51ae 100644 --- a/crates/rugpi-bakery/src/bake/image.rs +++ b/crates/rugpi-bakery/src/bake/image.rs @@ -8,7 +8,6 @@ use std::{ use anyhow::Context; use rugpi_common::{ - boot::BootFlow, disk::{ gpt::gpt_types, mbr::mbr_types, parse_size, DiskId, NumBlocks, Partition, PartitionTable, PartitionTableType, @@ -24,7 +23,7 @@ use xscript::{run, Run}; use crate::{ bake::targets::{ generic_grub_efi::initialize_grub, rpi_tryboot::initialize_tryboot, - rpi_uboot::initialize_uboot, + rpi_uboot::initialize_uboot, Target, }, project::images::{self, grub_efi_image_layout, pi_image_layout, ImageConfig, ImageLayout}, utils::prelude::*, @@ -54,21 +53,21 @@ pub fn make_image(config: &ImageConfig, src: &Path, image: &Path) -> Anyhow<()> // Initialize config and boot partitions based the selected on boot flow. info!("Initialize boot flow."); - if let Some(boot_flow) = config.boot_flow { - match boot_flow { - BootFlow::Tryboot => { + if let Some(target) = config.target { + match target { + Target::RpiTryboot => { initialize_tryboot(&config_dir, &boot_dir, &root_dir)?; } - BootFlow::UBoot => { + Target::RpiUboot => { initialize_uboot(config, &config_dir, &boot_dir, &root_dir)?; } - BootFlow::GrubEfi => { + Target::GenericGrubEfi => { initialize_grub(config, &config_dir)?; } } } // Always copy second stage boot scripts independently of the boot flow. - if config.boot_flow.is_some() { + if config.target.is_some() { info!("Copy second stage boot scripts."); copy_recursive( "/usr/share/rugpi/boot/u-boot/bin/second.scr", @@ -85,10 +84,10 @@ pub fn make_image(config: &ImageConfig, src: &Path, image: &Path) -> Anyhow<()> .layout .clone() .or_else(|| { - config.boot_flow.map(|boot_flow| match boot_flow { - BootFlow::Tryboot => pi_image_layout(), - BootFlow::UBoot => pi_image_layout(), - BootFlow::GrubEfi => grub_efi_image_layout(), + config.target.map(|target| match target { + Target::RpiTryboot => pi_image_layout(), + Target::RpiUboot => pi_image_layout(), + Target::GenericGrubEfi => grub_efi_image_layout(), }) }) .ok_or_else(|| anyhow!("image layout needs to be specified"))?; @@ -109,8 +108,8 @@ pub fn make_image(config: &ImageConfig, src: &Path, image: &Path) -> Anyhow<()> info!("Writing image partition table."); table.write(image)?; - if let Some(boot_flow) = &config.boot_flow { - if matches!(boot_flow, BootFlow::Tryboot | BootFlow::UBoot) { + if let Some(target) = &config.target { + if matches!(target, Target::RpiTryboot | Target::RpiUboot) { let disk_id = match table.disk_id { DiskId::Mbr(mbr_id) => mbr_id.into_raw(), _ => bail!("unsupported GPT partition layout"), diff --git a/crates/rugpi-bakery/src/bake/targets/mod.rs b/crates/rugpi-bakery/src/bake/targets/mod.rs index a199f95..9d95178 100644 --- a/crates/rugpi-bakery/src/bake/targets/mod.rs +++ b/crates/rugpi-bakery/src/bake/targets/mod.rs @@ -10,5 +10,4 @@ pub enum Target { GenericGrubEfi, RpiTryboot, RpiUboot, - Unknown, } diff --git a/crates/rugpi-bakery/src/project/images.rs b/crates/rugpi-bakery/src/project/images.rs index e13fc06..2278129 100644 --- a/crates/rugpi-bakery/src/project/images.rs +++ b/crates/rugpi-bakery/src/project/images.rs @@ -1,10 +1,8 @@ -use rugpi_common::{ - boot::BootFlow, - disk::{gpt::gpt_types, PartitionTableType, PartitionType}, -}; +use rugpi_common::disk::{gpt::gpt_types, PartitionTableType, PartitionType}; use serde::{Deserialize, Serialize}; use super::config::Architecture; +use crate::bake::targets::Target; #[derive(Debug, Clone, Deserialize)] #[serde(deny_unknown_fields)] @@ -15,7 +13,7 @@ pub struct ImageConfig { #[serde(default)] pub architecture: Architecture, /// Indicates which boot flow to use for the image. - pub boot_flow: Option, + pub target: Option, pub size: Option, pub layout: Option, } diff --git a/examples/debian-grub-efi/rugpi-bakery.toml b/examples/debian-grub-efi/rugpi-bakery.toml index 5669633..9848541 100644 --- a/examples/debian-grub-efi/rugpi-bakery.toml +++ b/examples/debian-grub-efi/rugpi-bakery.toml @@ -4,22 +4,21 @@ rugpi-extra = { git = "https://github.com/silitics/rugpi-extra.git", branch = "v [images.generic-amd64] layer = "generic-amd64" architecture = "amd64" -boot_flow = "grub-efi" +target = "generic-grub-efi" [images.generic-amd64-vm] layer = "generic-amd64" architecture = "amd64" -boot_flow = "grub-efi" +target = "generic-grub-efi" size = "16G" [images.generic-arm64] layer = "generic-arm64" architecture = "arm64" -boot_flow = "grub-efi" +target = "generic-grub-efi" [images.generic-arm64-vm] layer = "generic-arm64" architecture = "arm64" -boot_flow = "grub-efi" +target = "generic-grub-efi" size = "16G" - diff --git a/tests/rugpi-bakery.toml b/tests/rugpi-bakery.toml index 24af241..2adbbd8 100644 --- a/tests/rugpi-bakery.toml +++ b/tests/rugpi-bakery.toml @@ -3,17 +3,17 @@ rugpi-extra = { git = "https://github.com/silitics/rugpi-extra.git" } [images.tryboot] layer = "customized" -boot_flow = "tryboot" +target = "rpi-tryboot" [images.pi4] layer = "customized-pi4" -boot_flow = "tryboot" +target = "rpi-tryboot" [images.u-boot] layer = "customized" -boot_flow = "u-boot" +target = "rpi-uboot" [images.u-boot-armhf] layer = "customized" architecture = "armhf" -boot_flow = "u-boot" +target = "rpi-uboot"