grub2: new grub2 stage options constructor for Unified configs
New constructor for unified grub2 setups [0]. Having this separate constructor lets us have different logic for unified and non-unified cases and also have fewer function parameters. [0] https://fedoraproject.org/wiki/Changes/UnifyGrubConfig Co-Authored-By: Christian Kellner <christian@kellner.me>
This commit is contained in:
parent
a7c702c4ae
commit
83ce9aa4ef
1 changed files with 41 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ package osbuild2
|
|||
import (
|
||||
"github.com/google/uuid"
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
"github.com/osbuild/osbuild-composer/internal/common"
|
||||
"github.com/osbuild/osbuild-composer/internal/disk"
|
||||
)
|
||||
|
||||
|
|
@ -22,6 +23,7 @@ type GRUB2StageOptions struct {
|
|||
UEFI *GRUB2UEFI `json:"uefi,omitempty"`
|
||||
SavedEntry string `json:"saved_entry,omitempty"`
|
||||
Greenboot bool `json:"greenboot,omitempty"`
|
||||
WriteCmdLine *bool `json:"write_cmdline,omitempty"`
|
||||
}
|
||||
|
||||
type GRUB2UEFI struct {
|
||||
|
|
@ -83,3 +85,42 @@ func NewGrub2StageOptions(pt *disk.PartitionTable,
|
|||
|
||||
return &stageOptions
|
||||
}
|
||||
|
||||
func NewGrub2StageOptionsUnified(pt *disk.PartitionTable,
|
||||
kernelVer string,
|
||||
uefi bool,
|
||||
legacy string,
|
||||
vendor string,
|
||||
install bool) *GRUB2StageOptions {
|
||||
|
||||
rootFs := pt.FindMountable("/")
|
||||
if rootFs == nil {
|
||||
panic("root filesystem must be defined for grub2 stage, this is a programming error")
|
||||
}
|
||||
|
||||
stageOptions := GRUB2StageOptions{
|
||||
RootFilesystemUUID: uuid.MustParse(rootFs.GetFSSpec().UUID),
|
||||
Legacy: legacy,
|
||||
WriteCmdLine: common.BoolToPtr(false),
|
||||
}
|
||||
|
||||
bootFs := pt.FindMountable("/boot")
|
||||
if bootFs != nil {
|
||||
bootFsUUID := uuid.MustParse(bootFs.GetFSSpec().UUID)
|
||||
stageOptions.BootFilesystemUUID = &bootFsUUID
|
||||
}
|
||||
|
||||
if uefi {
|
||||
stageOptions.UEFI = &GRUB2UEFI{
|
||||
Vendor: vendor,
|
||||
Install: install,
|
||||
Unified: true,
|
||||
}
|
||||
}
|
||||
|
||||
if kernelVer != "" {
|
||||
stageOptions.SavedEntry = "ffffffffffffffffffffffffffffffff-" + kernelVer
|
||||
}
|
||||
|
||||
return &stageOptions
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue