Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grubconfigs: move the GRUB2DIR creation earlier #583

Merged
merged 1 commit into from
Dec 11, 2023

Conversation

dustymabe
Copy link
Member

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.

Copy link
Member

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with this as is but shouldn't we delete the later creation then?

@dustymabe
Copy link
Member Author

hmm. really odd.. my local git diff HEAD^ shows me:

$ git diff HEAD^
diff --git a/src/grubconfigs.rs b/src/grubconfigs.rs
index 8b4b0c9..dbf4869 100644
--- a/src/grubconfigs.rs
+++ b/src/grubconfigs.rs
@@ -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))?;
@@ -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")?;

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.
@dustymabe
Copy link
Member Author

oh I see. the second half of the change didn't git added to the commit when I did git add --patch.. Fixed now!

@cgwalters cgwalters merged commit a5388f6 into coreos:main Dec 11, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants