distro/rhel8: update edge raw image to new definitions

Using the same pipeline code as RHEL 9 and Fedora introduces the
following changes to the image:
- ostree.config: moved and uses the stage mount instead of the old
  stage-specific options.
- lock root password like we do in Fedora and RHEL 9.
- set keymap to us and locale to C.UTF-8 like in Fedora and RHEL 9.
- grub2 contains kernel options and unified set to true.  This stage
  also now uses the ostree mount options to set up the deployment when
  running.
This commit is contained in:
Achilleas Koutsou 2023-01-11 20:17:59 +01:00 committed by Tomáš Hozza
parent 2eb94fa269
commit e2b1baf47c
3 changed files with 57 additions and 33 deletions

View file

@ -65,21 +65,19 @@ func edgeOCIImgType(rd distribution) imageType {
}
func edgeRawImgType() imageType {
it := imageType{
name: "edge-raw-image",
nameAliases: []string{"rhel-edge-raw-image"},
filename: "image.raw.xz",
mimeType: "application/xz",
packageSets: map[string]packageSetFunc{
buildPkgsKey: edgeRawImageBuildPackageSet,
},
name: "edge-raw-image",
nameAliases: []string{"rhel-edge-raw-image"},
filename: "image.raw.xz",
mimeType: "application/xz",
packageSets: nil,
defaultSize: 10 * common.GibiByte,
rpmOstree: true,
bootable: true,
bootISO: false,
pipelines: edgeRawImagePipelines,
image: edgeRawImage,
buildPipelines: []string{"build"},
payloadPipelines: []string{"image-tree", "image", "archive"},
exports: []string{"archive"},
payloadPipelines: []string{"image-tree", "image", "xz"},
exports: []string{"xz"},
basePartitionTables: edgeBasePartitionTables,
}
return it
@ -163,12 +161,6 @@ func edgeBuildPackageSet(t *imageType) rpmmd.PackageSet {
})
}
func edgeRawImageBuildPackageSet(t *imageType) rpmmd.PackageSet {
return edgeBuildPackageSet(t).Append(edgeEncryptionBuildPackageSet(t)).Append(
bootPackageSet(t),
)
}
// edge commit OS package set
func edgeCommitPackageSet(t *imageType) rpmmd.PackageSet {
ps := rpmmd.PackageSet{

View file

@ -9,6 +9,7 @@ import (
"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/ostree"
"github.com/osbuild/osbuild-composer/internal/platform"
"github.com/osbuild/osbuild-composer/internal/rpmmd"
"github.com/osbuild/osbuild-composer/internal/users"
@ -217,3 +218,51 @@ func tarImage(workload workload.Workload,
return img, nil
}
func edgeRawImage(workload workload.Workload,
t *imageType,
customizations *blueprint.Customizations,
options distro.ImageOptions,
packageSets map[string]rpmmd.PackageSet,
containers []container.Spec,
rng *rand.Rand) (image.ImageKind, error) {
commit := ostree.CommitSpec{
Ref: options.OSTree.ImageRef,
URL: options.OSTree.URL,
ContentURL: options.OSTree.ContentURL,
Checksum: options.OSTree.FetchChecksum,
}
img := image.NewOSTreeRawImage(commit)
img.Users = users.UsersFromBP(customizations.GetUsers())
img.Groups = users.GroupsFromBP(customizations.GetGroups())
// "rw" kernel option is required when /sysroot is mounted read-only to
// keep stateful parts of the filesystem writeable (/var/ and /etc)
img.KernelOptionsAppend = []string{"modprobe.blacklist=vc4", "rw"}
// TODO: move to image config
img.Keyboard = "us"
img.Locale = "C.UTF-8"
img.SysrootReadOnly = true
img.Platform = t.platform
img.Workload = workload
img.Remote = ostree.Remote{
Name: "rhel-edge",
URL: options.OSTree.URL,
ContentURL: options.OSTree.ContentURL,
}
img.OSName = "redhat"
// 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
}

View file

@ -159,23 +159,6 @@ func edgeImagePipelines(t *imageType, customizations *blueprint.Customizations,
return pipelines, xzPipeline.Name, nil
}
func edgeRawImagePipelines(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()))
imgName := t.filename
// create the raw image
imagePipelines, _, err := edgeImagePipelines(t, customizations, imgName, options, rng)
if err != nil {
return nil, err
}
pipelines = append(pipelines, imagePipelines...)
return pipelines, nil
}
func buildPipeline(repos []rpmmd.RepoConfig, buildPackageSpecs []rpmmd.PackageSpec, runner string) *osbuild.Pipeline {
p := new(osbuild.Pipeline)
p.Name = "build"