@@ -15,7 +15,7 @@ use cap_std_ext::{
15
15
use clap:: ValueEnum ;
16
16
use composefs:: fs:: read_file;
17
17
use 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 } ;
19
19
use composefs_boot:: BootOps ;
20
20
use fn_error_context:: context;
21
21
use ostree_ext:: composefs:: {
@@ -815,38 +815,31 @@ pub(crate) fn setup_composefs_uki_boot(
815
815
id : & Sha256HashValue ,
816
816
entries : Vec < ComposefsBootEntry < Sha256HashValue > > ,
817
817
) -> 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 {
819
819
BootSetupType :: Setup ( ( root_setup, state, ..) ) => {
820
820
if let Some ( v) = & state. config_opts . karg {
821
821
if v. len ( ) > 0 {
822
822
tracing:: warn!( "kargs passed for UKI will be ignored" ) ;
823
823
}
824
824
}
825
825
826
+ let Some ( cfs_opts) = & state. composefs_options else {
827
+ anyhow:: bail!( "ComposeFS options not found" ) ;
828
+ } ;
829
+
826
830
let esp_part = root_setup
827
831
. device_info
828
832
. partitions
829
833
. iter ( )
830
834
. find ( |p| p. parttype . as_str ( ) == ESP_GUID )
831
835
. ok_or_else ( || anyhow ! ( "ESP partition not found" ) ) ?;
832
836
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
-
845
837
(
846
838
root_setup. physical_root_path . clone ( ) ,
847
839
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 ( ) ,
850
843
)
851
844
}
852
845
@@ -860,6 +853,7 @@ pub(crate) fn setup_composefs_uki_boot(
860
853
get_esp_partition ( & sysroot_parent) ?. 0 ,
861
854
bootloader,
862
855
false ,
856
+ None ,
863
857
)
864
858
}
865
859
} ;
@@ -876,6 +870,31 @@ pub(crate) fn setup_composefs_uki_boot(
876
870
}
877
871
878
872
ComposefsBootEntry :: Type2 ( entry) => {
873
+ // If --uki-addon is not passed, we include all addons found
874
+ if let Some ( addons) = uki_addons {
875
+ match entry. pe_type {
876
+ PEType :: Uki => { /* no-op */ }
877
+
878
+ PEType :: UkiAddon => {
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 = addon_name. strip_suffix ( EFI_ADDON_FILE_EXT ) . ok_or (
888
+ anyhow:: anyhow!( "UKI addon doesn't end with {EFI_ADDON_DIR_EXT}" ) ,
889
+ ) ?;
890
+
891
+ if !addons. iter ( ) . any ( |passed_addon| passed_addon == addon_name) {
892
+ continue ;
893
+ }
894
+ }
895
+ }
896
+ }
897
+
879
898
let ret = write_pe_to_esp (
880
899
& repo,
881
900
& entry. file ,
0 commit comments