@@ -15,7 +15,7 @@ use cap_std_ext::{
1515use clap:: ValueEnum ;
1616use composefs:: fs:: read_file;
1717use composefs:: tree:: { FileSystem , RegularFile } ;
18- use composefs_boot:: bootloader:: { PEType , EFI_ADDON_DIR_EXT , EFI_EXT } ;
18+ use composefs_boot:: bootloader:: { PEType , EFI_ADDON_DIR_EXT , EFI_ADDON_FILE_EXT , EFI_EXT } ;
1919use composefs_boot:: BootOps ;
2020use fn_error_context:: context;
2121use ostree_ext:: composefs:: {
@@ -815,38 +815,31 @@ pub(crate) fn setup_composefs_uki_boot(
815815 id : & Sha256HashValue ,
816816 entries : Vec < ComposefsBootEntry < Sha256HashValue > > ,
817817) -> Result < ( ) > {
818- let ( root_path, esp_device, bootloader, is_insecure_from_opts) = match setup_type {
818+ let ( root_path, esp_device, bootloader, is_insecure_from_opts, uki_addons ) = match setup_type {
819819 BootSetupType :: Setup ( ( root_setup, state, ..) ) => {
820820 if let Some ( v) = & state. config_opts . karg {
821821 if v. len ( ) > 0 {
822822 tracing:: warn!( "kargs passed for UKI will be ignored" ) ;
823823 }
824824 }
825825
826+ let Some ( cfs_opts) = & state. composefs_options else {
827+ anyhow:: bail!( "ComposeFS options not found" ) ;
828+ } ;
829+
826830 let esp_part = root_setup
827831 . device_info
828832 . partitions
829833 . iter ( )
830834 . find ( |p| p. parttype . as_str ( ) == ESP_GUID )
831835 . ok_or_else ( || anyhow ! ( "ESP partition not found" ) ) ?;
832836
833- let bootloader = state
834- . composefs_options
835- . as_ref ( )
836- . map ( |opts| opts. bootloader . clone ( ) )
837- . unwrap_or ( Bootloader :: default ( ) ) ;
838-
839- let is_insecure = state
840- . composefs_options
841- . as_ref ( )
842- . map ( |x| x. insecure )
843- . unwrap_or ( false ) ;
844-
845837 (
846838 root_setup. physical_root_path . clone ( ) ,
847839 esp_part. node . clone ( ) ,
848- bootloader,
849- is_insecure,
840+ cfs_opts. bootloader . clone ( ) ,
841+ cfs_opts. insecure ,
842+ cfs_opts. uki_addon . as_ref ( ) ,
850843 )
851844 }
852845
@@ -860,6 +853,7 @@ pub(crate) fn setup_composefs_uki_boot(
860853 get_esp_partition ( & sysroot_parent) ?. 0 ,
861854 bootloader,
862855 false ,
856+ None ,
863857 )
864858 }
865859 } ;
@@ -876,6 +870,32 @@ pub(crate) fn setup_composefs_uki_boot(
876870 }
877871
878872 ComposefsBootEntry :: Type2 ( entry) => {
873+ // If --uki-addon is not passed, we don't install any addon
874+ if matches ! ( entry. pe_type, PEType :: UkiAddon ) {
875+ let Some ( addons) = uki_addons else {
876+ continue ;
877+ } ;
878+
879+ let addon_name = entry
880+ . file_path
881+ . components ( )
882+ . last ( )
883+ . ok_or ( anyhow:: anyhow!( "Could not get UKI addon name" ) ) ?;
884+
885+ let addon_name = addon_name. as_str ( ) ?;
886+
887+ let addon_name =
888+ addon_name
889+ . strip_suffix ( EFI_ADDON_FILE_EXT )
890+ . ok_or ( anyhow:: anyhow!(
891+ "UKI addon doesn't end with {EFI_ADDON_DIR_EXT}"
892+ ) ) ?;
893+
894+ if !addons. iter ( ) . any ( |passed_addon| passed_addon == addon_name) {
895+ continue ;
896+ }
897+ }
898+
879899 let ret = write_pe_to_esp (
880900 & repo,
881901 & entry. file ,
0 commit comments