@@ -5,7 +5,7 @@ use std::path::Path;
55
66use anyhow:: { anyhow, Context , Result } ;
77use bootc_blockdev:: find_parent_devices;
8- use bootc_kernel_cmdline:: utf8:: Cmdline ;
8+ use bootc_kernel_cmdline:: utf8:: { Cmdline , Parameter } ;
99use bootc_mount:: inspect_filesystem_of_dir;
1010use bootc_mount:: tempmount:: TempMount ;
1111use camino:: { Utf8Path , Utf8PathBuf } ;
@@ -34,6 +34,7 @@ use schemars::JsonSchema;
3434use serde:: { Deserialize , Serialize } ;
3535
3636use crate :: bootc_composefs:: status:: get_sorted_grub_uki_boot_entries;
37+ use crate :: bootc_kargs:: kargs_from_composefs_filesystem;
3738use crate :: composefs_consts:: { TYPE1_ENT_PATH , TYPE1_ENT_PATH_STAGED } ;
3839use crate :: parsers:: bls_config:: { BLSConfig , BLSConfigType } ;
3940use crate :: parsers:: grub_menuconfig:: MenuEntry ;
@@ -51,7 +52,6 @@ use crate::{
5152 BOOT_LOADER_ENTRIES , COMPOSEFS_CMDLINE , ORIGIN_KEY_BOOT , ORIGIN_KEY_BOOT_DIGEST ,
5253 STAGED_BOOT_LOADER_ENTRIES , STATE_DIR_ABS , USER_CFG , USER_CFG_STAGED ,
5354 } ,
54- install:: RW_KARG ,
5555 spec:: { Bootloader , Host } ,
5656} ;
5757
@@ -377,7 +377,7 @@ pub(crate) fn setup_composefs_bls_boot(
377377) -> Result < String > {
378378 let id_hex = id. to_hex ( ) ;
379379
380- let ( root_path, esp_device, cmdline_refs, fs, bootloader) = match setup_type {
380+ let ( root_path, esp_device, mut cmdline_refs, fs, bootloader) = match setup_type {
381381 BootSetupType :: Setup ( ( root_setup, state, fs) ) => {
382382 // root_setup.kargs has [root=UUID=<UUID>, "rw"]
383383 let mut cmdline_options = Cmdline :: new ( ) ;
@@ -408,16 +408,53 @@ pub(crate) fn setup_composefs_bls_boot(
408408 let sysroot_parent = get_sysroot_parent_dev ( & storage. physical_root ) ?;
409409 let bootloader = host. require_composefs_booted ( ) ?. bootloader . clone ( ) ;
410410
411+ let current_cfg = match bootloader {
412+ Bootloader :: Grub => {
413+ let boot_dir = storage
414+ . physical_root
415+ . open_dir ( "boot" )
416+ . context ( "Opening boot" ) ?;
417+
418+ get_booted_bls ( & boot_dir) ?
419+ }
420+
421+ Bootloader :: Systemd => {
422+ let esp = get_esp_partition ( & sysroot_parent) ?. 0 ;
423+ let esp_mnt = mount_esp ( & esp) ?;
424+
425+ get_booted_bls ( & esp_mnt. fd ) ?
426+ }
427+ } ;
428+
429+ let mut cmdline = match current_cfg. cfg_type {
430+ BLSConfigType :: NonEFI { options, .. } => {
431+ let options = options
432+ . ok_or_else ( || anyhow:: anyhow!( "No 'options' found in BLS Config" ) ) ?;
433+
434+ Cmdline :: from ( options)
435+ }
436+
437+ _ => anyhow:: bail!( "Found NonEFI config" ) ,
438+ } ;
439+
440+ // Copy all cmdline args, replacing only `composefs=`
441+ let param = format ! ( "{COMPOSEFS_CMDLINE}={id_hex}" ) ;
442+ let param =
443+ Parameter :: parse ( & param) . context ( "Failed to create 'composefs=' parameter" ) ?;
444+ cmdline. add_or_modify ( & param) ;
445+
411446 (
412447 Utf8PathBuf :: from ( "/sysroot" ) ,
413448 get_esp_partition ( & sysroot_parent) ?. 0 ,
414- Cmdline :: from ( format ! ( "{RW_KARG} {COMPOSEFS_CMDLINE}={id_hex}" ) ) ,
449+ cmdline ,
415450 fs,
416451 bootloader,
417452 )
418453 }
419454 } ;
420455
456+ kargs_from_composefs_filesystem ( fs, & repo, & mut cmdline_refs) ?;
457+
421458 let is_upgrade = matches ! ( setup_type, BootSetupType :: Upgrade ( ..) ) ;
422459
423460 let ( entry_paths, _tmpdir_guard) = match bootloader {
0 commit comments