Skip to content

Commit

Permalink
pkg/boot/grub: add support for grub devicetree command
Browse files Browse the repository at this point in the history
Signed-off-by: Tobias Heider <[email protected]>
  • Loading branch information
tobhe authored and rminnich committed Aug 1, 2024
1 parent eebbb4b commit 0eb397f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/boot/boottest/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ func LinuxImageToJSON(li *boot.LinuxImage) map[string]interface{} {
if li.Initrd != nil {
m["initrd"] = module(li.Initrd)
}
if li.DTB != nil {
m["dtb"] = module(li.DTB)
}
return m
}

Expand Down
9 changes: 9 additions & 0 deletions pkg/boot/grub/grub.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,15 @@ func (c *parser) append(ctx context.Context, config string) error {
return err
}

case "devicetree":
if e, ok := c.linuxEntries[c.curEntry]; ok {
dtb, err := c.getFile(arg)
if err != nil {
return err
}
e.DTB = dtb
}

case "menuentry":
c.curEntry = strconv.Itoa(c.numEntry)
c.curLabel = arg
Expand Down
3 changes: 3 additions & 0 deletions pkg/boot/grub/testdata_new/ubuntu_16_04_boot.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"kernel": {
"url": "file:///testdata_new/ubuntu_16_04_boot/vmlinuz-4.10.0-42-generic.efi.signed"
},
"dtb": {
"url": "file:///testdata_new/ubuntu_16_04_boot/dtb-4.10.0-42-generic"
},
"name": "Ubuntu",
"rank": "0"
},
Expand Down
1 change: 1 addition & 0 deletions pkg/boot/grub/testdata_new/ubuntu_16_04_boot/grub/grub.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menu
fi
linux /vmlinuz-4.10.0-42-generic.efi.signed root=/dev/mapper/ubuntu--vg-root ro quiet splash $vt_handoff
initrd /initrd.img-4.10.0-42-generic
devicetree /dtb-4.10.0-42-generic
}
submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-UUID2' {
menuentry 'Ubuntu, with Linux 4.10.0-42-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.10.0-42-generic-advanced-UUID2' {
Expand Down

0 comments on commit 0eb397f

Please sign in to comment.