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

Add extra-cmdline flag to build-iso command #2072

Merged
merged 2 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/build-iso.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

"github.com/rancher/elemental-toolkit/v2/cmd/config"
"github.com/rancher/elemental-toolkit/v2/pkg/action"
"github.com/rancher/elemental-toolkit/v2/pkg/constants"
elementalError "github.com/rancher/elemental-toolkit/v2/pkg/error"
"github.com/rancher/elemental-toolkit/v2/pkg/types"
"github.com/rancher/elemental-toolkit/v2/pkg/utils"
Expand Down Expand Up @@ -139,6 +140,7 @@ func NewBuildISO(root *cobra.Command, addCheckRoot bool) *cobra.Command {
c.Flags().String("overlay-uefi", "", "Path of the overlayed uefi data")
c.Flags().String("overlay-iso", "", "Path of the overlayed iso data")
c.Flags().String("label", "", "Label of the ISO volume")
c.Flags().String("extra-cmdline", "", fmt.Sprintf("Extra kernel cmdline (defaults to '%s')", constants.ISODefaultExtraCmdline))
c.Flags().Bool("bootloader-in-rootfs", false, "Fetch ISO bootloader binaries from the rootfs")
c.Flags().Var(firmType, "firmware", "Firmware to install, only 'efi' is currently supported")
_ = c.Flags().MarkDeprecated("firmware", "'firmware' is deprecated. only efi firmware is supported.")
Expand Down
6 changes: 3 additions & 3 deletions pkg/action/build-iso.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const (
isoBootCatalog = "/boot/boot.catalog"
)

func grubCfgTemplate(arch string) string {
func grubCfgTemplate(arch, cmdline string) string {
return `search --no-floppy --file --set=root ` + constants.ISOKernelPath(arch) + `
set default=0
set timeout=5
Expand All @@ -42,7 +42,7 @@ func grubCfgTemplate(arch string) string {
menuentry "%s" --class os --unrestricted {
echo Loading kernel...
linux ($root)` + constants.ISOKernelPath(arch) + ` cdroot root=live:CDLABEL=%s rd.live.dir=` + constants.ISOLoaderPath(arch) +
` rd.live.squashimg=rootfs.squashfs security=selinux enforcing=0 console=tty1 console=ttyS0 elemental.disable elemental.setup=` +
` rd.live.squashimg=rootfs.squashfs ` + cmdline + ` elemental.disable elemental.setup=` +
constants.ISOCloudInitPath + `
echo Loading initrd...
initrd ($root)` + constants.ISOInitrdPath(arch) + `
Expand Down Expand Up @@ -222,7 +222,7 @@ func (b *BuildISOAction) renderGrubTemplate(rootDir string) error {
// Write grub.cfg file
return b.cfg.Fs.WriteFile(
filepath.Join(rootDir, constants.FallbackEFIPath, constants.GrubCfg),
[]byte(fmt.Sprintf(grubCfgTemplate(b.cfg.Platform.Arch), b.spec.GrubEntry, b.spec.Label)),
[]byte(fmt.Sprintf(grubCfgTemplate(b.cfg.Platform.Arch, b.spec.ExtraCmdline), b.spec.GrubEntry, b.spec.Label)),
constants.FilePerm,
)
}
Expand Down
11 changes: 6 additions & 5 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,11 +538,12 @@ func NewDisk(cfg *types.BuildConfig) *types.DiskSpec {

func NewISO() *types.LiveISO {
return &types.LiveISO{
Label: constants.ISOLabel,
GrubEntry: constants.GrubDefEntry,
UEFI: []*types.ImageSource{},
Image: []*types.ImageSource{},
Firmware: types.EFI,
Label: constants.ISOLabel,
GrubEntry: constants.GrubDefEntry,
UEFI: []*types.ImageSource{},
Image: []*types.ImageSource{},
Firmware: types.EFI,
ExtraCmdline: constants.ISODefaultExtraCmdline,
}
}

Expand Down
9 changes: 5 additions & 4 deletions pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,11 @@ const (
SELinuxRelabelDir = "/run/systemd/relabel-extra.d"
SELinuxRelabelFile = "elemental.relabel"

ISORootFile = "rootfs.squashfs"
ISOEFIImg = "uefi.img"
ISOLabel = "COS_LIVE"
ISOCloudInitPath = LiveDir + "/iso-config"
ISORootFile = "rootfs.squashfs"
ISOEFIImg = "uefi.img"
ISOLabel = "COS_LIVE"
ISOCloudInitPath = LiveDir + "/iso-config"
ISODefaultExtraCmdline = "security=selinux enforcing=0 console=tty1 console=ttyS0"

MountLayoutPath = "/run/elemental/mount-layout.env"

Expand Down
1 change: 1 addition & 0 deletions pkg/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ type LiveISO struct {
GrubEntry string `yaml:"grub-entry-name,omitempty" mapstructure:"grub-entry-name"`
BootloaderInRootFs bool `yaml:"bootloader-in-rootfs" mapstructure:"bootloader-in-rootfs"`
Firmware string `yaml:"firmware,omitempty" mapstructure:"firmware"`
ExtraCmdline string `yaml:"extra-cmdline,omitempty" mapstructure:"extra-cmdline"`
}

// Sanitize checks the consistency of the struct, returns error
Expand Down
Loading