distro/rhel9: update qcow2 and openstack to new definitions
Add the image function and remove the pipeline function. Remove the build package set: build packages are added to the pipeline on-demand based on platform, environment, etc. Copied the liveImage ImageKind generator from Fedora.
This commit is contained in:
parent
51ac3e973e
commit
0c6bbc6dff
4 changed files with 157 additions and 38 deletions
151
internal/distro/rhel9/images.go
Normal file
151
internal/distro/rhel9/images.go
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
package rhel9
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
"github.com/osbuild/osbuild-composer/internal/image"
|
||||
"github.com/osbuild/osbuild-composer/internal/manifest"
|
||||
"github.com/osbuild/osbuild-composer/internal/osbuild"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
"github.com/osbuild/osbuild-composer/internal/users"
|
||||
"github.com/osbuild/osbuild-composer/internal/workload"
|
||||
)
|
||||
|
||||
func osCustomizations(
|
||||
t *imageType,
|
||||
osPackageSet rpmmd.PackageSet,
|
||||
c *blueprint.Customizations) manifest.OSCustomizations {
|
||||
|
||||
imageConfig := t.getDefaultImageConfig()
|
||||
|
||||
osc := manifest.OSCustomizations{}
|
||||
|
||||
if t.bootable || t.rpmOstree {
|
||||
osc.KernelName = c.GetKernel().Name
|
||||
|
||||
var kernelOptions []string
|
||||
if t.kernelOptions != "" {
|
||||
kernelOptions = append(kernelOptions, t.kernelOptions)
|
||||
}
|
||||
if bpKernel := c.GetKernel(); bpKernel.Append != "" {
|
||||
kernelOptions = append(kernelOptions, bpKernel.Append)
|
||||
}
|
||||
osc.KernelOptionsAppend = kernelOptions
|
||||
}
|
||||
|
||||
osc.ExtraBasePackages = osPackageSet.Include
|
||||
osc.ExcludeBasePackages = osPackageSet.Exclude
|
||||
osc.ExtraBaseRepos = osPackageSet.Repositories
|
||||
|
||||
osc.GPGKeyFiles = imageConfig.GPGKeyFiles
|
||||
if imageConfig.ExcludeDocs != nil {
|
||||
osc.ExcludeDocs = *imageConfig.ExcludeDocs
|
||||
}
|
||||
|
||||
if !t.bootISO {
|
||||
// don't put users and groups in the payload of an installer
|
||||
// add them via kickstart instead
|
||||
osc.Groups = users.GroupsFromBP(c.GetGroups())
|
||||
osc.Users = users.UsersFromBP(c.GetUsers())
|
||||
}
|
||||
|
||||
osc.EnabledServices = imageConfig.EnabledServices
|
||||
osc.DisabledServices = imageConfig.DisabledServices
|
||||
if imageConfig.DefaultTarget != nil {
|
||||
osc.DefaultTarget = *imageConfig.DefaultTarget
|
||||
}
|
||||
|
||||
osc.Firewall = c.GetFirewall()
|
||||
|
||||
language, keyboard := c.GetPrimaryLocale()
|
||||
if language != nil {
|
||||
osc.Language = *language
|
||||
} else if imageConfig.Locale != nil {
|
||||
osc.Language = *imageConfig.Locale
|
||||
}
|
||||
if keyboard != nil {
|
||||
osc.Keyboard = keyboard
|
||||
} else if imageConfig.Keyboard != nil {
|
||||
osc.Keyboard = &imageConfig.Keyboard.Keymap
|
||||
}
|
||||
|
||||
if hostname := c.GetHostname(); hostname != nil {
|
||||
osc.Hostname = *hostname
|
||||
}
|
||||
|
||||
timezone, ntpServers := c.GetTimezoneSettings()
|
||||
if timezone != nil {
|
||||
osc.Timezone = *timezone
|
||||
} else if imageConfig.Timezone != nil {
|
||||
osc.Timezone = *imageConfig.Timezone
|
||||
}
|
||||
|
||||
if len(ntpServers) > 0 {
|
||||
osc.NTPServers = ntpServers
|
||||
} else if imageConfig.TimeSynchronization != nil {
|
||||
osc.NTPServers = imageConfig.TimeSynchronization.Timeservers
|
||||
}
|
||||
|
||||
// Relabel the tree, unless the `NoSElinux` flag is explicitly set to `true`
|
||||
if imageConfig.NoSElinux == nil || imageConfig.NoSElinux != nil && !*imageConfig.NoSElinux {
|
||||
osc.SElinux = "targeted"
|
||||
}
|
||||
|
||||
if oscapConfig := c.GetOpenSCAP(); oscapConfig != nil {
|
||||
if t.rpmOstree {
|
||||
panic("unexpected oscap options for ostree image type")
|
||||
}
|
||||
osc.OpenSCAPConfig = osbuild.NewOscapRemediationStageOptions(
|
||||
osbuild.OscapConfig{
|
||||
Datastream: oscapConfig.DataStream,
|
||||
ProfileID: oscapConfig.ProfileID,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
osc.Grub2Config = imageConfig.Grub2Config
|
||||
osc.Sysconfig = imageConfig.Sysconfig
|
||||
osc.SystemdLogind = imageConfig.SystemdLogind
|
||||
osc.CloudInit = imageConfig.CloudInit
|
||||
osc.Modprobe = imageConfig.Modprobe
|
||||
osc.DracutConf = imageConfig.DracutConf
|
||||
osc.SystemdUnit = imageConfig.SystemdUnit
|
||||
osc.Authselect = imageConfig.Authselect
|
||||
osc.SELinuxConfig = imageConfig.SELinuxConfig
|
||||
osc.Tuned = imageConfig.Tuned
|
||||
osc.Tmpfilesd = imageConfig.Tmpfilesd
|
||||
osc.PamLimitsConf = imageConfig.PamLimitsConf
|
||||
osc.Sysctld = imageConfig.Sysctld
|
||||
osc.DNFConfig = imageConfig.DNFConfig
|
||||
osc.SshdConfig = imageConfig.SshdConfig
|
||||
osc.AuthConfig = imageConfig.Authconfig
|
||||
osc.PwQuality = imageConfig.PwQuality
|
||||
|
||||
return osc
|
||||
}
|
||||
|
||||
func liveImage(workload workload.Workload,
|
||||
t *imageType,
|
||||
customizations *blueprint.Customizations,
|
||||
options distro.ImageOptions,
|
||||
packageSets map[string]rpmmd.PackageSet,
|
||||
rng *rand.Rand) (image.ImageKind, error) {
|
||||
|
||||
img := image.NewLiveImage()
|
||||
img.Platform = t.platform
|
||||
img.OSCustomizations = osCustomizations(t, packageSets[osPkgsKey], customizations)
|
||||
img.Environment = t.environment
|
||||
img.Workload = workload
|
||||
// TODO: move generation into LiveImage
|
||||
pt, err := t.getPartitionTable(customizations.GetFilesystems(), options, rng)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
img.PartitionTable = pt
|
||||
|
||||
img.Filename = t.Filename()
|
||||
|
||||
return img, nil
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ import (
|
|||
"github.com/osbuild/osbuild-composer/internal/container"
|
||||
"github.com/osbuild/osbuild-composer/internal/disk"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
"github.com/osbuild/osbuild-composer/internal/environment"
|
||||
"github.com/osbuild/osbuild-composer/internal/image"
|
||||
"github.com/osbuild/osbuild-composer/internal/manifest"
|
||||
"github.com/osbuild/osbuild-composer/internal/osbuild"
|
||||
|
|
@ -50,6 +51,7 @@ type packageSetFunc func(t *imageType) rpmmd.PackageSet
|
|||
type imageType struct {
|
||||
arch *architecture
|
||||
platform platform.Platform
|
||||
environment environment.Environment
|
||||
name string
|
||||
nameAliases []string
|
||||
filename string
|
||||
|
|
|
|||
|
|
@ -17,32 +17,6 @@ import (
|
|||
"github.com/osbuild/osbuild-composer/internal/users"
|
||||
)
|
||||
|
||||
func qcow2Pipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, containers []container.Spec, rng *rand.Rand) ([]osbuild.Pipeline, error) {
|
||||
pipelines := make([]osbuild.Pipeline, 0)
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey], t.arch.distro.runner.String()))
|
||||
|
||||
partitionTable, err := t.getPartitionTable(customizations.GetFilesystems(), options, rng)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
treePipeline, err := osPipeline(t, repos, packageSetSpecs[osPkgsKey], containers, customizations, options, partitionTable)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pipelines = append(pipelines, *treePipeline)
|
||||
|
||||
diskfile := "disk.img"
|
||||
kernelVer := rpmmd.GetVerStrFromPackageSpecListPanic(packageSetSpecs[osPkgsKey], customizations.GetKernel().Name)
|
||||
imagePipeline := liveImagePipeline(treePipeline.Name, diskfile, partitionTable, t.arch, kernelVer)
|
||||
pipelines = append(pipelines, *imagePipeline)
|
||||
|
||||
qemuPipeline := qemuPipeline(imagePipeline.Name, diskfile, t.filename, osbuild.QEMUFormatQCOW2, osbuild.QCOW2Options{Compat: "1.1"})
|
||||
pipelines = append(pipelines, *qemuPipeline)
|
||||
|
||||
return pipelines, nil
|
||||
}
|
||||
|
||||
func prependKernelCmdlineStage(pipeline *osbuild.Pipeline, kernelOptions string, pt *disk.PartitionTable) *osbuild.Pipeline {
|
||||
rootFs := pt.FindMountable("/")
|
||||
if rootFs == nil {
|
||||
|
|
|
|||
|
|
@ -14,11 +14,7 @@ var (
|
|||
mimeType: "application/x-qemu-disk",
|
||||
kernelOptions: "console=tty0 console=ttyS0,115200n8 no_timer_check net.ifnames=0",
|
||||
packageSets: map[string]packageSetFunc{
|
||||
buildPkgsKey: distroBuildPackageSet,
|
||||
osPkgsKey: qcow2CommonPackageSet,
|
||||
},
|
||||
packageSetChains: map[string][]string{
|
||||
osPkgsKey: {osPkgsKey, blueprintPkgsKey},
|
||||
osPkgsKey: qcow2CommonPackageSet,
|
||||
},
|
||||
defaultImageConfig: &distro.ImageConfig{
|
||||
DefaultTarget: common.StringToPtr("multi-user.target"),
|
||||
|
|
@ -37,7 +33,7 @@ var (
|
|||
},
|
||||
bootable: true,
|
||||
defaultSize: 10 * common.GibiByte,
|
||||
pipelines: qcow2Pipelines,
|
||||
image: liveImage,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "qcow2"},
|
||||
exports: []string{"qcow2"},
|
||||
|
|
@ -49,11 +45,7 @@ var (
|
|||
filename: "disk.qcow2",
|
||||
mimeType: "application/x-qemu-disk",
|
||||
packageSets: map[string]packageSetFunc{
|
||||
buildPkgsKey: distroBuildPackageSet,
|
||||
osPkgsKey: openstackCommonPackageSet,
|
||||
},
|
||||
packageSetChains: map[string][]string{
|
||||
osPkgsKey: {osPkgsKey, blueprintPkgsKey},
|
||||
osPkgsKey: openstackCommonPackageSet,
|
||||
},
|
||||
defaultImageConfig: &distro.ImageConfig{
|
||||
Locale: common.StringToPtr("en_US.UTF-8"),
|
||||
|
|
@ -61,7 +53,7 @@ var (
|
|||
kernelOptions: "ro net.ifnames=0",
|
||||
bootable: true,
|
||||
defaultSize: 4 * common.GibiByte,
|
||||
pipelines: openstackPipelines,
|
||||
image: liveImage,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "image", "qcow2"},
|
||||
exports: []string{"qcow2"},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue