-
Notifications
You must be signed in to change notification settings - Fork 44
/
ostree_simplified_installer.go
161 lines (128 loc) · 4.82 KB
/
ostree_simplified_installer.go
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/internal/environment"
"github.com/osbuild/images/internal/workload"
"github.com/osbuild/images/pkg/arch"
"github.com/osbuild/images/pkg/artifact"
"github.com/osbuild/images/pkg/customizations/fdo"
"github.com/osbuild/images/pkg/customizations/ignition"
"github.com/osbuild/images/pkg/manifest"
"github.com/osbuild/images/pkg/platform"
"github.com/osbuild/images/pkg/rpmmd"
"github.com/osbuild/images/pkg/runner"
)
type OSTreeSimplifiedInstaller struct {
Base
// Raw image that will be created and embedded
rawImage *OSTreeDiskImage
Platform platform.Platform
OSCustomizations manifest.OSCustomizations
Environment environment.Environment
Workload workload.Workload
ExtraBasePackages rpmmd.PackageSet
ISOLabel string
// ISO label template (architecture-free)
ISOLabelTmpl string
// Product string for ISO buildstamp
Product string
// OSVersion string for ISO buildstamp
OSVersion string
// Variant string for ISO buildstamp
Variant string
// OSName for ostree deployment
OSName string
installDevice string
Filename string
FDO *fdo.Options
// Ignition firstboot configuration options
IgnitionFirstBoot *ignition.FirstBootOptions
// Ignition embedded configuration options
IgnitionEmbedded *ignition.EmbeddedOptions
AdditionalDracutModules []string
}
func NewOSTreeSimplifiedInstaller(rawImage *OSTreeDiskImage, installDevice string) *OSTreeSimplifiedInstaller {
return &OSTreeSimplifiedInstaller{
Base: NewBase("ostree-simplified-installer"),
rawImage: rawImage,
installDevice: installDevice,
}
}
func (img *OSTreeSimplifiedInstaller) InstantiateManifest(m *manifest.Manifest,
repos []rpmmd.RepoConfig,
runner runner.Runner,
rng *rand.Rand) (*artifact.Artifact, error) {
buildPipeline := manifest.NewBuild(m, runner, repos, nil)
buildPipeline.Checkpoint()
imageFilename := "image.raw.xz"
// image in simplified installer is always compressed
compressedImage := manifest.NewXZ(buildPipeline, baseRawOstreeImage(img.rawImage, buildPipeline, nil))
compressedImage.SetFilename(imageFilename)
coiPipeline := manifest.NewCoreOSInstaller(
buildPipeline,
img.Platform,
repos,
"kernel",
img.Product,
img.OSVersion,
)
coiPipeline.ExtraPackages = img.ExtraBasePackages.Include
coiPipeline.ExcludePackages = img.ExtraBasePackages.Exclude
coiPipeline.ExtraRepos = img.ExtraBasePackages.Repositories
coiPipeline.FDO = img.FDO
coiPipeline.Ignition = img.IgnitionEmbedded
coiPipeline.Biosdevname = (img.Platform.GetArch() == arch.ARCH_X86_64)
coiPipeline.Variant = img.Variant
coiPipeline.AdditionalDracutModules = img.AdditionalDracutModules
var isoLabel string
if len(img.ISOLabel) > 0 {
isoLabel = img.ISOLabel
} else {
// TODO: replace isoLabelTmpl with more high-level properties
isoLabel = fmt.Sprintf(img.ISOLabelTmpl, img.Platform.GetArch())
}
bootTreePipeline := manifest.NewEFIBootTree(buildPipeline, img.Product, img.OSVersion)
bootTreePipeline.Platform = img.Platform
bootTreePipeline.UEFIVendor = img.Platform.GetUEFIVendor()
bootTreePipeline.ISOLabel = isoLabel
// kernel options for EFI boot tree grub stage
kernelOpts := []string{
"rd.neednet=1",
"coreos.inst.crypt_root=1",
"coreos.inst.isoroot=" + isoLabel,
"coreos.inst.install_dev=" + img.installDevice,
fmt.Sprintf("coreos.inst.image_file=/run/media/iso/%s", imageFilename),
"coreos.inst.insecure",
}
// extra FDO options for EFI boot tree grub stage
if img.FDO != nil {
kernelOpts = append(kernelOpts, "fdo.manufacturing_server_url="+img.FDO.ManufacturingServerURL)
if img.FDO.DiunPubKeyInsecure != "" {
kernelOpts = append(kernelOpts, "fdo.diun_pub_key_insecure="+img.FDO.DiunPubKeyInsecure)
}
if img.FDO.DiunPubKeyHash != "" {
kernelOpts = append(kernelOpts, "fdo.diun_pub_key_hash="+img.FDO.DiunPubKeyHash)
}
if img.FDO.DiunPubKeyRootCerts != "" {
kernelOpts = append(kernelOpts, "fdo.diun_pub_key_root_certs=/fdo_diun_pub_key_root_certs.pem")
}
if img.FDO.DiMfgStringTypeMacIface != "" {
kernelOpts = append(kernelOpts, "fdo.di_mfg_string_type_mac_iface="+img.FDO.DiMfgStringTypeMacIface)
}
}
bootTreePipeline.KernelOpts = kernelOpts
// enable ISOLinux on x86_64 only
isoLinuxEnabled := img.Platform.GetArch() == arch.ARCH_X86_64
isoTreePipeline := manifest.NewCoreOSISOTree(buildPipeline, compressedImage, coiPipeline, bootTreePipeline)
isoTreePipeline.KernelOpts = kernelOpts
isoTreePipeline.PartitionTable = efiBootPartitionTable(rng)
isoTreePipeline.OSName = img.OSName
isoTreePipeline.PayloadPath = fmt.Sprintf("/%s", imageFilename)
isoTreePipeline.ISOLinux = isoLinuxEnabled
isoPipeline := manifest.NewISO(buildPipeline, isoTreePipeline, isoLabel)
isoPipeline.SetFilename(img.Filename)
isoPipeline.ISOLinux = isoLinuxEnabled
artifact := isoPipeline.Export()
return artifact, nil
}