Skip to content

Commit

Permalink
grubconfigs: move the GRUB2DIR creation earlier
Browse files Browse the repository at this point in the history
We add the GRUB2DIR creation in ece9120 but there is an earlier
use of that directory if there are dropins so let's move the
creation of the directory earlier before the dropins are processed.

I hit this because I'm testing out things on FCOS. Building a qemu
and metal image works just fine, because in that case we are doing
the MBR install using `grub2-install` and I guess that tool creates
the directory. In the metal4k case, though, there is no BIOS install
and thus we get here and the GRUB2DIR doesn't exist and bootupd fails.
  • Loading branch information
dustymabe committed Dec 11, 2023
1 parent 0cf4a3b commit baccac3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/grubconfigs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ pub(crate) fn install(target_root: &openat::Dir, efi: bool, write_uuid: bool) ->
root_dev != boot_dev
};

if !bootdir.exists(GRUB2DIR)? {
bootdir.create_dir(GRUB2DIR, 0o700)?;
}

let mut config = std::fs::read_to_string(Path::new(CONFIGDIR).join("grub-static-pre.cfg"))?;

let dropindir = openat::Dir::open(&Path::new(CONFIGDIR).join(DROPINDIR))?;
Expand Down Expand Up @@ -68,10 +72,6 @@ pub(crate) fn install(target_root: &openat::Dir, efi: bool, write_uuid: bool) ->
config.push_str(post.as_str());
}

if !bootdir.exists(GRUB2DIR)? {
bootdir.create_dir(GRUB2DIR, 0o700)?;
}

bootdir
.write_file_contents(format!("{GRUB2DIR}/grub.cfg"), 0o644, config.as_bytes())
.context("Copying grub-static.cfg")?;
Expand Down

0 comments on commit baccac3

Please sign in to comment.