From fcdbb2c621544b00b6a57ee67591031b353d8ea3 Mon Sep 17 00:00:00 2001 From: Simon de Vlieger Date: Fri, 15 Dec 2023 14:09:07 +0100 Subject: [PATCH] anaconda: switch container-installer to fixed ks Use a fixed kickstart to cut corners, this needs a PoC as soon as possible. We need manual partitioning because we need to set the boot label on the `/boot` partition. It is possible that this won't be necessary in the future: https://github.com/rhinstaller/anaconda/pull/5363 We'll remove the kickstart literal once the PR is merged and the options used are merged into the kickstart stage. --- pkg/manifest/anaconda_installer_iso_tree.go | 51 +++++++++++++++++---- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/pkg/manifest/anaconda_installer_iso_tree.go b/pkg/manifest/anaconda_installer_iso_tree.go index d7e7594f5..6e282401d 100644 --- a/pkg/manifest/anaconda_installer_iso_tree.go +++ b/pkg/manifest/anaconda_installer_iso_tree.go @@ -5,6 +5,7 @@ import ( "path" "github.com/osbuild/images/pkg/container" + "github.com/osbuild/images/pkg/customizations/fsnode" "github.com/osbuild/images/pkg/customizations/users" "github.com/osbuild/images/pkg/disk" "github.com/osbuild/images/pkg/osbuild" @@ -55,6 +56,8 @@ type AnacondaInstallerISOTree struct { // Enable ISOLinux stage ISOLinux bool + + Files []*fsnode.File } func NewAnacondaInstallerISOTree(buildPipeline *Build, anacondaPipeline *AnacondaInstaller, rootfsPipeline *ISORootfsImg, bootTreePipeline *EFIBootTree) *AnacondaInstallerISOTree { @@ -76,6 +79,16 @@ func NewAnacondaInstallerISOTree(buildPipeline *Build, anacondaPipeline *Anacond return p } +func (p *AnacondaInstallerISOTree) getOSTreeCommitSources() []ostree.SourceSpec { + if p.OSTreeCommitSource == nil { + return nil + } + + return []ostree.SourceSpec{ + *p.OSTreeCommitSource, + } +} + func (p *AnacondaInstallerISOTree) getOSTreeCommits() []ostree.CommitSpec { if p.ostreeCommitSpec == nil { return nil @@ -99,6 +112,16 @@ func (p *AnacondaInstallerISOTree) getContainerSources() []container.SourceSpec } } +func (p *AnacondaInstallerISOTree) getInline() []string { + inlineData := []string{} + + // inline data for custom files + for _, file := range p.Files { + inlineData = append(inlineData, string(file.Data())) + } + + return inlineData +} func (p *AnacondaInstallerISOTree) getBuildPackages(_ Distro) []string { packages := []string{ "squashfs-tools", @@ -299,20 +322,28 @@ func (p *AnacondaInstallerISOTree) serialize() osbuild.Pipeline { images, manifests)) - kickstartOptions, err := osbuild.NewKickstartStageOptionsWithOSTreeContainer( - p.KSPath, - p.Users, - p.Groups, - path.Join("/run/install/repo", p.PayloadPath), - "oci", - "", - "") + kickstartFile, err := fsnode.NewFile(p.KSPath, nil, nil, nil, []byte(` +ostreecontainer --url=/run/install/repo/container --transport=oci --no-signature-verification +rootpw --lock +user --name fedora --groups wheel +lang en_US.UTF-8 +keyboard us +timezone UTC +clearpart --all +part /boot/efi --fstype=efi --size=512 --fsoptions="umask=0077" +part /boot --fstype=ext2 --size=1024 --label=boot +part swap --fstype=swap --size=1024 +part / --fstype=ext4 --grow +reboot --eject +`)) if err != nil { - panic("failed to create kickstartstage options") + panic(err) } - pipeline.AddStage(osbuild.NewKickstartStage(kickstartOptions)) + p.Files = []*fsnode.File{kickstartFile} + + pipeline.AddStages(osbuild.GenFileNodesStages(p.Files)...) } if p.OSPipeline != nil {