From 4ed6dd5367b7a65480f491701ea025af2af93195 Mon Sep 17 00:00:00 2001 From: Simon de Vlieger Date: Tue, 5 Aug 2025 13:22:59 +0200 Subject: [PATCH] image-installer: apply `kernel.append` Append the `kernel.append` customization to installer images images of the `image-installer` type. Signed-off-by: Simon de Vlieger --- pkg/image/anaconda_tar_installer.go | 2 ++ pkg/image/installer_image_test.go | 36 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/pkg/image/anaconda_tar_installer.go b/pkg/image/anaconda_tar_installer.go index 5894afa641..fe015f7856 100644 --- a/pkg/image/anaconda_tar_installer.go +++ b/pkg/image/anaconda_tar_installer.go @@ -178,6 +178,7 @@ func (img *AnacondaTarInstaller) InstantiateManifest(m *manifest.Manifest, kernelOpts = append(kernelOpts, "fips=1") } kernelOpts = append(kernelOpts, img.AdditionalKernelOpts...) + kernelOpts = append(kernelOpts, img.OSCustomizations.KernelOptionsAppend...) bootTreePipeline.KernelOpts = kernelOpts osPipeline := manifest.NewOS(buildPipeline, img.Platform, repos) @@ -200,6 +201,7 @@ func (img *AnacondaTarInstaller) InstantiateManifest(m *manifest.Manifest, isoTreePipeline.OSPipeline = osPipeline isoTreePipeline.KernelOpts = img.AdditionalKernelOpts + isoTreePipeline.KernelOpts = append(isoTreePipeline.KernelOpts, img.OSCustomizations.KernelOptionsAppend...) if img.OSCustomizations.FIPS { isoTreePipeline.KernelOpts = append(isoTreePipeline.KernelOpts, "fips=1") } diff --git a/pkg/image/installer_image_test.go b/pkg/image/installer_image_test.go index e2b27a817e..4492cfd64f 100644 --- a/pkg/image/installer_image_test.go +++ b/pkg/image/installer_image_test.go @@ -708,6 +708,22 @@ func findDracutStageOptions(t *testing.T, mf manifest.OSBuildManifest, pipelineN return modules, addModules, drivers, addDrivers } +func findGrub2IsoStageOptions(t *testing.T, mf manifest.OSBuildManifest, pipelineName string) []string { + pipeline := findPipelineFromOsbuildManifest(t, mf, pipelineName) + assert.NotNil(t, pipeline) + stage := findStageFromOsbuildPipeline(t, pipeline, "org.osbuild.grub2.iso") + assert.NotNil(t, stage) + stageOptions := stage["options"].(map[string]any) + assert.NotNil(t, stageOptions) + + stageKernelOptions := stageOptions["kernel"].(map[string]any) + assert.NotNil(t, stageKernelOptions) + + kernelOpts := getStageOptions(stageKernelOptions, "opts") + + return kernelOpts +} + func TestContainerInstallerDracut(t *testing.T) { img := image.NewAnacondaContainerInstaller(container.SourceSpec{}, "") img.Product = product @@ -786,3 +802,23 @@ func TestTarInstallerDracut(t *testing.T) { assert.Subset(t, addModules, testModules) assert.Subset(t, addDrivers, testDrivers) } + +func TestTarInstallerKernelOpts(t *testing.T) { + img := image.NewAnacondaTarInstaller() + img.Product = product + img.OSVersion = osversion + img.ISOLabel = isolabel + + testOpts := []string{"foo=1", "bar=2"} + + img.AdditionalKernelOpts = testOpts + + assert.NotNil(t, img) + img.Platform = testPlatform + mfs := instantiateAndSerialize(t, img, mockPackageSets(), nil, nil) + + opts := findGrub2IsoStageOptions(t, manifest.OSBuildManifest(mfs), "efiboot-tree") + + assert.NotNil(t, opts) + assert.Subset(t, opts, testOpts) +}