@@ -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 } ;
@@ -33,6 +33,7 @@ use rustix::{mount::MountFlags, path::Arg};
3333use schemars:: JsonSchema ;
3434use serde:: { Deserialize , Serialize } ;
3535
36+ use crate :: bootc_kargs:: kargs_from_composefs_filesystem;
3637use crate :: composefs_consts:: { TYPE1_ENT_PATH , TYPE1_ENT_PATH_STAGED } ;
3738use crate :: parsers:: bls_config:: { BLSConfig , BLSConfigType } ;
3839use 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
@@ -384,7 +384,7 @@ pub(crate) fn setup_composefs_bls_boot(
384384) -> Result < String > {
385385 let id_hex = id. to_hex ( ) ;
386386
387- let ( root_path, esp_device, cmdline_refs, fs, bootloader) = match setup_type {
387+ let ( root_path, esp_device, mut cmdline_refs, fs, bootloader) = match setup_type {
388388 BootSetupType :: Setup ( ( root_setup, state, postfetch, fs) ) => {
389389 // root_setup.kargs has [root=UUID=<UUID>, "rw"]
390390 let mut cmdline_options = Cmdline :: new ( ) ;
@@ -415,16 +415,53 @@ pub(crate) fn setup_composefs_bls_boot(
415415 let sysroot_parent = get_sysroot_parent_dev ( & storage. physical_root ) ?;
416416 let bootloader = host. require_composefs_booted ( ) ?. bootloader . clone ( ) ;
417417
418+ let current_cfg = match bootloader {
419+ Bootloader :: Grub => {
420+ let boot_dir = storage
421+ . physical_root
422+ . open_dir ( "boot" )
423+ . context ( "Opening boot" ) ?;
424+
425+ get_booted_bls ( & boot_dir) ?
426+ }
427+
428+ Bootloader :: Systemd => {
429+ let esp = get_esp_partition ( & sysroot_parent) ?. 0 ;
430+ let esp_mnt = mount_esp ( & esp) ?;
431+
432+ get_booted_bls ( & esp_mnt. fd ) ?
433+ }
434+ } ;
435+
436+ let mut cmdline = match current_cfg. cfg_type {
437+ BLSConfigType :: NonEFI { options, .. } => {
438+ let options = options
439+ . ok_or_else ( || anyhow:: anyhow!( "No 'options' found in BLS Config" ) ) ?;
440+
441+ Cmdline :: from ( options)
442+ }
443+
444+ _ => anyhow:: bail!( "Found NonEFI config" ) ,
445+ } ;
446+
447+ // Copy all cmdline args, replacing only `composefs=`
448+ let param = format ! ( "{COMPOSEFS_CMDLINE}={id_hex}" ) ;
449+ let param =
450+ Parameter :: parse ( & param) . context ( "Failed to create 'composefs=' parameter" ) ?;
451+ cmdline. add_or_modify ( & param) ;
452+
418453 (
419454 Utf8PathBuf :: from ( "/sysroot" ) ,
420455 get_esp_partition ( & sysroot_parent) ?. 0 ,
421- Cmdline :: from ( format ! ( "{RW_KARG} {COMPOSEFS_CMDLINE}={id_hex}" ) ) ,
456+ cmdline ,
422457 fs,
423458 bootloader,
424459 )
425460 }
426461 } ;
427462
463+ kargs_from_composefs_filesystem ( fs, & repo, & mut cmdline_refs) ?;
464+
428465 let is_upgrade = matches ! ( setup_type, BootSetupType :: Upgrade ( ..) ) ;
429466
430467 let ( entry_paths, _tmpdir_guard) = match bootloader {
0 commit comments