You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add `fn get_ostree_bootloader()` to get `sysroot.bootloader` in
ostree repo config.
Add `fn set_ostree_bootloader(bootloader: &str)` to set
`sysroot.bootloader` value in ostree repo config.
/// Writes a stripped GRUB config to `stripped_config_name`, removing lines between
654
+
/// `### BEGIN /etc/grub.d/15_ostree ###` and `### END /etc/grub.d/15_ostree ###`.
655
+
fnstrip_grub_config_file(
656
+
current_config_content:implBufRead,
657
+
dirfd:&openat::Dir,
658
+
stripped_config_name:&str,
659
+
) -> Result<()>{
660
+
// mode = -rw-r--r-- (644)
661
+
letmut writer = BufWriter::new(
662
+
dirfd
663
+
.write_file(
664
+
stripped_config_name,
665
+
(S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)asmode_t,
666
+
)
667
+
.context("Failed to open temporary GRUB config")?,
668
+
);
669
+
670
+
letmut skip = false;
671
+
for line in current_config_content.lines(){
672
+
let line = line.context("Failed to read line from GRUB config")?;
673
+
if line == "### END /etc/grub.d/15_ostree ###"{
674
+
skip = false;
675
+
continue;
676
+
}
677
+
if skip {
678
+
continue;
679
+
}
680
+
if line == "### BEGIN /etc/grub.d/15_ostree ###"{
681
+
skip = true;
682
+
continue;
683
+
}
684
+
writer
685
+
.write_all(line.as_bytes())
686
+
.context("Failed to write stripped GRUB config")?;
687
+
writer
688
+
.write_all(b"\n")
689
+
.context("Failed to write stripped GRUB config")?;
690
+
}
691
+
692
+
writer
693
+
.flush()
694
+
.context("Failed to write stripped GRUB config")?;
695
+
696
+
Ok(())
697
+
}
698
+
705
699
#[cfg(test)]
706
700
mod tests {
707
701
usesuper::*;
@@ -714,4 +708,54 @@ mod tests {
714
708
assert_eq!(r.is_err(),true);
715
709
guard.teardown();
716
710
}
711
+
712
+
#[test]
713
+
fntest_strip_grub_config_file() -> Result<()>{
714
+
let root:&tempfile::TempDir = &tempfile::tempdir()?;
715
+
let root_path = root.path();
716
+
let rootd = openat::Dir::open(root_path)?;
717
+
let stripped_config = root_path.join("stripped");
718
+
let content = r"
719
+
### BEGIN /etc/grub.d/10_linux ###
720
+
721
+
### END /etc/grub.d/10_linux ###
722
+
723
+
### BEGIN /etc/grub.d/15_ostree ###
724
+
menuentry 'Red Hat Enterprise Linux CoreOS 4 (ostree)' --class gnu-linux --class gnu --class os --unrestricted 'ostree-0-a92522f9-74dc-456a-ae0c-05ba22bca976' {
0 commit comments