Skip to content

Commit

Permalink
Fix kernelArgs issue with LeapMicro 6.0 (#499)
Browse files Browse the repository at this point in the history
* Fix kernelArgs with LeapMicro 6.0

Due to changes in the grub cmdline the sed approach no longer works,
so instead we can run grub2-mkconfig via guestfish which should
re-generate the grub.cfg with the defaults applied

Closes: #498

* Add bug info to release notes
  • Loading branch information
hardys committed Jul 18, 2024
1 parent 0588601 commit 5125755
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 17 deletions.
2 changes: 2 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

## Bug Fixes

* [#498](https://github.com/suse-edge/edge-image-builder/issues/498) - Fix kernelArgs issue with Leap Micro 6.0

---

# v1.0.2
Expand Down
3 changes: 0 additions & 3 deletions pkg/build/grub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ func TestGenerateGRUBGuestfishCommands(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, commandString)

expectedFirstBoot := "sed -i '/ignition.platform/ s/$/ alpha beta /' /tmp/grub.cfg"
assert.Contains(t, commandString, expectedFirstBoot)

expectedDefault := "sed -i '/^GRUB_CMDLINE_LINUX_DEFAULT=\"/ s/\"$/ alpha beta \"/' /tmp/grub"
assert.Contains(t, commandString, expectedDefault)
}
Expand Down
4 changes: 0 additions & 4 deletions pkg/build/raw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ func TestWriteModifyScript(t *testing.T) {
expectedContains: []string{
fmt.Sprintf("guestfish --blocksize=$BLOCKSIZE --format=raw --rw -a %s", outputImageFilename),
fmt.Sprintf("copy-in %s", builder.context.CombustionDir),
"download /boot/grub2/grub.cfg /tmp/grub.cfg",
"btrfs filesystem label / INSTALL",
"sed -i '/ignition.platform/ s/$/ alpha beta /' /tmp/grub.cfg",
"truncate -s 64G",
"virt-resize --expand $ROOT_PART",
},
Expand All @@ -88,8 +86,6 @@ func TestWriteModifyScript(t *testing.T) {
renameFilesystem: false,
expectedContains: []string{
fmt.Sprintf("guestfish --blocksize=$BLOCKSIZE --format=raw --rw -a %s", outputImageFilename),
"download /boot/grub2/grub.cfg /tmp/grub.cfg",
"sed -i '/ignition.platform/ s/$/ alpha beta /' /tmp/grub.cfg",
},
expectedMissing: []string{
fmt.Sprintf("copy-in %s", builder.context.CombustionDir),
Expand Down
16 changes: 6 additions & 10 deletions pkg/build/templates/grub/guestfish-snippet.tpl
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
# Configure GRUB for first boot
# - Without this, the values wouldn't be used until after the first time the
# grub configuration is regenerated
download /boot/grub2/grub.cfg /tmp/grub.cfg
! sed -i '/ignition.platform/ s/$/ {{.KernelArgs}} /' /tmp/grub.cfg
upload /tmp/grub.cfg /boot/grub2/grub.cfg

# Configure GRUB defaults
# - Without this, when `transactional-update grub.cfg` is run it will overwrite
# settings used in the above change
# - So that the update below, and later`transactional-update grub.cfg` will persist the changes
download /etc/default/grub /tmp/grub
! sed -i '/^GRUB_CMDLINE_LINUX_DEFAULT="/ s/"$/ {{.KernelArgs}} "/' /tmp/grub
upload /tmp/grub /etc/default/grub
upload /tmp/grub /etc/default/grub

# Configure GRUB for first boot
# - This re-generates the grub.cfg applying the /etc/default/grub above
sh "grub2-mkconfig -o /boot/grub2/grub.cfg"

0 comments on commit 5125755

Please sign in to comment.