From 6d293649fb3effeb5b22c8a413bce12fcab7caed 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 | 50 ++++++++++++++++----- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/pkg/manifest/anaconda_installer_iso_tree.go b/pkg/manifest/anaconda_installer_iso_tree.go index d7e7594f5e..4198974685 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,15 @@ func NewAnacondaInstallerISOTree(buildPipeline *Build, anacondaPipeline *Anacond return p } +func (p *AnacondaInstallerISOTree) getOSTreeCommitSources() []ostree.SourceSpec { + if p.OSTreeCommitSource == nil { + return []ostree.SourceSpec{} + } + return []ostree.SourceSpec{ + *p.OSTreeCommitSource, + } +} + func (p *AnacondaInstallerISOTree) getOSTreeCommits() []ostree.CommitSpec { if p.ostreeCommitSpec == nil { return nil @@ -99,6 +111,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 +321,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 {