-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathanaconda_container_installer.go
More file actions
161 lines (132 loc) · 5.49 KB
/
Copy pathanaconda_container_installer.go
File metadata and controls
161 lines (132 loc) · 5.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
package image
import (
"fmt"
"math/rand"
"github.com/osbuild/images/pkg/arch"
"github.com/osbuild/images/pkg/artifact"
"github.com/osbuild/images/pkg/container"
"github.com/osbuild/images/pkg/customizations/anaconda"
"github.com/osbuild/images/pkg/customizations/kickstart"
"github.com/osbuild/images/pkg/datasizes"
"github.com/osbuild/images/pkg/disk"
"github.com/osbuild/images/pkg/manifest"
"github.com/osbuild/images/pkg/osbuild"
"github.com/osbuild/images/pkg/platform"
"github.com/osbuild/images/pkg/runner"
)
type AnacondaContainerInstaller struct {
Base
InstallerCustomizations manifest.InstallerCustomizations
RootfsCompression string
Ref string
ContainerSource container.SourceSpec
InstallerPayload container.SourceSpec
ContainerRemoveSignatures bool
Kickstart *kickstart.Options
// Locale for the installer. This should be set to the same locale as the
// ISO OS payload, if known.
Locale string
// Filesystem type for the installed system as opposed to that of the ISO.
InstallRootfsType disk.FSType
// KernelVer is needed so that dracut finds it files
KernelVer string
// {Kernel,Initramfs}Path is needed for grub2.iso
KernelPath string
InitramfsPath string
// bootc installer cannot use /root as installer home
InstallerHome string
// BootcInstallVerb controls which directive to use in kickstart files.
// Valid values are "ostreecontainer" (default) and "bootc"
BootcInstallVerb string
}
func NewAnacondaContainerInstaller(platform platform.Platform, filename string, container container.SourceSpec, ref string) *AnacondaContainerInstaller {
return &AnacondaContainerInstaller{
Base: NewBase("bootc-installer", platform, filename),
ContainerSource: container,
Ref: ref,
}
}
func (img *AnacondaContainerInstaller) InstantiateManifestFromContainer(m *manifest.Manifest,
containers []container.SourceSpec,
runner runner.Runner,
rng *rand.Rand) (*artifact.Artifact, error) {
cnts := []container.SourceSpec{img.ContainerSource}
buildPipeline := manifest.NewBuildFromContainer(m, runner, cnts,
&manifest.BuildOptions{
ContainerBuildable: true,
})
anacondaPipeline := manifest.NewAnacondaInstaller(
manifest.AnacondaInstallerTypePayload,
buildPipeline,
img.platform,
nil, // repos
"kernel",
img.InstallerCustomizations,
)
// with bootc we need different kernel/initramfs paths
anacondaPipeline.BootcLivefsContainer = &img.ContainerSource
anacondaPipeline.KernelPath = img.KernelPath
anacondaPipeline.InitramfsPath = img.InitramfsPath
anacondaPipeline.SetKernelVer(img.KernelVer)
anacondaPipeline.InstallerHome = img.InstallerHome
anacondaPipeline.Biosdevname = (img.platform.GetArch() == arch.ARCH_X86_64)
anacondaPipeline.Checkpoint()
if anacondaPipeline.InstallerCustomizations.FIPS {
anacondaPipeline.InstallerCustomizations.EnabledAnacondaModules = append(
anacondaPipeline.InstallerCustomizations.EnabledAnacondaModules,
anaconda.ModuleSecurity,
)
}
anacondaPipeline.Locale = img.Locale
var rootfsImagePipeline *manifest.ISORootfsImg
switch img.InstallerCustomizations.ISORootfsType {
case manifest.SquashfsExt4Rootfs:
rootfsImagePipeline = manifest.NewISORootfsImg(buildPipeline, anacondaPipeline)
rootfsImagePipeline.Size = 4 * datasizes.GibiByte
default:
}
bootTreePipeline := manifest.NewEFIBootTree(buildPipeline, img.InstallerCustomizations.Product, img.InstallerCustomizations.OSVersion)
bootTreePipeline.Platform = img.platform
bootTreePipeline.UEFIVendor = img.platform.GetUEFIVendor()
bootTreePipeline.ISOLabel = img.InstallerCustomizations.ISOLabel
if img.Kickstart == nil {
img.Kickstart = &kickstart.Options{}
}
if img.Kickstart.Path == "" {
img.Kickstart.Path = osbuild.KickstartPathOSBuild
}
kernelOpts := []string{
fmt.Sprintf("inst.stage2=hd:LABEL=%s", img.InstallerCustomizations.ISOLabel),
fmt.Sprintf("inst.ks=hd:LABEL=%s:%s", img.InstallerCustomizations.ISOLabel, img.Kickstart.Path),
"console=tty0",
// XXX: we want the graphical installer eventually, just
// need to figure out the dependencies
"inst.text",
}
if anacondaPipeline.InstallerCustomizations.FIPS {
kernelOpts = append(kernelOpts, "fips=1")
}
kernelOpts = append(kernelOpts, img.InstallerCustomizations.KernelOptionsAppend...)
bootTreePipeline.KernelOpts = kernelOpts
isoTreePipeline := manifest.NewAnacondaInstallerISOTree(buildPipeline, anacondaPipeline, rootfsImagePipeline, bootTreePipeline)
isoTreePipeline.PartitionTable = efiBootPartitionTable(rng)
isoTreePipeline.Release = img.InstallerCustomizations.Release
isoTreePipeline.Kickstart = img.Kickstart
isoTreePipeline.BootcInstallVerb = img.BootcInstallVerb
isoTreePipeline.RootfsCompression = img.RootfsCompression
isoTreePipeline.RootfsType = img.InstallerCustomizations.ISORootfsType
// For ostree installers, always put the kickstart file in the root of the ISO
isoTreePipeline.PayloadPath = "/container"
isoTreePipeline.PayloadRemoveSignatures = img.ContainerRemoveSignatures
isoTreePipeline.ContainerSource = &img.InstallerPayload
isoTreePipeline.ISOBoot = img.InstallerCustomizations.ISOBoot
if anacondaPipeline.InstallerCustomizations.FIPS {
isoTreePipeline.KernelOpts = append(isoTreePipeline.KernelOpts, "fips=1")
}
isoTreePipeline.InstallRootfsType = img.InstallRootfsType
isoPipeline := manifest.NewISO(buildPipeline, isoTreePipeline, img.InstallerCustomizations.ISOLabel)
isoPipeline.SetFilename(img.filename)
isoPipeline.ISOBoot = img.InstallerCustomizations.ISOBoot
artifact := isoPipeline.Export()
return artifact, nil
}