distro/rhel86: copy all definitions from rhel85
Adjust strings from 85, 8.5, 8-5, to 86, 8.6, 8-6.
This commit is contained in:
parent
4eca54b6ed
commit
513b7f94b9
8 changed files with 4710 additions and 0 deletions
832
internal/distro/rhel86/distro.go
Normal file
832
internal/distro/rhel86/distro.go
Normal file
|
|
@ -0,0 +1,832 @@
|
|||
package rhel86
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"path"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
"github.com/osbuild/osbuild-composer/internal/disk"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
osbuild "github.com/osbuild/osbuild-composer/internal/osbuild2"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
)
|
||||
|
||||
const defaultName = "rhel-86"
|
||||
const rhel86Name = "rhel-86"
|
||||
const osVersion = "8.6"
|
||||
const releaseVersion = "8"
|
||||
const modulePlatformID = "platform:el8"
|
||||
const ostreeRef = "rhel/8/%s/edge"
|
||||
|
||||
const (
|
||||
// package set names
|
||||
|
||||
// build package set name
|
||||
buildPkgsKey = "build"
|
||||
|
||||
// main/common os image package set name
|
||||
osPkgsKey = "packages"
|
||||
|
||||
// container package set name
|
||||
containerPkgsKey = "container"
|
||||
|
||||
// installer package set name
|
||||
installerPkgsKey = "installer"
|
||||
|
||||
// blueprint package set name
|
||||
blueprintPkgsKey = "blueprint"
|
||||
)
|
||||
|
||||
var mountpointAllowList = []string{
|
||||
"/", "/var", "/opt", "/srv", "/usr", "/app", "/data", "/home",
|
||||
}
|
||||
|
||||
type distribution struct {
|
||||
name string
|
||||
modulePlatformID string
|
||||
ostreeRef string
|
||||
arches map[string]distro.Arch
|
||||
}
|
||||
|
||||
func (d *distribution) Name() string {
|
||||
return d.name
|
||||
}
|
||||
|
||||
func (d *distribution) Releasever() string {
|
||||
return releaseVersion
|
||||
}
|
||||
|
||||
func (d *distribution) ModulePlatformID() string {
|
||||
return d.modulePlatformID
|
||||
}
|
||||
|
||||
func (d *distribution) OSTreeRef() string {
|
||||
return d.ostreeRef
|
||||
}
|
||||
|
||||
func (d *distribution) ListArches() []string {
|
||||
archNames := make([]string, 0, len(d.arches))
|
||||
for name := range d.arches {
|
||||
archNames = append(archNames, name)
|
||||
}
|
||||
sort.Strings(archNames)
|
||||
return archNames
|
||||
}
|
||||
|
||||
func (d *distribution) GetArch(name string) (distro.Arch, error) {
|
||||
arch, exists := d.arches[name]
|
||||
if !exists {
|
||||
return nil, errors.New("invalid architecture: " + name)
|
||||
}
|
||||
return arch, nil
|
||||
}
|
||||
|
||||
func (d *distribution) addArches(arches ...architecture) {
|
||||
if d.arches == nil {
|
||||
d.arches = map[string]distro.Arch{}
|
||||
}
|
||||
|
||||
// Do not make copies of architectures, as opposed to image types,
|
||||
// because architecture definitions are not used by more than a single
|
||||
// distro definition.
|
||||
for idx := range arches {
|
||||
d.arches[arches[idx].name] = &arches[idx]
|
||||
}
|
||||
}
|
||||
|
||||
type architecture struct {
|
||||
distro *distribution
|
||||
name string
|
||||
imageTypes map[string]distro.ImageType
|
||||
imageTypeAliases map[string]string
|
||||
legacy string
|
||||
bootType distro.BootType
|
||||
}
|
||||
|
||||
func (a *architecture) Name() string {
|
||||
return a.name
|
||||
}
|
||||
|
||||
func (a *architecture) ListImageTypes() []string {
|
||||
itNames := make([]string, 0, len(a.imageTypes))
|
||||
for name := range a.imageTypes {
|
||||
itNames = append(itNames, name)
|
||||
}
|
||||
sort.Strings(itNames)
|
||||
return itNames
|
||||
}
|
||||
|
||||
func (a *architecture) GetImageType(name string) (distro.ImageType, error) {
|
||||
t, exists := a.imageTypes[name]
|
||||
if !exists {
|
||||
aliasForName, exists := a.imageTypeAliases[name]
|
||||
if !exists {
|
||||
return nil, errors.New("invalid image type: " + name)
|
||||
}
|
||||
t, exists = a.imageTypes[aliasForName]
|
||||
if !exists {
|
||||
panic(fmt.Sprintf("image type '%s' is an alias to a non-existing image type '%s'", name, aliasForName))
|
||||
}
|
||||
}
|
||||
return t, nil
|
||||
}
|
||||
|
||||
func (a *architecture) addImageTypes(imageTypes ...imageType) {
|
||||
if a.imageTypes == nil {
|
||||
a.imageTypes = map[string]distro.ImageType{}
|
||||
}
|
||||
for idx := range imageTypes {
|
||||
it := imageTypes[idx]
|
||||
it.arch = a
|
||||
a.imageTypes[it.name] = &it
|
||||
for _, alias := range it.nameAliases {
|
||||
if a.imageTypeAliases == nil {
|
||||
a.imageTypeAliases = map[string]string{}
|
||||
}
|
||||
if existingAliasFor, exists := a.imageTypeAliases[alias]; exists {
|
||||
panic(fmt.Sprintf("image type alias '%s' for '%s' is already defined for another image type '%s'", alias, it.name, existingAliasFor))
|
||||
}
|
||||
a.imageTypeAliases[alias] = it.name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a *architecture) Distro() distro.Distro {
|
||||
return a.distro
|
||||
}
|
||||
|
||||
type pipelinesFunc func(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]osbuild.Pipeline, error)
|
||||
|
||||
type packageSetFunc func(t *imageType) rpmmd.PackageSet
|
||||
|
||||
type imageType struct {
|
||||
arch *architecture
|
||||
name string
|
||||
nameAliases []string
|
||||
filename string
|
||||
mimeType string
|
||||
packageSets map[string]packageSetFunc
|
||||
enabledServices []string
|
||||
disabledServices []string
|
||||
defaultTarget string
|
||||
kernelOptions string
|
||||
defaultSize uint64
|
||||
exports []string
|
||||
pipelines pipelinesFunc
|
||||
|
||||
// bootISO: installable ISO
|
||||
bootISO bool
|
||||
// rpmOstree: edge/ostree
|
||||
rpmOstree bool
|
||||
// bootable image
|
||||
bootable bool
|
||||
// If set to a value, it is preferred over the architecture value
|
||||
bootType distro.BootType
|
||||
// List of valid arches for the image type
|
||||
basePartitionTables distro.BasePartitionTableMap
|
||||
}
|
||||
|
||||
func (t *imageType) Name() string {
|
||||
return t.name
|
||||
}
|
||||
|
||||
func (t *imageType) Arch() distro.Arch {
|
||||
return t.arch
|
||||
}
|
||||
|
||||
func (t *imageType) Filename() string {
|
||||
return t.filename
|
||||
}
|
||||
|
||||
func (t *imageType) MIMEType() string {
|
||||
return t.mimeType
|
||||
}
|
||||
|
||||
func (t *imageType) OSTreeRef() string {
|
||||
if t.rpmOstree {
|
||||
return fmt.Sprintf(ostreeRef, t.arch.name)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (t *imageType) Size(size uint64) uint64 {
|
||||
const MegaByte = 1024 * 1024
|
||||
// Microsoft Azure requires vhd images to be rounded up to the nearest MB
|
||||
if t.name == "vhd" && size%MegaByte != 0 {
|
||||
size = (size/MegaByte + 1) * MegaByte
|
||||
}
|
||||
if size == 0 {
|
||||
size = t.defaultSize
|
||||
}
|
||||
return size
|
||||
}
|
||||
|
||||
func (t *imageType) getPackages(name string) rpmmd.PackageSet {
|
||||
getter := t.packageSets[name]
|
||||
if getter == nil {
|
||||
return rpmmd.PackageSet{}
|
||||
}
|
||||
|
||||
return getter(t)
|
||||
}
|
||||
|
||||
func (t *imageType) PackageSets(bp blueprint.Blueprint) map[string]rpmmd.PackageSet {
|
||||
// merge package sets that appear in the image type with the package sets
|
||||
// of the same name from the distro and arch
|
||||
mergedSets := make(map[string]rpmmd.PackageSet)
|
||||
|
||||
imageSets := t.packageSets
|
||||
|
||||
for name := range imageSets {
|
||||
mergedSets[name] = t.getPackages(name)
|
||||
}
|
||||
|
||||
if _, hasPackages := imageSets[osPkgsKey]; !hasPackages {
|
||||
// should this be possible??
|
||||
mergedSets[osPkgsKey] = rpmmd.PackageSet{}
|
||||
}
|
||||
|
||||
// every image type must define a 'build' package set
|
||||
if _, hasBuild := imageSets[buildPkgsKey]; !hasBuild {
|
||||
panic(fmt.Sprintf("'%s' image type has no '%s' package set defined", t.name, buildPkgsKey))
|
||||
}
|
||||
|
||||
// blueprint packages
|
||||
bpPackages := bp.GetPackages()
|
||||
timezone, _ := bp.Customizations.GetTimezoneSettings()
|
||||
if timezone != nil {
|
||||
bpPackages = append(bpPackages, "chrony")
|
||||
}
|
||||
|
||||
// depsolve bp packages separately
|
||||
// bp packages aren't restricted by exclude lists
|
||||
mergedSets[blueprintPkgsKey] = rpmmd.PackageSet{Include: bpPackages}
|
||||
kernel := bp.Customizations.GetKernel().Name
|
||||
|
||||
// add bp kernel to main OS package set to avoid duplicate kernels
|
||||
mergedSets[osPkgsKey] = mergedSets[osPkgsKey].Append(rpmmd.PackageSet{Include: []string{kernel}})
|
||||
return mergedSets
|
||||
|
||||
}
|
||||
|
||||
func (t *imageType) Exports() []string {
|
||||
if len(t.exports) > 0 {
|
||||
return t.exports
|
||||
}
|
||||
return []string{"assembler"}
|
||||
}
|
||||
|
||||
// getBootType returns the BootType which should be used for this particular
|
||||
// combination of architecture and image type.
|
||||
func (t *imageType) getBootType() distro.BootType {
|
||||
bootType := t.arch.bootType
|
||||
if t.bootType != distro.UnsetBootType {
|
||||
bootType = t.bootType
|
||||
}
|
||||
return bootType
|
||||
}
|
||||
|
||||
func (t *imageType) supportsUEFI() bool {
|
||||
bootType := t.getBootType()
|
||||
if bootType == distro.HybridBootType || bootType == distro.UEFIBootType {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (t *imageType) getPartitionTable(
|
||||
mountpoints []blueprint.FilesystemCustomization,
|
||||
options distro.ImageOptions,
|
||||
rng *rand.Rand,
|
||||
) (disk.PartitionTable, error) {
|
||||
archName := t.arch.Name()
|
||||
|
||||
basePartitionTable, exists := t.basePartitionTables[archName]
|
||||
|
||||
if !exists {
|
||||
return basePartitionTable, fmt.Errorf("unknown arch: " + archName)
|
||||
}
|
||||
|
||||
return disk.CreatePartitionTable(mountpoints, options.Size, basePartitionTable, rng), nil
|
||||
}
|
||||
|
||||
// local type for ostree commit metadata used to define commit sources
|
||||
type ostreeCommit struct {
|
||||
Checksum string
|
||||
URL string
|
||||
}
|
||||
|
||||
func (t *imageType) Manifest(customizations *blueprint.Customizations,
|
||||
options distro.ImageOptions,
|
||||
repos []rpmmd.RepoConfig,
|
||||
packageSpecSets map[string][]rpmmd.PackageSpec,
|
||||
seed int64) (distro.Manifest, error) {
|
||||
|
||||
if err := t.checkOptions(customizations, options); err != nil {
|
||||
return distro.Manifest{}, err
|
||||
}
|
||||
|
||||
source := rand.NewSource(seed)
|
||||
rng := rand.New(source)
|
||||
|
||||
pipelines, err := t.pipelines(t, customizations, options, repos, packageSpecSets, rng)
|
||||
if err != nil {
|
||||
return distro.Manifest{}, err
|
||||
}
|
||||
|
||||
// flatten spec sets for sources
|
||||
allPackageSpecs := make([]rpmmd.PackageSpec, 0)
|
||||
for _, specs := range packageSpecSets {
|
||||
allPackageSpecs = append(allPackageSpecs, specs...)
|
||||
}
|
||||
|
||||
var commits []ostreeCommit
|
||||
if options.OSTree.Parent != "" && options.OSTree.URL != "" {
|
||||
commits = []ostreeCommit{{Checksum: options.OSTree.Parent, URL: options.OSTree.URL}}
|
||||
}
|
||||
return json.Marshal(
|
||||
osbuild.Manifest{
|
||||
Version: "2",
|
||||
Pipelines: pipelines,
|
||||
Sources: t.sources(allPackageSpecs, commits),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func (t *imageType) sources(packages []rpmmd.PackageSpec, ostreeCommits []ostreeCommit) osbuild.Sources {
|
||||
sources := osbuild.Sources{}
|
||||
curl := &osbuild.CurlSource{
|
||||
Items: make(map[string]osbuild.CurlSourceItem),
|
||||
}
|
||||
for _, pkg := range packages {
|
||||
item := new(osbuild.URLWithSecrets)
|
||||
item.URL = pkg.RemoteLocation
|
||||
if pkg.Secrets == "org.osbuild.rhsm" {
|
||||
item.Secrets = &osbuild.URLSecrets{
|
||||
Name: "org.osbuild.rhsm",
|
||||
}
|
||||
}
|
||||
curl.Items[pkg.Checksum] = item
|
||||
}
|
||||
if len(curl.Items) > 0 {
|
||||
sources["org.osbuild.curl"] = curl
|
||||
}
|
||||
|
||||
ostree := &osbuild.OSTreeSource{
|
||||
Items: make(map[string]osbuild.OSTreeSourceItem),
|
||||
}
|
||||
for _, commit := range ostreeCommits {
|
||||
item := new(osbuild.OSTreeSourceItem)
|
||||
item.Remote.URL = commit.URL
|
||||
ostree.Items[commit.Checksum] = *item
|
||||
}
|
||||
if len(ostree.Items) > 0 {
|
||||
sources["org.osbuild.ostree"] = ostree
|
||||
}
|
||||
return sources
|
||||
}
|
||||
|
||||
func isMountpointAllowed(mountpoint string) bool {
|
||||
for _, allowed := range mountpointAllowList {
|
||||
match, _ := path.Match(allowed, mountpoint)
|
||||
if match {
|
||||
return true
|
||||
}
|
||||
// ensure that only clean mountpoints
|
||||
// are valid
|
||||
if strings.Contains(mountpoint, "//") {
|
||||
return false
|
||||
}
|
||||
match = strings.HasPrefix(mountpoint, allowed+"/")
|
||||
if allowed != "/" && match {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// checkOptions checks the validity and compatibility of options and customizations for the image type.
|
||||
func (t *imageType) checkOptions(customizations *blueprint.Customizations, options distro.ImageOptions) error {
|
||||
if t.bootISO && t.rpmOstree {
|
||||
if options.OSTree.Parent == "" {
|
||||
return fmt.Errorf("boot ISO image type %q requires specifying a URL from which to retrieve the OSTree commit", t.name)
|
||||
}
|
||||
|
||||
if t.name == "edge-simplified-installer" {
|
||||
if err := customizations.CheckAllowed("InstallationDevice"); err != nil {
|
||||
return fmt.Errorf("boot ISO image type %q contains unsupported blueprint customizations: %v", t.name, err)
|
||||
}
|
||||
} else if customizations != nil {
|
||||
return fmt.Errorf("boot ISO image type %q does not support blueprint customizations", t.name)
|
||||
}
|
||||
}
|
||||
|
||||
if t.name == "edge-raw-image" && options.OSTree.Parent == "" {
|
||||
return fmt.Errorf("edge raw images require specifying a URL from which to retrieve the OSTree commit")
|
||||
}
|
||||
|
||||
if kernelOpts := customizations.GetKernel(); kernelOpts.Append != "" && t.rpmOstree && (!t.bootable || t.bootISO) {
|
||||
return fmt.Errorf("kernel boot parameter customizations are not supported for ostree types")
|
||||
}
|
||||
|
||||
mountpoints := customizations.GetFilesystems()
|
||||
|
||||
if mountpoints != nil && t.rpmOstree {
|
||||
return fmt.Errorf("Custom mountpoints are not supported for ostree types")
|
||||
}
|
||||
|
||||
invalidMountpoints := []string{}
|
||||
for _, m := range mountpoints {
|
||||
if m.Mountpoint == "/usr" && m.MinSize < 2147483648 {
|
||||
m.MinSize = 2147483648
|
||||
}
|
||||
if !isMountpointAllowed(m.Mountpoint) {
|
||||
invalidMountpoints = append(invalidMountpoints, m.Mountpoint)
|
||||
}
|
||||
}
|
||||
|
||||
if len(invalidMountpoints) > 0 {
|
||||
return fmt.Errorf("The following custom mountpoints are not supported %+q", invalidMountpoints)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// New creates a new distro object, defining the supported architectures and image types
|
||||
func New() distro.Distro {
|
||||
return newDistro(defaultName, modulePlatformID, ostreeRef)
|
||||
}
|
||||
|
||||
func NewRHEL86() distro.Distro {
|
||||
return newDistro(rhel86Name, modulePlatformID, ostreeRef)
|
||||
}
|
||||
|
||||
func NewHostDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
||||
return newDistro(name, modulePlatformID, ostreeRef)
|
||||
}
|
||||
|
||||
func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
||||
const GigaByte = 1024 * 1024 * 1024
|
||||
|
||||
rd := &distribution{
|
||||
name: name,
|
||||
modulePlatformID: modulePlatformID,
|
||||
ostreeRef: ostreeRef,
|
||||
}
|
||||
|
||||
// Architecture definitions
|
||||
x86_64 := architecture{
|
||||
name: distro.X86_64ArchName,
|
||||
distro: rd,
|
||||
legacy: "i386-pc",
|
||||
bootType: distro.HybridBootType,
|
||||
}
|
||||
|
||||
aarch64 := architecture{
|
||||
name: distro.Aarch64ArchName,
|
||||
distro: rd,
|
||||
bootType: distro.UEFIBootType,
|
||||
}
|
||||
|
||||
ppc64le := architecture{
|
||||
distro: rd,
|
||||
name: distro.Ppc64leArchName,
|
||||
legacy: "powerpc-ieee1275",
|
||||
bootType: distro.LegacyBootType,
|
||||
}
|
||||
s390x := architecture{
|
||||
distro: rd,
|
||||
name: distro.S390xArchName,
|
||||
bootType: distro.LegacyBootType,
|
||||
}
|
||||
|
||||
// Shared Services
|
||||
edgeServices := []string{
|
||||
"NetworkManager.service", "firewalld.service", "sshd.service",
|
||||
}
|
||||
|
||||
// Image Definitions
|
||||
edgeCommitImgType := imageType{
|
||||
name: "edge-commit",
|
||||
nameAliases: []string{"rhel-edge-commit"},
|
||||
filename: "commit.tar",
|
||||
mimeType: "application/x-tar",
|
||||
packageSets: map[string]packageSetFunc{
|
||||
buildPkgsKey: edgeBuildPackageSet,
|
||||
osPkgsKey: edgeCommitPackageSet,
|
||||
},
|
||||
enabledServices: edgeServices,
|
||||
rpmOstree: true,
|
||||
pipelines: edgeCommitPipelines,
|
||||
exports: []string{"commit-archive"},
|
||||
}
|
||||
|
||||
edgeOCIImgType := imageType{
|
||||
name: "edge-container",
|
||||
nameAliases: []string{"rhel-edge-container"},
|
||||
filename: "container.tar",
|
||||
mimeType: "application/x-tar",
|
||||
packageSets: map[string]packageSetFunc{
|
||||
buildPkgsKey: edgeBuildPackageSet,
|
||||
osPkgsKey: edgeCommitPackageSet,
|
||||
containerPkgsKey: func(t *imageType) rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{"nginx"},
|
||||
}
|
||||
},
|
||||
},
|
||||
enabledServices: edgeServices,
|
||||
rpmOstree: true,
|
||||
bootISO: false,
|
||||
pipelines: edgeContainerPipelines,
|
||||
exports: []string{"container"},
|
||||
}
|
||||
|
||||
edgeRawImgType := imageType{
|
||||
name: "edge-raw-image",
|
||||
nameAliases: []string{"rhel-edge-raw-image"},
|
||||
filename: "image.raw.xz",
|
||||
mimeType: "application/xz",
|
||||
packageSets: map[string]packageSetFunc{
|
||||
buildPkgsKey: edgeRawImageBuildPackageSet,
|
||||
},
|
||||
defaultSize: 10 * GigaByte,
|
||||
rpmOstree: true,
|
||||
bootable: true,
|
||||
bootISO: false,
|
||||
pipelines: edgeRawImagePipelines,
|
||||
exports: []string{"archive"},
|
||||
basePartitionTables: edgeBasePartitionTables,
|
||||
}
|
||||
|
||||
edgeInstallerImgType := imageType{
|
||||
name: "edge-installer",
|
||||
nameAliases: []string{"rhel-edge-installer"},
|
||||
filename: "installer.iso",
|
||||
mimeType: "application/x-iso9660-image",
|
||||
packageSets: map[string]packageSetFunc{
|
||||
// TODO: non-arch-specific package set handling for installers
|
||||
// This image type requires build packages for installers and
|
||||
// ostree/edge. For now we only have x86-64 installer build
|
||||
// package sets defined. When we add installer build package sets
|
||||
// for other architectures, this will need to be moved to the
|
||||
// architecture and the merging will happen in the PackageSets()
|
||||
// method like the other sets.
|
||||
buildPkgsKey: edgeInstallerBuildPackageSet,
|
||||
osPkgsKey: edgeCommitPackageSet,
|
||||
installerPkgsKey: edgeInstallerPackageSet,
|
||||
},
|
||||
enabledServices: edgeServices,
|
||||
rpmOstree: true,
|
||||
bootISO: true,
|
||||
pipelines: edgeInstallerPipelines,
|
||||
exports: []string{"bootiso"},
|
||||
}
|
||||
|
||||
edgeSimplifiedInstallerImgType := imageType{
|
||||
name: "edge-simplified-installer",
|
||||
nameAliases: []string{"rhel-edge-simplified-installer"},
|
||||
filename: "simplified-installer.iso",
|
||||
mimeType: "application/x-iso9660-image",
|
||||
packageSets: map[string]packageSetFunc{
|
||||
// TODO: non-arch-specific package set handling for installers
|
||||
// This image type requires build packages for installers and
|
||||
// ostree/edge. For now we only have x86-64 installer build
|
||||
// package sets defined. When we add installer build package sets
|
||||
// for other architectures, this will need to be moved to the
|
||||
// architecture and the merging will happen in the PackageSets()
|
||||
// method like the other sets.
|
||||
buildPkgsKey: edgeInstallerBuildPackageSet,
|
||||
installerPkgsKey: edgeSimplifiedInstallerPackageSet,
|
||||
},
|
||||
enabledServices: edgeServices,
|
||||
defaultSize: 10 * GigaByte,
|
||||
rpmOstree: true,
|
||||
bootable: true,
|
||||
bootISO: true,
|
||||
pipelines: edgeSimplifiedInstallerPipelines,
|
||||
exports: []string{"bootiso"},
|
||||
basePartitionTables: edgeBasePartitionTables,
|
||||
}
|
||||
|
||||
qcow2ImgType := imageType{
|
||||
name: "qcow2",
|
||||
filename: "disk.qcow2",
|
||||
mimeType: "application/x-qemu-disk",
|
||||
defaultTarget: "multi-user.target",
|
||||
kernelOptions: "console=tty0 console=ttyS0,115200n8 no_timer_check net.ifnames=0 crashkernel=auto",
|
||||
packageSets: map[string]packageSetFunc{
|
||||
buildPkgsKey: distroBuildPackageSet,
|
||||
osPkgsKey: qcow2CommonPackageSet,
|
||||
},
|
||||
bootable: true,
|
||||
defaultSize: 10 * GigaByte,
|
||||
pipelines: qcow2Pipelines,
|
||||
exports: []string{"qcow2"},
|
||||
basePartitionTables: defaultBasePartitionTables,
|
||||
}
|
||||
|
||||
vhdImgType := imageType{
|
||||
name: "vhd",
|
||||
filename: "disk.vhd",
|
||||
mimeType: "application/x-vhd",
|
||||
packageSets: map[string]packageSetFunc{
|
||||
buildPkgsKey: distroBuildPackageSet,
|
||||
osPkgsKey: vhdCommonPackageSet,
|
||||
},
|
||||
enabledServices: []string{
|
||||
"sshd",
|
||||
"waagent",
|
||||
},
|
||||
defaultTarget: "multi-user.target",
|
||||
kernelOptions: "ro biosdevname=0 rootdelay=300 console=ttyS0 earlyprintk=ttyS0 net.ifnames=0",
|
||||
bootable: true,
|
||||
defaultSize: 4 * GigaByte,
|
||||
pipelines: vhdPipelines,
|
||||
exports: []string{"vpc"},
|
||||
basePartitionTables: defaultBasePartitionTables,
|
||||
}
|
||||
|
||||
vmdkImgType := imageType{
|
||||
name: "vmdk",
|
||||
filename: "disk.vmdk",
|
||||
mimeType: "application/x-vmdk",
|
||||
packageSets: map[string]packageSetFunc{
|
||||
buildPkgsKey: distroBuildPackageSet,
|
||||
osPkgsKey: vmdkCommonPackageSet,
|
||||
},
|
||||
kernelOptions: "ro net.ifnames=0",
|
||||
bootable: true,
|
||||
defaultSize: 4 * GigaByte,
|
||||
pipelines: vmdkPipelines,
|
||||
exports: []string{"vmdk"},
|
||||
basePartitionTables: defaultBasePartitionTables,
|
||||
}
|
||||
|
||||
openstackImgType := imageType{
|
||||
name: "openstack",
|
||||
filename: "disk.qcow2",
|
||||
mimeType: "application/x-qemu-disk",
|
||||
packageSets: map[string]packageSetFunc{
|
||||
buildPkgsKey: distroBuildPackageSet,
|
||||
osPkgsKey: openstackCommonPackageSet,
|
||||
},
|
||||
kernelOptions: "ro net.ifnames=0",
|
||||
bootable: true,
|
||||
defaultSize: 4 * GigaByte,
|
||||
pipelines: openstackPipelines,
|
||||
exports: []string{"qcow2"},
|
||||
basePartitionTables: defaultBasePartitionTables,
|
||||
}
|
||||
|
||||
// EC2 services
|
||||
ec2EnabledServices := []string{
|
||||
"sshd",
|
||||
"NetworkManager",
|
||||
"nm-cloud-setup.service",
|
||||
"nm-cloud-setup.timer",
|
||||
"cloud-init",
|
||||
"cloud-init-local",
|
||||
"cloud-config",
|
||||
"cloud-final",
|
||||
"reboot.target",
|
||||
}
|
||||
|
||||
amiImgTypeX86_64 := imageType{
|
||||
name: "ami",
|
||||
filename: "image.raw",
|
||||
mimeType: "application/octet-stream",
|
||||
packageSets: map[string]packageSetFunc{
|
||||
buildPkgsKey: ec2BuildPackageSet,
|
||||
osPkgsKey: ec2CommonPackageSet,
|
||||
},
|
||||
defaultTarget: "multi-user.target",
|
||||
enabledServices: ec2EnabledServices,
|
||||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto",
|
||||
bootable: true,
|
||||
bootType: distro.LegacyBootType,
|
||||
defaultSize: 10 * GigaByte,
|
||||
pipelines: ec2Pipelines,
|
||||
exports: []string{"image"},
|
||||
basePartitionTables: ec2BasePartitionTables,
|
||||
}
|
||||
|
||||
amiImgTypeAarch64 := imageType{
|
||||
name: "ami",
|
||||
filename: "image.raw",
|
||||
mimeType: "application/octet-stream",
|
||||
packageSets: map[string]packageSetFunc{
|
||||
buildPkgsKey: ec2BuildPackageSet,
|
||||
osPkgsKey: ec2CommonPackageSet,
|
||||
},
|
||||
defaultTarget: "multi-user.target",
|
||||
enabledServices: ec2EnabledServices,
|
||||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 iommu.strict=0 crashkernel=auto",
|
||||
bootable: true,
|
||||
defaultSize: 10 * GigaByte,
|
||||
pipelines: ec2Pipelines,
|
||||
exports: []string{"image"},
|
||||
basePartitionTables: ec2BasePartitionTables,
|
||||
}
|
||||
|
||||
ec2ImgTypeX86_64 := imageType{
|
||||
name: "ec2",
|
||||
filename: "image.raw.xz",
|
||||
mimeType: "application/xz",
|
||||
packageSets: map[string]packageSetFunc{
|
||||
buildPkgsKey: ec2BuildPackageSet,
|
||||
osPkgsKey: rhelEc2PackageSet,
|
||||
},
|
||||
defaultTarget: "multi-user.target",
|
||||
enabledServices: ec2EnabledServices,
|
||||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto",
|
||||
bootable: true,
|
||||
bootType: distro.LegacyBootType,
|
||||
defaultSize: 10 * GigaByte,
|
||||
pipelines: rhelEc2Pipelines,
|
||||
exports: []string{"archive"},
|
||||
basePartitionTables: ec2BasePartitionTables,
|
||||
}
|
||||
|
||||
ec2ImgTypeAarch64 := imageType{
|
||||
name: "ec2",
|
||||
filename: "image.raw.xz",
|
||||
mimeType: "application/xz",
|
||||
packageSets: map[string]packageSetFunc{
|
||||
buildPkgsKey: ec2BuildPackageSet,
|
||||
osPkgsKey: rhelEc2PackageSet,
|
||||
},
|
||||
defaultTarget: "multi-user.target",
|
||||
enabledServices: ec2EnabledServices,
|
||||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 iommu.strict=0 crashkernel=auto",
|
||||
bootable: true,
|
||||
defaultSize: 10 * GigaByte,
|
||||
pipelines: rhelEc2Pipelines,
|
||||
exports: []string{"archive"},
|
||||
basePartitionTables: ec2BasePartitionTables,
|
||||
}
|
||||
|
||||
ec2HaImgTypeX86_64 := imageType{
|
||||
name: "ec2-ha",
|
||||
filename: "image.raw.xz",
|
||||
mimeType: "application/xz",
|
||||
packageSets: map[string]packageSetFunc{
|
||||
buildPkgsKey: ec2BuildPackageSet,
|
||||
osPkgsKey: rhelEc2HaPackageSet,
|
||||
},
|
||||
defaultTarget: "multi-user.target",
|
||||
enabledServices: ec2EnabledServices,
|
||||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto",
|
||||
bootable: true,
|
||||
bootType: distro.LegacyBootType,
|
||||
defaultSize: 10 * GigaByte,
|
||||
pipelines: rhelEc2Pipelines,
|
||||
exports: []string{"archive"},
|
||||
basePartitionTables: ec2BasePartitionTables,
|
||||
}
|
||||
|
||||
tarImgType := imageType{
|
||||
name: "tar",
|
||||
filename: "root.tar.xz",
|
||||
mimeType: "application/x-tar",
|
||||
packageSets: map[string]packageSetFunc{
|
||||
buildPkgsKey: distroBuildPackageSet,
|
||||
osPkgsKey: func(t *imageType) rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{"policycoreutils", "selinux-policy-targeted"},
|
||||
Exclude: []string{"rng-tools"},
|
||||
}
|
||||
},
|
||||
},
|
||||
pipelines: tarPipelines,
|
||||
exports: []string{"root-tar"},
|
||||
}
|
||||
tarInstallerImgTypeX86_64 := imageType{
|
||||
name: "image-installer",
|
||||
filename: "installer.iso",
|
||||
mimeType: "application/x-iso9660-image",
|
||||
packageSets: map[string]packageSetFunc{
|
||||
buildPkgsKey: anacondaBuildPackageSet,
|
||||
osPkgsKey: bareMetalPackageSet,
|
||||
installerPkgsKey: anacondaPackageSet,
|
||||
},
|
||||
rpmOstree: false,
|
||||
bootISO: true,
|
||||
bootable: true,
|
||||
pipelines: tarInstallerPipelines,
|
||||
exports: []string{"bootiso"},
|
||||
}
|
||||
|
||||
x86_64.addImageTypes(qcow2ImgType, vhdImgType, vmdkImgType, openstackImgType, amiImgTypeX86_64, ec2ImgTypeX86_64, ec2HaImgTypeX86_64, tarImgType, tarInstallerImgTypeX86_64, edgeCommitImgType, edgeInstallerImgType, edgeOCIImgType, edgeRawImgType, edgeSimplifiedInstallerImgType)
|
||||
aarch64.addImageTypes(qcow2ImgType, openstackImgType, amiImgTypeAarch64, ec2ImgTypeAarch64, tarImgType, edgeCommitImgType, edgeInstallerImgType, edgeOCIImgType, edgeRawImgType, edgeSimplifiedInstallerImgType)
|
||||
ppc64le.addImageTypes(qcow2ImgType, tarImgType)
|
||||
s390x.addImageTypes(qcow2ImgType, tarImgType)
|
||||
|
||||
rd.addArches(x86_64, aarch64, ppc64le, s390x)
|
||||
return rd
|
||||
}
|
||||
85
internal/distro/rhel86/distro_internal_test.go
Normal file
85
internal/distro/rhel86/distro_internal_test.go
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
package rhel86
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"testing"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
"github.com/osbuild/osbuild-composer/internal/disk"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var testBasicImageType = imageType{
|
||||
name: "test",
|
||||
basePartitionTables: defaultBasePartitionTables,
|
||||
}
|
||||
|
||||
var testEc2ImageType = imageType{
|
||||
name: "test_ec2",
|
||||
basePartitionTables: ec2BasePartitionTables,
|
||||
}
|
||||
|
||||
var mountpoints = []blueprint.FilesystemCustomization{
|
||||
{
|
||||
MinSize: 1024,
|
||||
Mountpoint: "/usr",
|
||||
},
|
||||
}
|
||||
|
||||
var rng = rand.New(rand.NewSource(0))
|
||||
|
||||
func containsMountpoint(expected []disk.Partition, mountpoint string) bool {
|
||||
for _, p := range expected {
|
||||
if p.Filesystem == nil {
|
||||
continue
|
||||
}
|
||||
if p.Filesystem.Mountpoint == mountpoint {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func TestDistro_UnsupportedArch(t *testing.T) {
|
||||
testBasicImageType.arch = &architecture{
|
||||
name: "unsupported_arch",
|
||||
}
|
||||
_, err := testBasicImageType.getPartitionTable(mountpoints, distro.ImageOptions{}, rng)
|
||||
require.EqualError(t, err, "unknown arch: "+testBasicImageType.arch.name)
|
||||
}
|
||||
|
||||
func TestDistro_DefaultPartitionTables(t *testing.T) {
|
||||
rhel8distro := New()
|
||||
for _, archName := range rhel8distro.ListArches() {
|
||||
testBasicImageType.arch = &architecture{
|
||||
name: archName,
|
||||
}
|
||||
pt, err := testBasicImageType.getPartitionTable(mountpoints, distro.ImageOptions{}, rng)
|
||||
require.Nil(t, err)
|
||||
for _, m := range mountpoints {
|
||||
contains := containsMountpoint(pt.Partitions, m.Mountpoint)
|
||||
assert.True(t, contains)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDistro_Ec2PartitionTables(t *testing.T) {
|
||||
rhel8distro := New()
|
||||
for _, archName := range rhel8distro.ListArches() {
|
||||
testEc2ImageType.arch = &architecture{
|
||||
name: archName,
|
||||
}
|
||||
pt, err := testEc2ImageType.getPartitionTable(mountpoints, distro.ImageOptions{}, rng)
|
||||
if _, exists := testEc2ImageType.basePartitionTables[archName]; exists {
|
||||
require.Nil(t, err)
|
||||
for _, m := range mountpoints {
|
||||
contains := containsMountpoint(pt.Partitions, m.Mountpoint)
|
||||
assert.True(t, contains)
|
||||
}
|
||||
} else {
|
||||
require.EqualError(t, err, "unknown arch: "+testEc2ImageType.arch.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
782
internal/distro/rhel86/distro_test.go
Normal file
782
internal/distro/rhel86/distro_test.go
Normal file
|
|
@ -0,0 +1,782 @@
|
|||
package rhel86_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/distro_test_common"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/rhel86"
|
||||
)
|
||||
|
||||
type rhelFamilyDistro struct {
|
||||
name string
|
||||
distro distro.Distro
|
||||
}
|
||||
|
||||
var rhelFamilyDistros = []rhelFamilyDistro{
|
||||
{
|
||||
name: "rhel",
|
||||
distro: rhel86.New(),
|
||||
},
|
||||
}
|
||||
|
||||
func TestFilenameFromType(t *testing.T) {
|
||||
type args struct {
|
||||
outputFormat string
|
||||
}
|
||||
type wantResult struct {
|
||||
filename string
|
||||
mimeType string
|
||||
wantErr bool
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want wantResult
|
||||
}{
|
||||
{
|
||||
name: "ami",
|
||||
args: args{"ami"},
|
||||
want: wantResult{
|
||||
filename: "image.raw",
|
||||
mimeType: "application/octet-stream",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "ec2",
|
||||
args: args{"ec2"},
|
||||
want: wantResult{
|
||||
filename: "image.raw.xz",
|
||||
mimeType: "application/xz",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "ec2-ha",
|
||||
args: args{"ec2-ha"},
|
||||
want: wantResult{
|
||||
filename: "image.raw.xz",
|
||||
mimeType: "application/xz",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "qcow2",
|
||||
args: args{"qcow2"},
|
||||
want: wantResult{
|
||||
filename: "disk.qcow2",
|
||||
mimeType: "application/x-qemu-disk",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "openstack",
|
||||
args: args{"openstack"},
|
||||
want: wantResult{
|
||||
filename: "disk.qcow2",
|
||||
mimeType: "application/x-qemu-disk",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "vhd",
|
||||
args: args{"vhd"},
|
||||
want: wantResult{
|
||||
filename: "disk.vhd",
|
||||
mimeType: "application/x-vhd",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "vmdk",
|
||||
args: args{"vmdk"},
|
||||
want: wantResult{
|
||||
filename: "disk.vmdk",
|
||||
mimeType: "application/x-vmdk",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "tar",
|
||||
args: args{"tar"},
|
||||
want: wantResult{
|
||||
filename: "root.tar.xz",
|
||||
mimeType: "application/x-tar",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "image-installer",
|
||||
args: args{"image-installer"},
|
||||
want: wantResult{
|
||||
filename: "installer.iso",
|
||||
mimeType: "application/x-iso9660-image",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "edge-commit",
|
||||
args: args{"edge-commit"},
|
||||
want: wantResult{
|
||||
filename: "commit.tar",
|
||||
mimeType: "application/x-tar",
|
||||
},
|
||||
},
|
||||
// Alias
|
||||
{
|
||||
name: "rhel-edge-commit",
|
||||
args: args{"rhel-edge-commit"},
|
||||
want: wantResult{
|
||||
filename: "commit.tar",
|
||||
mimeType: "application/x-tar",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "edge-container",
|
||||
args: args{"edge-container"},
|
||||
want: wantResult{
|
||||
filename: "container.tar",
|
||||
mimeType: "application/x-tar",
|
||||
},
|
||||
},
|
||||
// Alias
|
||||
{
|
||||
name: "rhel-edge-container",
|
||||
args: args{"rhel-edge-container"},
|
||||
want: wantResult{
|
||||
filename: "container.tar",
|
||||
mimeType: "application/x-tar",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "edge-installer",
|
||||
args: args{"edge-installer"},
|
||||
want: wantResult{
|
||||
filename: "installer.iso",
|
||||
mimeType: "application/x-iso9660-image",
|
||||
},
|
||||
},
|
||||
// Alias
|
||||
{
|
||||
name: "rhel-edge-installer",
|
||||
args: args{"rhel-edge-installer"},
|
||||
want: wantResult{
|
||||
filename: "installer.iso",
|
||||
mimeType: "application/x-iso9660-image",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "invalid-output-type",
|
||||
args: args{"foobar"},
|
||||
want: wantResult{wantErr: true},
|
||||
},
|
||||
}
|
||||
for _, dist := range rhelFamilyDistros {
|
||||
t.Run(dist.name, func(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
dist := dist.distro
|
||||
arch, _ := dist.GetArch("x86_64")
|
||||
imgType, err := arch.GetImageType(tt.args.outputFormat)
|
||||
if (err != nil) != tt.want.wantErr {
|
||||
t.Errorf("Arch.GetImageType() error = %v, wantErr %v", err, tt.want.wantErr)
|
||||
return
|
||||
}
|
||||
if !tt.want.wantErr {
|
||||
gotFilename := imgType.Filename()
|
||||
gotMIMEType := imgType.MIMEType()
|
||||
if gotFilename != tt.want.filename {
|
||||
t.Errorf("ImageType.Filename() got = %v, want %v", gotFilename, tt.want.filename)
|
||||
}
|
||||
if gotMIMEType != tt.want.mimeType {
|
||||
t.Errorf("ImageType.MIMEType() got1 = %v, want %v", gotMIMEType, tt.want.mimeType)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestImageType_BuildPackages(t *testing.T) {
|
||||
x8664BuildPackages := []string{
|
||||
"dnf",
|
||||
"dosfstools",
|
||||
"e2fsprogs",
|
||||
"grub2-efi-x64",
|
||||
"grub2-pc",
|
||||
"policycoreutils",
|
||||
"shim-x64",
|
||||
"systemd",
|
||||
"tar",
|
||||
"qemu-img",
|
||||
"xz",
|
||||
}
|
||||
aarch64BuildPackages := []string{
|
||||
"dnf",
|
||||
"dosfstools",
|
||||
"e2fsprogs",
|
||||
"policycoreutils",
|
||||
"qemu-img",
|
||||
"systemd",
|
||||
"tar",
|
||||
"xz",
|
||||
}
|
||||
buildPackages := map[string][]string{
|
||||
"x86_64": x8664BuildPackages,
|
||||
"aarch64": aarch64BuildPackages,
|
||||
}
|
||||
for _, dist := range rhelFamilyDistros {
|
||||
t.Run(dist.name, func(t *testing.T) {
|
||||
d := dist.distro
|
||||
for _, archLabel := range d.ListArches() {
|
||||
archStruct, err := d.GetArch(archLabel)
|
||||
if assert.NoErrorf(t, err, "d.GetArch(%v) returned err = %v; expected nil", archLabel, err) {
|
||||
continue
|
||||
}
|
||||
for _, itLabel := range archStruct.ListImageTypes() {
|
||||
itStruct, err := archStruct.GetImageType(itLabel)
|
||||
if assert.NoErrorf(t, err, "d.GetArch(%v) returned err = %v; expected nil", archLabel, err) {
|
||||
continue
|
||||
}
|
||||
buildPkgs := itStruct.PackageSets(blueprint.Blueprint{})["build"]
|
||||
assert.NotNil(t, buildPkgs)
|
||||
assert.ElementsMatch(t, buildPackages[archLabel], buildPkgs.Include)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestImageType_Name(t *testing.T) {
|
||||
imgMap := []struct {
|
||||
arch string
|
||||
imgNames []string
|
||||
}{
|
||||
{
|
||||
arch: "x86_64",
|
||||
imgNames: []string{
|
||||
"qcow2",
|
||||
"openstack",
|
||||
"vhd",
|
||||
"vmdk",
|
||||
"ami",
|
||||
"ec2",
|
||||
"ec2-ha",
|
||||
"edge-commit",
|
||||
"edge-container",
|
||||
"edge-installer",
|
||||
"tar",
|
||||
"image-installer",
|
||||
},
|
||||
},
|
||||
{
|
||||
arch: "aarch64",
|
||||
imgNames: []string{
|
||||
"qcow2",
|
||||
"openstack",
|
||||
"ami",
|
||||
"ec2",
|
||||
"edge-commit",
|
||||
"edge-container",
|
||||
"tar",
|
||||
},
|
||||
},
|
||||
{
|
||||
arch: "ppc64le",
|
||||
imgNames: []string{
|
||||
"qcow2",
|
||||
"tar",
|
||||
},
|
||||
},
|
||||
{
|
||||
arch: "s390x",
|
||||
imgNames: []string{
|
||||
"qcow2",
|
||||
"tar",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, dist := range rhelFamilyDistros {
|
||||
t.Run(dist.name, func(t *testing.T) {
|
||||
for _, mapping := range imgMap {
|
||||
if mapping.arch == "s390x" && dist.name == "centos" {
|
||||
continue
|
||||
}
|
||||
arch, err := dist.distro.GetArch(mapping.arch)
|
||||
if assert.NoError(t, err) {
|
||||
for _, imgName := range mapping.imgNames {
|
||||
if imgName == "edge-commit" && dist.name == "centos" {
|
||||
continue
|
||||
}
|
||||
imgType, err := arch.GetImageType(imgName)
|
||||
if assert.NoError(t, err) {
|
||||
assert.Equalf(t, imgName, imgType.Name(), "arch: %s", mapping.arch)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestImageTypeAliases(t *testing.T) {
|
||||
type args struct {
|
||||
imageTypeAliases []string
|
||||
}
|
||||
type wantResult struct {
|
||||
imageTypeName string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want wantResult
|
||||
}{
|
||||
{
|
||||
name: "edge-commit aliases",
|
||||
args: args{
|
||||
imageTypeAliases: []string{"rhel-edge-commit"},
|
||||
},
|
||||
want: wantResult{
|
||||
imageTypeName: "edge-commit",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "edge-container aliases",
|
||||
args: args{
|
||||
imageTypeAliases: []string{"rhel-edge-container"},
|
||||
},
|
||||
want: wantResult{
|
||||
imageTypeName: "edge-container",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "edge-installer aliases",
|
||||
args: args{
|
||||
imageTypeAliases: []string{"rhel-edge-installer"},
|
||||
},
|
||||
want: wantResult{
|
||||
imageTypeName: "edge-installer",
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, dist := range rhelFamilyDistros {
|
||||
t.Run(dist.name, func(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
dist := dist.distro
|
||||
for _, archName := range dist.ListArches() {
|
||||
t.Run(archName, func(t *testing.T) {
|
||||
arch, err := dist.GetArch(archName)
|
||||
require.Nilf(t, err,
|
||||
"failed to get architecture '%s', previously listed as supported for the distro '%s'",
|
||||
archName, dist.Name())
|
||||
// Test image type aliases only if the aliased image type is supported for the arch
|
||||
if _, err = arch.GetImageType(tt.want.imageTypeName); err != nil {
|
||||
t.Skipf("aliased image type '%s' is not supported for architecture '%s'",
|
||||
tt.want.imageTypeName, archName)
|
||||
}
|
||||
for _, alias := range tt.args.imageTypeAliases {
|
||||
t.Run(fmt.Sprintf("'%s' alias for image type '%s'", alias, tt.want.imageTypeName),
|
||||
func(t *testing.T) {
|
||||
gotImage, err := arch.GetImageType(alias)
|
||||
require.Nilf(t, err, "arch.GetImageType() for image type alias '%s' failed: %v",
|
||||
alias, err)
|
||||
assert.Equalf(t, tt.want.imageTypeName, gotImage.Name(),
|
||||
"got unexpected image type name for alias '%s'. got = %s, want = %s",
|
||||
alias, tt.want.imageTypeName, gotImage.Name())
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Check that Manifest() function returns an error for unsupported
|
||||
// configurations.
|
||||
func TestDistro_ManifestError(t *testing.T) {
|
||||
// Currently, the only unsupported configuration is OSTree commit types
|
||||
// with Kernel boot options
|
||||
r8distro := rhel86.New()
|
||||
bp := blueprint.Blueprint{
|
||||
Customizations: &blueprint.Customizations{
|
||||
Kernel: &blueprint.KernelCustomization{
|
||||
Append: "debug",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, archName := range r8distro.ListArches() {
|
||||
arch, _ := r8distro.GetArch(archName)
|
||||
for _, imgTypeName := range arch.ListImageTypes() {
|
||||
imgType, _ := arch.GetImageType(imgTypeName)
|
||||
imgOpts := distro.ImageOptions{
|
||||
Size: imgType.Size(0),
|
||||
}
|
||||
_, err := imgType.Manifest(bp.Customizations, imgOpts, nil, nil, 0)
|
||||
if imgTypeName == "edge-commit" || imgTypeName == "edge-container" {
|
||||
assert.EqualError(t, err, "kernel boot parameter customizations are not supported for ostree types")
|
||||
} else if imgTypeName == "edge-raw-image" {
|
||||
assert.EqualError(t, err, "edge raw images require specifying a URL from which to retrieve the OSTree commit")
|
||||
} else if imgTypeName == "edge-installer" || imgTypeName == "edge-simplified-installer" {
|
||||
assert.EqualError(t, err, fmt.Sprintf("boot ISO image type \"%s\" requires specifying a URL from which to retrieve the OSTree commit", imgTypeName))
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestArchitecture_ListImageTypes(t *testing.T) {
|
||||
imgMap := []struct {
|
||||
arch string
|
||||
imgNames []string
|
||||
rhelAdditionalImageTypes []string
|
||||
}{
|
||||
{
|
||||
arch: "x86_64",
|
||||
imgNames: []string{
|
||||
"qcow2",
|
||||
"openstack",
|
||||
"vhd",
|
||||
"vmdk",
|
||||
"ami",
|
||||
"ec2",
|
||||
"ec2-ha",
|
||||
"edge-commit",
|
||||
"edge-container",
|
||||
"edge-installer",
|
||||
"edge-raw-image",
|
||||
"edge-simplified-installer",
|
||||
"tar",
|
||||
"image-installer",
|
||||
},
|
||||
},
|
||||
{
|
||||
arch: "aarch64",
|
||||
imgNames: []string{
|
||||
"qcow2",
|
||||
"openstack",
|
||||
"ami",
|
||||
"ec2",
|
||||
"edge-commit",
|
||||
"edge-container",
|
||||
"edge-installer",
|
||||
"edge-simplified-installer",
|
||||
"edge-raw-image",
|
||||
"tar",
|
||||
},
|
||||
},
|
||||
{
|
||||
arch: "ppc64le",
|
||||
imgNames: []string{
|
||||
"qcow2",
|
||||
"tar",
|
||||
},
|
||||
},
|
||||
{
|
||||
arch: "s390x",
|
||||
imgNames: []string{
|
||||
"qcow2",
|
||||
"tar",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, dist := range rhelFamilyDistros {
|
||||
t.Run(dist.name, func(t *testing.T) {
|
||||
for _, mapping := range imgMap {
|
||||
arch, err := dist.distro.GetArch(mapping.arch)
|
||||
require.NoError(t, err)
|
||||
imageTypes := arch.ListImageTypes()
|
||||
|
||||
var expectedImageTypes []string
|
||||
expectedImageTypes = append(expectedImageTypes, mapping.imgNames...)
|
||||
if dist.name == "rhel" {
|
||||
expectedImageTypes = append(expectedImageTypes, mapping.rhelAdditionalImageTypes...)
|
||||
}
|
||||
|
||||
require.ElementsMatch(t, expectedImageTypes, imageTypes)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestRhel86_ListArches(t *testing.T) {
|
||||
arches := rhel86.New().ListArches()
|
||||
assert.Equal(t, []string{"aarch64", "ppc64le", "s390x", "x86_64"}, arches)
|
||||
}
|
||||
|
||||
func TestRhel86_GetArch(t *testing.T) {
|
||||
arches := []struct {
|
||||
name string
|
||||
errorExpected bool
|
||||
errorExpectedInCentos bool
|
||||
}{
|
||||
{
|
||||
name: "x86_64",
|
||||
},
|
||||
{
|
||||
name: "aarch64",
|
||||
},
|
||||
{
|
||||
name: "ppc64le",
|
||||
},
|
||||
{
|
||||
name: "s390x",
|
||||
},
|
||||
{
|
||||
name: "foo-arch",
|
||||
errorExpected: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, dist := range rhelFamilyDistros {
|
||||
t.Run(dist.name, func(t *testing.T) {
|
||||
for _, a := range arches {
|
||||
actualArch, err := dist.distro.GetArch(a.name)
|
||||
if a.errorExpected || (a.errorExpectedInCentos && dist.name == "centos") {
|
||||
assert.Nil(t, actualArch)
|
||||
assert.Error(t, err)
|
||||
} else {
|
||||
assert.Equal(t, a.name, actualArch.Name())
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestRhel86_Name(t *testing.T) {
|
||||
distro := rhel86.New()
|
||||
assert.Equal(t, "rhel-86", distro.Name())
|
||||
}
|
||||
|
||||
func TestRhel86_ModulePlatformID(t *testing.T) {
|
||||
distro := rhel86.New()
|
||||
assert.Equal(t, "platform:el8", distro.ModulePlatformID())
|
||||
}
|
||||
|
||||
func TestRhel86_KernelOption(t *testing.T) {
|
||||
distro_test_common.TestDistro_KernelOption(t, rhel86.New())
|
||||
}
|
||||
|
||||
func TestDistro_CustomFileSystemManifestError(t *testing.T) {
|
||||
r8distro := rhel86.New()
|
||||
bp := blueprint.Blueprint{
|
||||
Customizations: &blueprint.Customizations{
|
||||
Filesystem: []blueprint.FilesystemCustomization{
|
||||
{
|
||||
MinSize: 1024,
|
||||
Mountpoint: "/boot",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, archName := range r8distro.ListArches() {
|
||||
arch, _ := r8distro.GetArch(archName)
|
||||
for _, imgTypeName := range arch.ListImageTypes() {
|
||||
imgType, _ := arch.GetImageType(imgTypeName)
|
||||
_, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, 0)
|
||||
if imgTypeName == "edge-commit" || imgTypeName == "edge-container" {
|
||||
assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types")
|
||||
} else if imgTypeName == "edge-installer" || imgTypeName == "edge-simplified-installer" || imgTypeName == "edge-raw-image" {
|
||||
continue
|
||||
} else {
|
||||
assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/boot\"]")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDistro_TestRootMountPoint(t *testing.T) {
|
||||
r8distro := rhel86.New()
|
||||
bp := blueprint.Blueprint{
|
||||
Customizations: &blueprint.Customizations{
|
||||
Filesystem: []blueprint.FilesystemCustomization{
|
||||
{
|
||||
MinSize: 1024,
|
||||
Mountpoint: "/",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, archName := range r8distro.ListArches() {
|
||||
arch, _ := r8distro.GetArch(archName)
|
||||
for _, imgTypeName := range arch.ListImageTypes() {
|
||||
imgType, _ := arch.GetImageType(imgTypeName)
|
||||
_, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, 0)
|
||||
if imgTypeName == "edge-commit" || imgTypeName == "edge-container" {
|
||||
assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types")
|
||||
} else if imgTypeName == "edge-installer" || imgTypeName == "edge-simplified-installer" || imgTypeName == "edge-raw-image" {
|
||||
continue
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDistro_CustomFileSystemSubDirectories(t *testing.T) {
|
||||
r8distro := rhel86.New()
|
||||
bp := blueprint.Blueprint{
|
||||
Customizations: &blueprint.Customizations{
|
||||
Filesystem: []blueprint.FilesystemCustomization{
|
||||
{
|
||||
MinSize: 1024,
|
||||
Mountpoint: "/var/log",
|
||||
},
|
||||
{
|
||||
MinSize: 1024,
|
||||
Mountpoint: "/var/log/audit",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, archName := range r8distro.ListArches() {
|
||||
arch, _ := r8distro.GetArch(archName)
|
||||
for _, imgTypeName := range arch.ListImageTypes() {
|
||||
imgType, _ := arch.GetImageType(imgTypeName)
|
||||
_, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, 0)
|
||||
if strings.HasPrefix(imgTypeName, "edge-") {
|
||||
continue
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDistro_MountpointsWithArbitraryDepthAllowed(t *testing.T) {
|
||||
r8distro := rhel86.New()
|
||||
bp := blueprint.Blueprint{
|
||||
Customizations: &blueprint.Customizations{
|
||||
Filesystem: []blueprint.FilesystemCustomization{
|
||||
{
|
||||
MinSize: 1024,
|
||||
Mountpoint: "/var/a",
|
||||
},
|
||||
{
|
||||
MinSize: 1024,
|
||||
Mountpoint: "/var/a/b",
|
||||
},
|
||||
{
|
||||
MinSize: 1024,
|
||||
Mountpoint: "/var/a/b/c",
|
||||
},
|
||||
{
|
||||
MinSize: 1024,
|
||||
Mountpoint: "/var/a/b/c/d",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, archName := range r8distro.ListArches() {
|
||||
arch, _ := r8distro.GetArch(archName)
|
||||
for _, imgTypeName := range arch.ListImageTypes() {
|
||||
imgType, _ := arch.GetImageType(imgTypeName)
|
||||
_, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, 0)
|
||||
if strings.HasPrefix(imgTypeName, "edge-") {
|
||||
continue
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDistro_DirtyMountpointsNotAllowed(t *testing.T) {
|
||||
r8distro := rhel86.New()
|
||||
bp := blueprint.Blueprint{
|
||||
Customizations: &blueprint.Customizations{
|
||||
Filesystem: []blueprint.FilesystemCustomization{
|
||||
{
|
||||
MinSize: 1024,
|
||||
Mountpoint: "//",
|
||||
},
|
||||
{
|
||||
MinSize: 1024,
|
||||
Mountpoint: "/var//",
|
||||
},
|
||||
{
|
||||
MinSize: 1024,
|
||||
Mountpoint: "/var//log/audit/",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, archName := range r8distro.ListArches() {
|
||||
arch, _ := r8distro.GetArch(archName)
|
||||
for _, imgTypeName := range arch.ListImageTypes() {
|
||||
imgType, _ := arch.GetImageType(imgTypeName)
|
||||
_, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, 0)
|
||||
if strings.HasPrefix(imgTypeName, "edge-") {
|
||||
continue
|
||||
} else {
|
||||
assert.EqualError(t, err, "The following custom mountpoints are not supported [\"//\" \"/var//\" \"/var//log/audit/\"]")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDistro_CustomFileSystemPatternMatching(t *testing.T) {
|
||||
r8distro := rhel86.New()
|
||||
bp := blueprint.Blueprint{
|
||||
Customizations: &blueprint.Customizations{
|
||||
Filesystem: []blueprint.FilesystemCustomization{
|
||||
{
|
||||
MinSize: 1024,
|
||||
Mountpoint: "/variable",
|
||||
},
|
||||
{
|
||||
MinSize: 1024,
|
||||
Mountpoint: "/variable/log/audit",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, archName := range r8distro.ListArches() {
|
||||
arch, _ := r8distro.GetArch(archName)
|
||||
for _, imgTypeName := range arch.ListImageTypes() {
|
||||
imgType, _ := arch.GetImageType(imgTypeName)
|
||||
_, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, 0)
|
||||
if imgTypeName == "edge-commit" || imgTypeName == "edge-container" {
|
||||
assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types")
|
||||
} else if imgTypeName == "edge-installer" || imgTypeName == "edge-simplified-installer" || imgTypeName == "edge-raw-image" {
|
||||
continue
|
||||
} else {
|
||||
assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/variable\" \"/variable/log/audit\"]")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDistro_CustomUsrPartitionNotLargeEnough(t *testing.T) {
|
||||
r8distro := rhel86.New()
|
||||
bp := blueprint.Blueprint{
|
||||
Customizations: &blueprint.Customizations{
|
||||
Filesystem: []blueprint.FilesystemCustomization{
|
||||
{
|
||||
MinSize: 1024,
|
||||
Mountpoint: "/usr",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, archName := range r8distro.ListArches() {
|
||||
arch, _ := r8distro.GetArch(archName)
|
||||
for _, imgTypeName := range arch.ListImageTypes() {
|
||||
imgType, _ := arch.GetImageType(imgTypeName)
|
||||
_, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, 0)
|
||||
if imgTypeName == "edge-commit" || imgTypeName == "edge-container" {
|
||||
assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types")
|
||||
} else if imgTypeName == "edge-installer" || imgTypeName == "edge-simplified-installer" || imgTypeName == "edge-raw-image" {
|
||||
continue
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
714
internal/distro/rhel86/package_sets.go
Normal file
714
internal/distro/rhel86/package_sets.go
Normal file
|
|
@ -0,0 +1,714 @@
|
|||
package rhel86
|
||||
|
||||
// This file defines package sets that are used by more than one image type.
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
)
|
||||
|
||||
// BUILD PACKAGE SETS
|
||||
|
||||
// distro-wide build package set
|
||||
func distroBuildPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
ps := rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"dnf", "dosfstools", "e2fsprogs", "glibc", "lorax-templates-generic",
|
||||
"lorax-templates-rhel", "policycoreutils", "python36",
|
||||
"python3-iniparse", "qemu-img", "selinux-policy-targeted", "systemd",
|
||||
"tar", "xfsprogs", "xz",
|
||||
},
|
||||
}
|
||||
|
||||
switch t.arch.Name() {
|
||||
|
||||
case distro.X86_64ArchName:
|
||||
ps = ps.Append(x8664BuildPackageSet(t))
|
||||
|
||||
case distro.Ppc64leArchName:
|
||||
ps = ps.Append(ppc64leBuildPackageSet(t))
|
||||
}
|
||||
|
||||
return ps
|
||||
}
|
||||
|
||||
// x86_64 build package set
|
||||
func x8664BuildPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{"grub2-pc"},
|
||||
}
|
||||
}
|
||||
|
||||
// ppc64le build package set
|
||||
func ppc64leBuildPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{"grub2-ppc64le", "grub2-ppc64le-modules"},
|
||||
}
|
||||
}
|
||||
|
||||
// common ec2 image build package set
|
||||
func ec2BuildPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
return distroBuildPackageSet(t).Append(
|
||||
rpmmd.PackageSet{
|
||||
Include: []string{"python3-pyyaml"},
|
||||
})
|
||||
}
|
||||
|
||||
// common edge image build package set
|
||||
func edgeBuildPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
return distroBuildPackageSet(t).Append(
|
||||
rpmmd.PackageSet{
|
||||
Include: []string{"rpm-ostree"},
|
||||
Exclude: nil,
|
||||
})
|
||||
}
|
||||
|
||||
func edgeRawImageBuildPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
return edgeBuildPackageSet(t).Append(
|
||||
bootPackageSet(t),
|
||||
)
|
||||
}
|
||||
|
||||
// installer boot package sets, needed for booting and
|
||||
// also in the build host
|
||||
|
||||
func anacondaBootPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
ps := rpmmd.PackageSet{}
|
||||
|
||||
grubCommon := rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"grub2-tools",
|
||||
"grub2-tools-extra",
|
||||
"grub2-tools-minimal",
|
||||
},
|
||||
}
|
||||
|
||||
efiCommon := rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"efibootmgr",
|
||||
},
|
||||
}
|
||||
|
||||
switch t.arch.Name() {
|
||||
case distro.X86_64ArchName:
|
||||
ps = ps.Append(grubCommon)
|
||||
ps = ps.Append(efiCommon)
|
||||
ps = ps.Append(rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"grub2-efi-ia32-cdboot",
|
||||
"grub2-efi-x64",
|
||||
"grub2-efi-x64-cdboot",
|
||||
"grub2-pc",
|
||||
"grub2-pc-modules",
|
||||
"shim-ia32",
|
||||
"shim-x64",
|
||||
"syslinux",
|
||||
"syslinux-nonlinux",
|
||||
},
|
||||
})
|
||||
case distro.Aarch64ArchName:
|
||||
ps = ps.Append(grubCommon)
|
||||
ps = ps.Append(efiCommon)
|
||||
ps = ps.Append(rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"grub2-efi-aa64-cdboot",
|
||||
"grub2-efi-aa64",
|
||||
"shim-aa64",
|
||||
},
|
||||
})
|
||||
|
||||
default:
|
||||
panic(fmt.Sprintf("unsupported arch: %s", t.arch.Name()))
|
||||
}
|
||||
|
||||
return ps
|
||||
}
|
||||
|
||||
func installerBuildPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
return distroBuildPackageSet(t).Append(
|
||||
rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"genisoimage",
|
||||
"isomd5sum",
|
||||
"xorriso",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func anacondaBuildPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
ps := rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"squashfs-tools",
|
||||
},
|
||||
}
|
||||
|
||||
ps = ps.Append(installerBuildPackageSet(t))
|
||||
ps = ps.Append(anacondaBootPackageSet(t))
|
||||
|
||||
return ps
|
||||
}
|
||||
|
||||
func edgeInstallerBuildPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
return anacondaBuildPackageSet(t).Append(
|
||||
edgeBuildPackageSet(t),
|
||||
)
|
||||
}
|
||||
|
||||
// BOOT PACKAGE SETS
|
||||
|
||||
func bootPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
if !t.bootable {
|
||||
return rpmmd.PackageSet{}
|
||||
}
|
||||
|
||||
var addLegacyBootPkg bool
|
||||
var addUEFIBootPkg bool
|
||||
|
||||
switch bt := t.getBootType(); bt {
|
||||
case distro.LegacyBootType:
|
||||
addLegacyBootPkg = true
|
||||
case distro.UEFIBootType:
|
||||
addUEFIBootPkg = true
|
||||
case distro.HybridBootType:
|
||||
addLegacyBootPkg = true
|
||||
addUEFIBootPkg = true
|
||||
default:
|
||||
panic(fmt.Sprintf("unsupported boot type: %q", bt))
|
||||
}
|
||||
|
||||
ps := rpmmd.PackageSet{}
|
||||
|
||||
switch t.arch.Name() {
|
||||
case distro.X86_64ArchName:
|
||||
if addLegacyBootPkg {
|
||||
ps = ps.Append(x8664LegacyBootPackageSet(t))
|
||||
}
|
||||
if addUEFIBootPkg {
|
||||
ps = ps.Append(x8664UEFIBootPackageSet(t))
|
||||
}
|
||||
|
||||
case distro.Aarch64ArchName:
|
||||
ps = ps.Append(aarch64UEFIBootPackageSet(t))
|
||||
|
||||
case distro.Ppc64leArchName:
|
||||
ps = ps.Append(ppc64leLegacyBootPackageSet(t))
|
||||
|
||||
case distro.S390xArchName:
|
||||
ps = ps.Append(s390xLegacyBootPackageSet(t))
|
||||
|
||||
default:
|
||||
panic(fmt.Sprintf("unsupported boot arch: %s", t.arch.Name()))
|
||||
}
|
||||
|
||||
return ps
|
||||
}
|
||||
|
||||
// x86_64 Legacy arch-specific boot package set
|
||||
func x8664LegacyBootPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{"dracut-config-generic", "grub2-pc"},
|
||||
}
|
||||
}
|
||||
|
||||
// x86_64 UEFI arch-specific boot package set
|
||||
func x8664UEFIBootPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"dracut-config-generic",
|
||||
"efibootmgr",
|
||||
"grub2-efi-x64",
|
||||
"shim-x64",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// aarch64 UEFI arch-specific boot package set
|
||||
func aarch64UEFIBootPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"dracut-config-generic", "efibootmgr", "grub2-efi-aa64",
|
||||
"grub2-tools", "shim-aa64",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// ppc64le Legacy arch-specific boot package set
|
||||
func ppc64leLegacyBootPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"dracut-config-generic", "powerpc-utils", "grub2-ppc64le",
|
||||
"grub2-ppc64le-modules",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// s390x Legacy arch-specific boot package set
|
||||
func s390xLegacyBootPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{"dracut-config-generic", "s390utils-base"},
|
||||
}
|
||||
}
|
||||
|
||||
// OS package sets
|
||||
|
||||
func qcow2CommonPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"@core", "authselect-compat", "chrony", "cloud-init",
|
||||
"cloud-utils-growpart", "cockpit-system", "cockpit-ws",
|
||||
"dhcp-client", "dnf", "dnf-utils", "dosfstools", "dracut-norescue",
|
||||
"insights-client", "NetworkManager", "net-tools", "nfs-utils",
|
||||
"oddjob", "oddjob-mkhomedir", "psmisc", "python3-jsonschema",
|
||||
"qemu-guest-agent", "redhat-release", "redhat-release-eula",
|
||||
"rsync", "subscription-manager-cockpit", "tar", "tcpdump", "yum",
|
||||
},
|
||||
Exclude: []string{
|
||||
"aic94xx-firmware", "alsa-firmware", "alsa-lib",
|
||||
"alsa-tools-firmware", "biosdevname", "dnf-plugin-spacewalk",
|
||||
"dracut-config-rescue", "fedora-release", "fedora-repos",
|
||||
"firewalld", "fwupd", "iprutils", "ivtv-firmware",
|
||||
"iwl100-firmware", "iwl1000-firmware", "iwl105-firmware",
|
||||
"iwl135-firmware", "iwl2000-firmware", "iwl2030-firmware",
|
||||
"iwl3160-firmware", "iwl3945-firmware", "iwl4965-firmware",
|
||||
"iwl5000-firmware", "iwl5150-firmware", "iwl6000-firmware",
|
||||
"iwl6000g2a-firmware", "iwl6000g2b-firmware", "iwl6050-firmware",
|
||||
"iwl7260-firmware", "langpacks-*", "langpacks-en", "langpacks-en",
|
||||
"libertas-sd8686-firmware", "libertas-sd8787-firmware",
|
||||
"libertas-usb8388-firmware", "nss", "plymouth", "rng-tools",
|
||||
"udisks2",
|
||||
},
|
||||
}.Append(bootPackageSet(t))
|
||||
}
|
||||
|
||||
func vhdCommonPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
// Defaults
|
||||
"@Core", "langpacks-en",
|
||||
|
||||
// From the lorax kickstart
|
||||
"selinux-policy-targeted", "chrony", "WALinuxAgent", "python3",
|
||||
"net-tools", "cloud-init", "cloud-utils-growpart", "gdisk",
|
||||
|
||||
// removed from defaults but required to boot in azure
|
||||
"dhcp-client",
|
||||
},
|
||||
Exclude: []string{
|
||||
"dracut-config-rescue", "rng-tools",
|
||||
},
|
||||
}.Append(bootPackageSet(t))
|
||||
}
|
||||
|
||||
func vmdkCommonPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"@core", "chrony", "firewalld", "langpacks-en", "open-vm-tools",
|
||||
"selinux-policy-targeted",
|
||||
},
|
||||
Exclude: []string{
|
||||
"dracut-config-rescue", "rng-tools",
|
||||
},
|
||||
}.Append(bootPackageSet(t))
|
||||
|
||||
}
|
||||
|
||||
func openstackCommonPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
// Defaults
|
||||
"@Core", "langpacks-en",
|
||||
|
||||
// From the lorax kickstart
|
||||
"selinux-policy-targeted", "cloud-init", "qemu-guest-agent",
|
||||
"spice-vdagent",
|
||||
},
|
||||
Exclude: []string{
|
||||
"dracut-config-rescue", "rng-tools",
|
||||
},
|
||||
}.Append(bootPackageSet(t))
|
||||
|
||||
}
|
||||
|
||||
func ec2CommonPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"@core", "authselect-compat", "chrony", "cloud-init", "cloud-utils-growpart",
|
||||
"dhcp-client", "yum-utils", "dracut-config-generic", "dracut-norescue", "gdisk",
|
||||
"grub2", "insights-client", "langpacks-en", "NetworkManager",
|
||||
"NetworkManager-cloud-setup", "redhat-release",
|
||||
"redhat-release-eula", "rsync", "tar", "qemu-guest-agent",
|
||||
},
|
||||
Exclude: []string{
|
||||
"aic94xx-firmware", "alsa-firmware", "alsa-lib",
|
||||
"alsa-tools-firmware", "biosdevname", "firewalld", "iprutils", "ivtv-firmware",
|
||||
"iwl1000-firmware", "iwl100-firmware", "iwl105-firmware",
|
||||
"iwl135-firmware", "iwl2000-firmware", "iwl2030-firmware",
|
||||
"iwl3160-firmware", "iwl3945-firmware", "iwl4965-firmware",
|
||||
"iwl5000-firmware", "iwl5150-firmware", "iwl6000-firmware",
|
||||
"iwl6000g2a-firmware", "iwl6000g2b-firmware", "iwl6050-firmware",
|
||||
"iwl7260-firmware", "libertas-sd8686-firmware",
|
||||
"libertas-sd8787-firmware", "libertas-usb8388-firmware",
|
||||
"plymouth",
|
||||
},
|
||||
}.Append(bootPackageSet(t))
|
||||
}
|
||||
|
||||
// rhel-ec2 image package set
|
||||
func rhelEc2PackageSet(t *imageType) rpmmd.PackageSet {
|
||||
ec2PackageSet := ec2CommonPackageSet(t)
|
||||
ec2PackageSet.Include = append(ec2PackageSet.Include, "rh-amazon-rhui-client")
|
||||
return ec2PackageSet
|
||||
}
|
||||
|
||||
// rhel-ha-ec2 image package set
|
||||
func rhelEc2HaPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
ec2HaPackageSet := ec2CommonPackageSet(t)
|
||||
ec2HaPackageSet.Include = append(ec2HaPackageSet.Include,
|
||||
"fence-agents-all",
|
||||
"pacemaker",
|
||||
"pcs",
|
||||
"rh-amazon-rhui-client-ha",
|
||||
)
|
||||
return ec2HaPackageSet
|
||||
}
|
||||
|
||||
// edge commit OS package set
|
||||
func edgeCommitPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
ps := rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"redhat-release", "glibc", "glibc-minimal-langpack",
|
||||
"nss-altfiles", "dracut-config-generic", "dracut-network",
|
||||
"basesystem", "bash", "platform-python", "shadow-utils", "chrony",
|
||||
"setup", "shadow-utils", "sudo", "systemd", "coreutils",
|
||||
"util-linux", "curl", "vim-minimal", "rpm", "rpm-ostree", "polkit",
|
||||
"lvm2", "cryptsetup", "pinentry", "e2fsprogs", "dosfstools",
|
||||
"keyutils", "gnupg2", "attr", "xz", "gzip", "firewalld",
|
||||
"iptables", "NetworkManager", "NetworkManager-wifi",
|
||||
"NetworkManager-wwan", "wpa_supplicant", "dnsmasq", "traceroute",
|
||||
"hostname", "iproute", "iputils", "openssh-clients", "procps-ng",
|
||||
"rootfiles", "openssh-server", "passwd", "policycoreutils",
|
||||
"policycoreutils-python-utils", "selinux-policy-targeted",
|
||||
"setools-console", "less", "tar", "rsync", "fwupd", "usbguard",
|
||||
"bash-completion", "tmux", "ima-evm-utils", "audit", "podman",
|
||||
"container-selinux", "skopeo", "criu", "slirp4netns",
|
||||
"fuse-overlayfs", "clevis", "clevis-dracut", "clevis-luks",
|
||||
"greenboot", "greenboot-grub2", "greenboot-rpm-ostree-grub2",
|
||||
"greenboot-reboot", "greenboot-status",
|
||||
},
|
||||
Exclude: []string{"rng-tools"},
|
||||
}
|
||||
|
||||
ps = ps.Append(bootPackageSet(t))
|
||||
|
||||
switch t.arch.Name() {
|
||||
case distro.X86_64ArchName:
|
||||
ps = ps.Append(x8664EdgeCommitPackageSet(t))
|
||||
|
||||
case distro.Aarch64ArchName:
|
||||
ps = ps.Append(aarch64EdgeCommitPackageSet(t))
|
||||
}
|
||||
|
||||
return ps
|
||||
|
||||
}
|
||||
|
||||
func x8664EdgeCommitPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"grub2", "grub2-efi-x64", "efibootmgr", "shim-x64",
|
||||
"microcode_ctl", "iwl1000-firmware", "iwl100-firmware",
|
||||
"iwl105-firmware", "iwl135-firmware", "iwl2000-firmware",
|
||||
"iwl2030-firmware", "iwl3160-firmware", "iwl5000-firmware",
|
||||
"iwl5150-firmware", "iwl6000-firmware", "iwl6050-firmware",
|
||||
"iwl7260-firmware",
|
||||
},
|
||||
Exclude: nil,
|
||||
}
|
||||
}
|
||||
|
||||
func aarch64EdgeCommitPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{"grub2-efi-aa64", "efibootmgr", "shim-aa64", "iwl7260-firmware"},
|
||||
Exclude: nil,
|
||||
}
|
||||
}
|
||||
|
||||
func bareMetalPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"authselect-compat", "chrony", "cockpit-system", "cockpit-ws",
|
||||
"@core", "dhcp-client", "dnf", "dnf-utils", "dosfstools",
|
||||
"dracut-norescue", "insights-client", "iwl1000-firmware",
|
||||
"iwl100-firmware", "iwl105-firmware", "iwl135-firmware",
|
||||
"iwl2000-firmware", "iwl2030-firmware", "iwl3160-firmware",
|
||||
"iwl3945-firmware", "iwl4965-firmware", "iwl5000-firmware",
|
||||
"iwl5150-firmware", "iwl6000-firmware", "iwl6000g2a-firmware",
|
||||
"iwl6000g2b-firmware", "iwl6050-firmware", "iwl7260-firmware",
|
||||
"lvm2", "net-tools", "NetworkManager", "nfs-utils", "oddjob",
|
||||
"oddjob-mkhomedir", "policycoreutils", "psmisc",
|
||||
"python3-jsonschema", "qemu-guest-agent", "redhat-release",
|
||||
"redhat-release-eula", "rsync", "selinux-policy-targeted",
|
||||
"subscription-manager-cockpit", "tar", "tcpdump", "yum",
|
||||
},
|
||||
Exclude: nil,
|
||||
}.Append(bootPackageSet(t))
|
||||
}
|
||||
|
||||
// INSTALLER PACKAGE SET
|
||||
|
||||
func installerPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
ps := rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"anaconda-dracut",
|
||||
"curl",
|
||||
"dracut-config-generic",
|
||||
"dracut-network",
|
||||
"hostname",
|
||||
"iwl100-firmware",
|
||||
"iwl1000-firmware",
|
||||
"iwl105-firmware",
|
||||
"iwl135-firmware",
|
||||
"iwl2000-firmware",
|
||||
"iwl2030-firmware",
|
||||
"iwl3160-firmware",
|
||||
"iwl5000-firmware",
|
||||
"iwl5150-firmware",
|
||||
"iwl6000-firmware",
|
||||
"iwl6050-firmware",
|
||||
"iwl7260-firmware",
|
||||
"kernel",
|
||||
"less",
|
||||
"nfs-utils",
|
||||
"openssh-clients",
|
||||
"ostree",
|
||||
"plymouth",
|
||||
"prefixdevname",
|
||||
"rng-tools",
|
||||
"rpcbind",
|
||||
"selinux-policy-targeted",
|
||||
"systemd",
|
||||
"tar",
|
||||
"xfsprogs",
|
||||
"xz",
|
||||
},
|
||||
}
|
||||
|
||||
switch t.arch.Name() {
|
||||
case distro.X86_64ArchName:
|
||||
ps = ps.Append(rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"biosdevname",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
return ps
|
||||
}
|
||||
|
||||
func anacondaPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
|
||||
// common installer packages
|
||||
ps := installerPackageSet(t)
|
||||
|
||||
ps = ps.Append(rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"aajohan-comfortaa-fonts",
|
||||
"abattis-cantarell-fonts",
|
||||
"alsa-firmware",
|
||||
"alsa-tools-firmware",
|
||||
"anaconda",
|
||||
"anaconda-install-env-deps",
|
||||
"anaconda-widgets",
|
||||
"audit",
|
||||
"bind-utils",
|
||||
"bitmap-fangsongti-fonts",
|
||||
"bzip2",
|
||||
"cryptsetup",
|
||||
"dbus-x11",
|
||||
"dejavu-sans-fonts",
|
||||
"dejavu-sans-mono-fonts",
|
||||
"device-mapper-persistent-data",
|
||||
"dnf",
|
||||
"dump",
|
||||
"ethtool",
|
||||
"fcoe-utils",
|
||||
"ftp",
|
||||
"gdb-gdbserver",
|
||||
"gdisk",
|
||||
"gfs2-utils",
|
||||
"glibc-all-langpacks",
|
||||
"google-noto-sans-cjk-ttc-fonts",
|
||||
"gsettings-desktop-schemas",
|
||||
"hdparm",
|
||||
"hexedit",
|
||||
"gsettings-desktop-schemas",
|
||||
"hdparm",
|
||||
"hexedit",
|
||||
"initscripts",
|
||||
"ipmitool",
|
||||
"iwl3945-firmware",
|
||||
"iwl4965-firmware",
|
||||
"iwl6000g2a-firmware",
|
||||
"iwl6000g2b-firmware",
|
||||
"jomolhari-fonts",
|
||||
"kacst-farsi-fonts",
|
||||
"kacst-qurn-fonts",
|
||||
"kbd",
|
||||
"kbd-misc",
|
||||
"kdump-anaconda-addon",
|
||||
"khmeros-base-fonts",
|
||||
"libblockdev-lvm-dbus",
|
||||
"libertas-sd8686-firmware",
|
||||
"libertas-sd8787-firmware",
|
||||
"libertas-usb8388-firmware",
|
||||
"libertas-usb8388-olpc-firmware",
|
||||
"libibverbs",
|
||||
"libreport-plugin-bugzilla",
|
||||
"libreport-plugin-reportuploader",
|
||||
"libreport-rhel-anaconda-bugzilla",
|
||||
"librsvg2",
|
||||
"linux-firmware",
|
||||
"lklug-fonts",
|
||||
"lohit-assamese-fonts",
|
||||
"lohit-bengali-fonts",
|
||||
"lohit-devanagari-fonts",
|
||||
"lohit-gujarati-fonts",
|
||||
"lohit-gurmukhi-fonts",
|
||||
"lohit-kannada-fonts",
|
||||
"lohit-odia-fonts",
|
||||
"lohit-tamil-fonts",
|
||||
"lohit-telugu-fonts",
|
||||
"lsof",
|
||||
"madan-fonts",
|
||||
"metacity",
|
||||
"mt-st",
|
||||
"mtr",
|
||||
"net-tools",
|
||||
"nm-connection-editor",
|
||||
"nmap-ncat",
|
||||
"nss-tools",
|
||||
"openssh-server",
|
||||
"oscap-anaconda-addon",
|
||||
"pciutils",
|
||||
"perl-interpreter",
|
||||
"pigz",
|
||||
"python3-pyatspi",
|
||||
"rdma-core",
|
||||
"redhat-release-eula",
|
||||
"rpm-ostree",
|
||||
"rsync",
|
||||
"rsyslog",
|
||||
"sg3_utils",
|
||||
"sil-abyssinica-fonts",
|
||||
"sil-padauk-fonts",
|
||||
"sil-scheherazade-fonts",
|
||||
"smartmontools",
|
||||
"smc-meera-fonts",
|
||||
"spice-vdagent",
|
||||
"strace",
|
||||
"system-storage-manager",
|
||||
"thai-scalable-waree-fonts",
|
||||
"tigervnc-server-minimal",
|
||||
"tigervnc-server-module",
|
||||
"udisks2",
|
||||
"udisks2-iscsi",
|
||||
"usbutils",
|
||||
"vim-minimal",
|
||||
"volume_key",
|
||||
"wget",
|
||||
"xfsdump",
|
||||
"xorg-x11-drivers",
|
||||
"xorg-x11-fonts-misc",
|
||||
"xorg-x11-server-Xorg",
|
||||
"xorg-x11-server-utils",
|
||||
"xorg-x11-xauth",
|
||||
},
|
||||
})
|
||||
|
||||
ps = ps.Append(anacondaBootPackageSet(t))
|
||||
|
||||
switch t.arch.Name() {
|
||||
case distro.X86_64ArchName:
|
||||
ps = ps.Append(rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"biosdevname",
|
||||
"dmidecode",
|
||||
"memtest86+",
|
||||
},
|
||||
})
|
||||
|
||||
case distro.Aarch64ArchName:
|
||||
ps = ps.Append(rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"dmidecode",
|
||||
},
|
||||
})
|
||||
|
||||
default:
|
||||
panic(fmt.Sprintf("unsupported arch: %s", t.arch.Name()))
|
||||
}
|
||||
|
||||
return ps
|
||||
}
|
||||
|
||||
func edgeInstallerPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
return anacondaPackageSet(t)
|
||||
}
|
||||
|
||||
func edgeSimplifiedInstallerPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
// common installer packages
|
||||
ps := installerPackageSet(t)
|
||||
|
||||
ps = ps.Append(rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"attr",
|
||||
"basesystem",
|
||||
"binutils",
|
||||
"bsdtar",
|
||||
"cloud-utils-growpart",
|
||||
"coreos-installer",
|
||||
"coreos-installer-bootinfra",
|
||||
"coreutils",
|
||||
"device-mapper-multipath",
|
||||
"dnsmasq",
|
||||
"dosfstools",
|
||||
"dracut-live",
|
||||
"e2fsprogs",
|
||||
"fcoe-utils",
|
||||
"gzip",
|
||||
"ima-evm-utils",
|
||||
"iproute",
|
||||
"iptables",
|
||||
"iputils",
|
||||
"iscsi-initiator-utils",
|
||||
"keyutils",
|
||||
"lldpad",
|
||||
"lvm2",
|
||||
"passwd",
|
||||
"policycoreutils",
|
||||
"policycoreutils-python-utils",
|
||||
"procps-ng",
|
||||
"rootfiles",
|
||||
"setools-console",
|
||||
"sudo",
|
||||
"traceroute",
|
||||
"util-linux",
|
||||
},
|
||||
Exclude: nil,
|
||||
})
|
||||
|
||||
switch t.arch.Name() {
|
||||
|
||||
case distro.X86_64ArchName:
|
||||
ps = ps.Append(x8664EdgeCommitPackageSet(t))
|
||||
case distro.Aarch64ArchName:
|
||||
ps = ps.Append(aarch64EdgeCommitPackageSet(t))
|
||||
|
||||
default:
|
||||
panic(fmt.Sprintf("unsupported arch: %s", t.arch.Name()))
|
||||
}
|
||||
|
||||
return ps
|
||||
}
|
||||
282
internal/distro/rhel86/partition_tables.go
Normal file
282
internal/distro/rhel86/partition_tables.go
Normal file
|
|
@ -0,0 +1,282 @@
|
|||
package rhel86
|
||||
|
||||
import (
|
||||
"github.com/osbuild/osbuild-composer/internal/disk"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
)
|
||||
|
||||
var defaultBasePartitionTables = distro.BasePartitionTableMap{
|
||||
distro.X86_64ArchName: disk.PartitionTable{
|
||||
UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
|
||||
Type: "gpt",
|
||||
Partitions: []disk.Partition{
|
||||
{
|
||||
Size: 2048,
|
||||
Bootable: true,
|
||||
Type: disk.BIOSBootPartitionGUID,
|
||||
UUID: disk.BIOSBootPartitionUUID,
|
||||
},
|
||||
{
|
||||
Size: 204800,
|
||||
Type: disk.EFISystemPartitionGUID,
|
||||
UUID: disk.EFISystemPartitionUUID,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "vfat",
|
||||
UUID: disk.EFIFilesystemUUID,
|
||||
Mountpoint: "/boot/efi",
|
||||
FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: disk.FilesystemDataGUID,
|
||||
UUID: disk.RootPartitionUUID,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
Label: "root",
|
||||
Mountpoint: "/",
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
distro.Aarch64ArchName: disk.PartitionTable{
|
||||
UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
|
||||
Type: "gpt",
|
||||
Partitions: []disk.Partition{
|
||||
{
|
||||
Size: 204800,
|
||||
Type: disk.EFISystemPartitionGUID,
|
||||
UUID: disk.EFISystemPartitionUUID,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "vfat",
|
||||
UUID: disk.EFIFilesystemUUID,
|
||||
Mountpoint: "/boot/efi",
|
||||
FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: disk.FilesystemDataGUID,
|
||||
UUID: disk.RootPartitionUUID,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
Label: "root",
|
||||
Mountpoint: "/",
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
distro.Ppc64leArchName: disk.PartitionTable{
|
||||
UUID: "0x14fc63d2",
|
||||
Type: "dos",
|
||||
Partitions: []disk.Partition{
|
||||
{
|
||||
Size: 8192,
|
||||
Type: "41",
|
||||
Bootable: true,
|
||||
},
|
||||
{
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
Mountpoint: "/",
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
distro.S390xArchName: disk.PartitionTable{
|
||||
UUID: "0x14fc63d2",
|
||||
Type: "dos",
|
||||
Partitions: []disk.Partition{
|
||||
{
|
||||
Bootable: true,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
Mountpoint: "/",
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
var ec2BasePartitionTables = distro.BasePartitionTableMap{
|
||||
distro.X86_64ArchName: disk.PartitionTable{
|
||||
UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
|
||||
Type: "gpt",
|
||||
Partitions: []disk.Partition{
|
||||
{
|
||||
Size: 2048,
|
||||
Bootable: true,
|
||||
Type: disk.BIOSBootPartitionGUID,
|
||||
UUID: disk.BIOSBootPartitionUUID,
|
||||
},
|
||||
{
|
||||
Type: disk.FilesystemDataGUID,
|
||||
UUID: disk.RootPartitionUUID,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
Label: "root",
|
||||
Mountpoint: "/",
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
distro.Aarch64ArchName: disk.PartitionTable{
|
||||
UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
|
||||
Type: "gpt",
|
||||
Partitions: []disk.Partition{
|
||||
{
|
||||
Size: 409600,
|
||||
Type: disk.EFISystemPartitionGUID,
|
||||
UUID: disk.EFISystemPartitionUUID,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "vfat",
|
||||
UUID: disk.EFIFilesystemUUID,
|
||||
Mountpoint: "/boot/efi",
|
||||
FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
Size: 1048676,
|
||||
Type: disk.FilesystemDataGUID,
|
||||
UUID: disk.FilesystemDataUUID,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
Mountpoint: "/boot",
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: disk.FilesystemDataGUID,
|
||||
UUID: disk.RootPartitionUUID,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
Label: "root",
|
||||
Mountpoint: "/",
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
var edgeBasePartitionTables = distro.BasePartitionTableMap{
|
||||
distro.X86_64ArchName: disk.PartitionTable{
|
||||
UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
|
||||
Type: "gpt",
|
||||
Partitions: []disk.Partition{
|
||||
{
|
||||
Size: 2048, // 2MB
|
||||
Bootable: true,
|
||||
Type: disk.BIOSBootPartitionGUID,
|
||||
UUID: disk.BIOSBootPartitionUUID,
|
||||
},
|
||||
{
|
||||
Size: 260096, // 127 MB
|
||||
Type: disk.EFISystemPartitionGUID,
|
||||
UUID: disk.EFISystemPartitionUUID,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "vfat",
|
||||
UUID: disk.EFIFilesystemUUID,
|
||||
Mountpoint: "/boot/efi",
|
||||
Label: "EFI-SYSTEM",
|
||||
FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
Size: 786432, // 384 MB
|
||||
Type: disk.FilesystemDataGUID,
|
||||
UUID: disk.FilesystemDataUUID,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
Mountpoint: "/boot",
|
||||
Label: "boot",
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 1,
|
||||
FSTabPassNo: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: disk.FilesystemDataGUID,
|
||||
UUID: disk.RootPartitionUUID,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
Label: "root",
|
||||
Mountpoint: "/",
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
distro.Aarch64ArchName: disk.PartitionTable{
|
||||
UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
|
||||
Type: "gpt",
|
||||
Partitions: []disk.Partition{
|
||||
{
|
||||
Size: 260096, // 127 MB
|
||||
Type: disk.EFISystemPartitionGUID,
|
||||
UUID: disk.EFISystemPartitionUUID,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "vfat",
|
||||
UUID: disk.EFIFilesystemUUID,
|
||||
Mountpoint: "/boot/efi",
|
||||
Label: "EFI-SYSTEM",
|
||||
FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
Size: 786432, // 384 MB
|
||||
Type: disk.FilesystemDataGUID,
|
||||
UUID: disk.FilesystemDataUUID,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
Mountpoint: "/boot",
|
||||
Label: "boot",
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 1,
|
||||
FSTabPassNo: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: disk.FilesystemDataGUID,
|
||||
UUID: disk.RootPartitionUUID,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
Label: "root",
|
||||
Mountpoint: "/",
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
1356
internal/distro/rhel86/pipelines.go
Normal file
1356
internal/distro/rhel86/pipelines.go
Normal file
File diff suppressed because it is too large
Load diff
74
internal/distro/rhel86/stage_inputs.go
Normal file
74
internal/distro/rhel86/stage_inputs.go
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
package rhel86
|
||||
|
||||
import (
|
||||
osbuild "github.com/osbuild/osbuild-composer/internal/osbuild2"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
)
|
||||
|
||||
func bootISOMonoStageInputs() *osbuild.BootISOMonoStageInputs {
|
||||
rootfsInput := new(osbuild.BootISOMonoStageInput)
|
||||
rootfsInput.Type = "org.osbuild.tree"
|
||||
rootfsInput.Origin = "org.osbuild.pipeline"
|
||||
rootfsInput.References = osbuild.BootISOMonoStageReferences{"name:anaconda-tree"}
|
||||
return &osbuild.BootISOMonoStageInputs{
|
||||
RootFS: rootfsInput,
|
||||
}
|
||||
}
|
||||
|
||||
func rpmStageInputs(specs []rpmmd.PackageSpec) *osbuild.RPMStageInputs {
|
||||
stageInput := new(osbuild.RPMStageInput)
|
||||
stageInput.Type = "org.osbuild.files"
|
||||
stageInput.Origin = "org.osbuild.source"
|
||||
stageInput.References = pkgRefs(specs)
|
||||
return &osbuild.RPMStageInputs{Packages: stageInput}
|
||||
}
|
||||
|
||||
func pkgRefs(specs []rpmmd.PackageSpec) osbuild.RPMStageReferences {
|
||||
refs := make([]string, len(specs))
|
||||
for idx, pkg := range specs {
|
||||
refs[idx] = pkg.Checksum
|
||||
}
|
||||
return refs
|
||||
}
|
||||
|
||||
func ostreePullStageInputs(origin, source, commitRef string) *osbuild.OSTreePullStageInputs {
|
||||
pullStageInput := new(osbuild.OSTreePullStageInput)
|
||||
pullStageInput.Type = "org.osbuild.ostree"
|
||||
pullStageInput.Origin = origin
|
||||
|
||||
inputRefs := make(map[string]osbuild.OSTreePullStageReference)
|
||||
inputRefs[source] = osbuild.OSTreePullStageReference{Ref: commitRef}
|
||||
pullStageInput.References = inputRefs
|
||||
return &osbuild.OSTreePullStageInputs{Commits: pullStageInput}
|
||||
}
|
||||
|
||||
func xorrisofsStageInputs(pipeline string) *osbuild.XorrisofsStageInputs {
|
||||
input := new(osbuild.XorrisofsStageInput)
|
||||
input.Type = "org.osbuild.tree"
|
||||
input.Origin = "org.osbuild.pipeline"
|
||||
input.References = osbuild.XorrisofsStageReferences{"name:" + pipeline}
|
||||
return &osbuild.XorrisofsStageInputs{Tree: input}
|
||||
}
|
||||
|
||||
func copyPipelineTreeInputs(name, inputPipeline string) *osbuild.CopyStageInputs {
|
||||
inputName := name
|
||||
treeInput := osbuild.CopyStageInput{}
|
||||
treeInput.Type = "org.osbuild.tree"
|
||||
treeInput.Origin = "org.osbuild.pipeline"
|
||||
treeInput.References = []string{"name:" + inputPipeline}
|
||||
return &osbuild.CopyStageInputs{inputName: treeInput}
|
||||
}
|
||||
|
||||
func qemuStageInputs(stage, file string) *osbuild.QEMUStageInputs {
|
||||
stageKey := "name:" + stage
|
||||
ref := map[string]osbuild.QEMUFile{
|
||||
stageKey: {
|
||||
File: file,
|
||||
},
|
||||
}
|
||||
input := new(osbuild.QEMUStageInput)
|
||||
input.Type = "org.osbuild.files"
|
||||
input.Origin = "org.osbuild.pipeline"
|
||||
input.References = ref
|
||||
return &osbuild.QEMUStageInputs{Image: input}
|
||||
}
|
||||
585
internal/distro/rhel86/stage_options.go
Normal file
585
internal/distro/rhel86/stage_options.go
Normal file
|
|
@ -0,0 +1,585 @@
|
|||
package rhel86
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
"github.com/osbuild/osbuild-composer/internal/common"
|
||||
"github.com/osbuild/osbuild-composer/internal/crypt"
|
||||
"github.com/osbuild/osbuild-composer/internal/disk"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
osbuild "github.com/osbuild/osbuild-composer/internal/osbuild2"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
)
|
||||
|
||||
const (
|
||||
kspath = "/osbuild.ks"
|
||||
)
|
||||
|
||||
func rpmStageOptions(repos []rpmmd.RepoConfig) *osbuild.RPMStageOptions {
|
||||
var gpgKeys []string
|
||||
for _, repo := range repos {
|
||||
if repo.GPGKey == "" {
|
||||
continue
|
||||
}
|
||||
gpgKeys = append(gpgKeys, repo.GPGKey)
|
||||
}
|
||||
|
||||
return &osbuild.RPMStageOptions{
|
||||
GPGKeys: gpgKeys,
|
||||
}
|
||||
}
|
||||
|
||||
// selinuxStageOptions returns the options for the org.osbuild.selinux stage.
|
||||
// Setting the argument to 'true' relabels the '/usr/bin/cp' and '/usr/bin/tar'
|
||||
// binaries with 'install_exec_t'. This should be set in the build root.
|
||||
func selinuxStageOptions(labelcp bool) *osbuild.SELinuxStageOptions {
|
||||
options := &osbuild.SELinuxStageOptions{
|
||||
FileContexts: "etc/selinux/targeted/contexts/files/file_contexts",
|
||||
}
|
||||
if labelcp {
|
||||
options.Labels = map[string]string{
|
||||
"/usr/bin/cp": "system_u:object_r:install_exec_t:s0",
|
||||
"/usr/bin/tar": "system_u:object_r:install_exec_t:s0",
|
||||
}
|
||||
}
|
||||
return options
|
||||
}
|
||||
|
||||
func userStageOptions(users []blueprint.UserCustomization) (*osbuild.UsersStageOptions, error) {
|
||||
options := osbuild.UsersStageOptions{
|
||||
Users: make(map[string]osbuild.UsersStageOptionsUser),
|
||||
}
|
||||
|
||||
for _, c := range users {
|
||||
if c.Password != nil && !crypt.PasswordIsCrypted(*c.Password) {
|
||||
cryptedPassword, err := crypt.CryptSHA512(*c.Password)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
c.Password = &cryptedPassword
|
||||
}
|
||||
|
||||
user := osbuild.UsersStageOptionsUser{
|
||||
Groups: c.Groups,
|
||||
Description: c.Description,
|
||||
Home: c.Home,
|
||||
Shell: c.Shell,
|
||||
Password: c.Password,
|
||||
Key: c.Key,
|
||||
}
|
||||
|
||||
user.UID = c.UID
|
||||
user.GID = c.GID
|
||||
|
||||
options.Users[c.Name] = user
|
||||
}
|
||||
|
||||
return &options, nil
|
||||
}
|
||||
|
||||
func usersFirstBootOptions(usersStageOptions *osbuild.UsersStageOptions) *osbuild.FirstBootStageOptions {
|
||||
cmds := make([]string, 0, 3*len(usersStageOptions.Users)+1)
|
||||
// workaround for creating authorized_keys file for user
|
||||
varhome := filepath.Join("/var", "home")
|
||||
for name, user := range usersStageOptions.Users {
|
||||
if user.Key != nil {
|
||||
sshdir := filepath.Join(varhome, name, ".ssh")
|
||||
cmds = append(cmds, fmt.Sprintf("mkdir -p %s", sshdir))
|
||||
cmds = append(cmds, fmt.Sprintf("sh -c 'echo %q >> %q'", *user.Key, filepath.Join(sshdir, "authorized_keys")))
|
||||
cmds = append(cmds, fmt.Sprintf("chown %s:%s -Rc %s", name, name, sshdir))
|
||||
}
|
||||
}
|
||||
cmds = append(cmds, fmt.Sprintf("restorecon -rvF %s", varhome))
|
||||
options := &osbuild.FirstBootStageOptions{
|
||||
Commands: cmds,
|
||||
WaitForNetwork: false,
|
||||
}
|
||||
|
||||
return options
|
||||
}
|
||||
|
||||
func groupStageOptions(groups []blueprint.GroupCustomization) *osbuild.GroupsStageOptions {
|
||||
options := osbuild.GroupsStageOptions{
|
||||
Groups: map[string]osbuild.GroupsStageOptionsGroup{},
|
||||
}
|
||||
|
||||
for _, group := range groups {
|
||||
groupData := osbuild.GroupsStageOptionsGroup{
|
||||
Name: group.Name,
|
||||
}
|
||||
groupData.GID = group.GID
|
||||
|
||||
options.Groups[group.Name] = groupData
|
||||
}
|
||||
|
||||
return &options
|
||||
}
|
||||
|
||||
func firewallStageOptions(firewall *blueprint.FirewallCustomization) *osbuild.FirewallStageOptions {
|
||||
options := osbuild.FirewallStageOptions{
|
||||
Ports: firewall.Ports,
|
||||
}
|
||||
|
||||
if firewall.Services != nil {
|
||||
options.EnabledServices = firewall.Services.Enabled
|
||||
options.DisabledServices = firewall.Services.Disabled
|
||||
}
|
||||
|
||||
return &options
|
||||
}
|
||||
|
||||
func systemdStageOptions(enabledServices, disabledServices []string, s *blueprint.ServicesCustomization, target string) *osbuild.SystemdStageOptions {
|
||||
if s != nil {
|
||||
enabledServices = append(enabledServices, s.Enabled...)
|
||||
disabledServices = append(disabledServices, s.Disabled...)
|
||||
}
|
||||
return &osbuild.SystemdStageOptions{
|
||||
EnabledServices: enabledServices,
|
||||
DisabledServices: disabledServices,
|
||||
DefaultTarget: target,
|
||||
}
|
||||
}
|
||||
|
||||
func buildStampStageOptions(arch string) *osbuild.BuildstampStageOptions {
|
||||
return &osbuild.BuildstampStageOptions{
|
||||
Arch: arch,
|
||||
Product: "Red Hat Enterprise Linux",
|
||||
Version: osVersion,
|
||||
Variant: "edge",
|
||||
Final: true,
|
||||
}
|
||||
}
|
||||
|
||||
func anacondaStageOptions() *osbuild.AnacondaStageOptions {
|
||||
return &osbuild.AnacondaStageOptions{
|
||||
KickstartModules: []string{
|
||||
"org.fedoraproject.Anaconda.Modules.Network",
|
||||
"org.fedoraproject.Anaconda.Modules.Payloads",
|
||||
"org.fedoraproject.Anaconda.Modules.Storage",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func loraxScriptStageOptions(arch string) *osbuild.LoraxScriptStageOptions {
|
||||
return &osbuild.LoraxScriptStageOptions{
|
||||
Path: "99-generic/runtime-postinstall.tmpl",
|
||||
BaseArch: arch,
|
||||
}
|
||||
}
|
||||
|
||||
func dracutStageOptions(kernelVer, arch string, additionalModules []string) *osbuild.DracutStageOptions {
|
||||
kernel := []string{kernelVer}
|
||||
modules := []string{
|
||||
"bash",
|
||||
"systemd",
|
||||
"fips",
|
||||
"systemd-initrd",
|
||||
"modsign",
|
||||
"nss-softokn",
|
||||
"rdma",
|
||||
"rngd",
|
||||
"i18n",
|
||||
"convertfs",
|
||||
"network-manager",
|
||||
"network",
|
||||
"ifcfg",
|
||||
"url-lib",
|
||||
"drm",
|
||||
"plymouth",
|
||||
"prefixdevname",
|
||||
"prefixdevname-tools",
|
||||
"crypt",
|
||||
"dm",
|
||||
"dmsquash-live",
|
||||
"kernel-modules",
|
||||
"kernel-modules-extra",
|
||||
"kernel-network-modules",
|
||||
"livenet",
|
||||
"lvm",
|
||||
"mdraid",
|
||||
"multipath",
|
||||
"qemu",
|
||||
"qemu-net",
|
||||
"fcoe",
|
||||
"fcoe-uefi",
|
||||
"iscsi",
|
||||
"lunmask",
|
||||
"nfs",
|
||||
"resume",
|
||||
"rootfs-block",
|
||||
"terminfo",
|
||||
"udev-rules",
|
||||
"dracut-systemd",
|
||||
"pollcdrom",
|
||||
"usrmount",
|
||||
"base",
|
||||
"fs-lib",
|
||||
"img-lib",
|
||||
"shutdown",
|
||||
"uefi-lib",
|
||||
}
|
||||
|
||||
if arch == distro.X86_64ArchName {
|
||||
modules = append(modules, "biosdevname")
|
||||
}
|
||||
|
||||
modules = append(modules, additionalModules...)
|
||||
return &osbuild.DracutStageOptions{
|
||||
Kernel: kernel,
|
||||
Modules: modules,
|
||||
Install: []string{"/.buildstamp"},
|
||||
}
|
||||
}
|
||||
|
||||
func tarKickstartStageOptions(tarURL string) *osbuild.KickstartStageOptions {
|
||||
return &osbuild.KickstartStageOptions{
|
||||
Path: kspath,
|
||||
LiveIMG: &osbuild.LiveIMG{
|
||||
URL: tarURL,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func ostreeKickstartStageOptions(ostreeURL, ostreeRef string) *osbuild.KickstartStageOptions {
|
||||
return &osbuild.KickstartStageOptions{
|
||||
Path: kspath,
|
||||
OSTree: &osbuild.OSTreeOptions{
|
||||
OSName: "rhel",
|
||||
URL: ostreeURL,
|
||||
Ref: ostreeRef,
|
||||
GPG: false,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func bootISOMonoStageOptions(kernelVer string, arch string) *osbuild.BootISOMonoStageOptions {
|
||||
comprOptions := new(osbuild.FSCompressionOptions)
|
||||
if bcj := osbuild.BCJOption(arch); bcj != "" {
|
||||
comprOptions.BCJ = bcj
|
||||
}
|
||||
isolabel := fmt.Sprintf("RHEL-8-6-0-BaseOS-%s", arch)
|
||||
|
||||
var architectures []string
|
||||
|
||||
if arch == distro.X86_64ArchName {
|
||||
architectures = []string{"IA32", "X64"}
|
||||
} else if arch == distro.Aarch64ArchName {
|
||||
architectures = []string{"AA64"}
|
||||
} else {
|
||||
panic("unsupported architecture")
|
||||
}
|
||||
|
||||
return &osbuild.BootISOMonoStageOptions{
|
||||
Product: osbuild.Product{
|
||||
Name: "Red Hat Enterprise Linux",
|
||||
Version: osVersion,
|
||||
},
|
||||
ISOLabel: isolabel,
|
||||
Kernel: kernelVer,
|
||||
KernelOpts: fmt.Sprintf("inst.ks=hd:LABEL=%s:%s", isolabel, kspath),
|
||||
EFI: osbuild.EFI{
|
||||
Architectures: architectures,
|
||||
Vendor: "redhat",
|
||||
},
|
||||
ISOLinux: osbuild.ISOLinux{
|
||||
Enabled: arch == distro.X86_64ArchName,
|
||||
Debug: false,
|
||||
},
|
||||
Templates: "80-rhel",
|
||||
RootFS: osbuild.RootFS{
|
||||
Size: 9216,
|
||||
Compression: osbuild.FSCompression{
|
||||
Method: "xz",
|
||||
Options: comprOptions,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func discinfoStageOptions(arch string) *osbuild.DiscinfoStageOptions {
|
||||
return &osbuild.DiscinfoStageOptions{
|
||||
BaseArch: arch,
|
||||
Release: "202010217.n.0",
|
||||
}
|
||||
}
|
||||
|
||||
func xorrisofsStageOptions(filename string, arch string, isolinux bool) *osbuild.XorrisofsStageOptions {
|
||||
options := &osbuild.XorrisofsStageOptions{
|
||||
Filename: filename,
|
||||
VolID: fmt.Sprintf("RHEL-8-6-0-BaseOS-%s", arch),
|
||||
SysID: "LINUX",
|
||||
EFI: "images/efiboot.img",
|
||||
}
|
||||
|
||||
if isolinux {
|
||||
options.Boot = &osbuild.XorrisofsBoot{
|
||||
Image: "isolinux/isolinux.bin",
|
||||
Catalog: "isolinux/boot.cat",
|
||||
}
|
||||
|
||||
options.IsohybridMBR = "/usr/share/syslinux/isohdpfx.bin"
|
||||
}
|
||||
|
||||
return options
|
||||
}
|
||||
|
||||
func grub2StageOptions(rootPartition *disk.Partition, bootPartition *disk.Partition, kernelOptions string,
|
||||
kernel *blueprint.KernelCustomization, kernelVer string, uefi bool, legacy string, install bool) *osbuild.GRUB2StageOptions {
|
||||
if rootPartition == nil {
|
||||
panic("root partition must be defined for grub2 stage, this is a programming error")
|
||||
}
|
||||
|
||||
stageOptions := osbuild.GRUB2StageOptions{
|
||||
RootFilesystemUUID: uuid.MustParse(rootPartition.Filesystem.UUID),
|
||||
KernelOptions: kernelOptions,
|
||||
Legacy: legacy,
|
||||
}
|
||||
|
||||
if bootPartition != nil {
|
||||
bootFsUUID := uuid.MustParse(bootPartition.Filesystem.UUID)
|
||||
stageOptions.BootFilesystemUUID = &bootFsUUID
|
||||
}
|
||||
|
||||
if uefi {
|
||||
stageOptions.UEFI = &osbuild.GRUB2UEFI{
|
||||
Vendor: "redhat",
|
||||
Install: install,
|
||||
}
|
||||
}
|
||||
|
||||
if !uefi {
|
||||
stageOptions.Legacy = legacy
|
||||
}
|
||||
|
||||
if kernel != nil {
|
||||
if kernel.Append != "" {
|
||||
stageOptions.KernelOptions += " " + kernel.Append
|
||||
}
|
||||
stageOptions.SavedEntry = "ffffffffffffffffffffffffffffffff-" + kernelVer
|
||||
}
|
||||
|
||||
return &stageOptions
|
||||
}
|
||||
|
||||
// sfdiskStageOptions creates the options and devices properties for an
|
||||
// org.osbuild.sfdisk stage based on a partition table description
|
||||
func sfdiskStageOptions(pt *disk.PartitionTable) *osbuild.SfdiskStageOptions {
|
||||
partitions := make([]osbuild.Partition, len(pt.Partitions))
|
||||
for idx, p := range pt.Partitions {
|
||||
partitions[idx] = osbuild.Partition{
|
||||
Bootable: p.Bootable,
|
||||
Size: p.Size,
|
||||
Start: p.Start,
|
||||
Type: p.Type,
|
||||
UUID: p.UUID,
|
||||
}
|
||||
}
|
||||
stageOptions := &osbuild.SfdiskStageOptions{
|
||||
Label: pt.Type,
|
||||
UUID: pt.UUID,
|
||||
Partitions: partitions,
|
||||
}
|
||||
|
||||
return stageOptions
|
||||
}
|
||||
|
||||
// copyFSTreeOptions creates the options, inputs, devices, and mounts properties
|
||||
// for an org.osbuild.copy stage for a given source tree using a partition
|
||||
// table description to define the mounts
|
||||
func copyFSTreeOptions(inputName, inputPipeline string, pt *disk.PartitionTable, device *osbuild.Device) (
|
||||
*osbuild.CopyStageOptions,
|
||||
*osbuild.Devices,
|
||||
*osbuild.Mounts,
|
||||
) {
|
||||
// assume loopback device for simplicity since it's the only one currently supported
|
||||
// panic if the conversion fails
|
||||
devOptions, ok := device.Options.(*osbuild.LoopbackDeviceOptions)
|
||||
if !ok {
|
||||
panic("copyStageOptions: failed to convert device options to loopback options")
|
||||
}
|
||||
|
||||
devices := make(map[string]osbuild.Device, len(pt.Partitions))
|
||||
mounts := make([]osbuild.Mount, 0, len(pt.Partitions))
|
||||
for _, p := range pt.Partitions {
|
||||
if p.Filesystem == nil {
|
||||
// no filesystem for partition (e.g., BIOS boot)
|
||||
continue
|
||||
}
|
||||
name := filepath.Base(p.Filesystem.Mountpoint)
|
||||
if name == "/" {
|
||||
name = "root"
|
||||
}
|
||||
devices[name] = *osbuild.NewLoopbackDevice(
|
||||
&osbuild.LoopbackDeviceOptions{
|
||||
Filename: devOptions.Filename,
|
||||
Start: p.Start,
|
||||
Size: p.Size,
|
||||
},
|
||||
)
|
||||
var mount *osbuild.Mount
|
||||
switch p.Filesystem.Type {
|
||||
case "xfs":
|
||||
mount = osbuild.NewXfsMount(name, name, p.Filesystem.Mountpoint)
|
||||
case "vfat":
|
||||
mount = osbuild.NewFATMount(name, name, p.Filesystem.Mountpoint)
|
||||
case "ext4":
|
||||
mount = osbuild.NewExt4Mount(name, name, p.Filesystem.Mountpoint)
|
||||
case "btrfs":
|
||||
mount = osbuild.NewBtrfsMount(name, name, p.Filesystem.Mountpoint)
|
||||
default:
|
||||
panic("unknown fs type " + p.Type)
|
||||
}
|
||||
mounts = append(mounts, *mount)
|
||||
}
|
||||
|
||||
// sort the mounts, using < should just work because:
|
||||
// - a parent directory should be always before its children:
|
||||
// / < /boot
|
||||
// - the order of siblings doesn't matter
|
||||
sort.Slice(mounts, func(i, j int) bool {
|
||||
return mounts[i].Target < mounts[j].Target
|
||||
})
|
||||
|
||||
stageMounts := osbuild.Mounts(mounts)
|
||||
stageDevices := osbuild.Devices(devices)
|
||||
|
||||
options := osbuild.CopyStageOptions{
|
||||
Paths: []osbuild.CopyStagePath{
|
||||
{
|
||||
From: fmt.Sprintf("input://%s/", inputName),
|
||||
To: "mount://root/",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return &options, &stageDevices, &stageMounts
|
||||
}
|
||||
|
||||
func grub2InstStageOptions(filename string, pt *disk.PartitionTable, platform string) *osbuild.Grub2InstStageOptions {
|
||||
bootPartIndex := pt.BootPartitionIndex()
|
||||
if bootPartIndex == -1 {
|
||||
panic("failed to find boot or root partition for grub2.inst stage")
|
||||
}
|
||||
bootPart := pt.Partitions[bootPartIndex]
|
||||
prefixPath := "/boot/grub2"
|
||||
if bootPart.Filesystem.Mountpoint == "/boot" {
|
||||
prefixPath = "/grub2"
|
||||
}
|
||||
core := osbuild.CoreMkImage{
|
||||
Type: "mkimage",
|
||||
PartLabel: pt.Type,
|
||||
Filesystem: pt.Partitions[bootPartIndex].Filesystem.Type,
|
||||
}
|
||||
|
||||
prefix := osbuild.PrefixPartition{
|
||||
Type: "partition",
|
||||
PartLabel: pt.Type,
|
||||
Number: uint(bootPartIndex),
|
||||
Path: prefixPath,
|
||||
}
|
||||
|
||||
return &osbuild.Grub2InstStageOptions{
|
||||
Filename: filename,
|
||||
Platform: platform,
|
||||
Location: pt.Partitions[0].Start,
|
||||
Core: core,
|
||||
Prefix: prefix,
|
||||
}
|
||||
}
|
||||
|
||||
func ziplInstStageOptions(kernel string, pt *disk.PartitionTable) *osbuild.ZiplInstStageOptions {
|
||||
bootPartIndex := pt.BootPartitionIndex()
|
||||
if bootPartIndex == -1 {
|
||||
panic("failed to find boot or root partition for zipl.inst stage")
|
||||
}
|
||||
|
||||
return &osbuild.ZiplInstStageOptions{
|
||||
Kernel: kernel,
|
||||
Location: pt.Partitions[bootPartIndex].Start,
|
||||
}
|
||||
}
|
||||
|
||||
func qemuStageOptions(filename, format, compat string) *osbuild.QEMUStageOptions {
|
||||
var options osbuild.QEMUFormatOptions
|
||||
switch format {
|
||||
case "qcow2":
|
||||
options = osbuild.Qcow2Options{
|
||||
Type: "qcow2",
|
||||
Compat: compat,
|
||||
}
|
||||
case "vpc":
|
||||
options = osbuild.VPCOptions{
|
||||
Type: "vpc",
|
||||
}
|
||||
case "vmdk":
|
||||
options = osbuild.VMDKOptions{
|
||||
Type: "vmdk",
|
||||
}
|
||||
default:
|
||||
panic("unknown format in qemu stage: " + format)
|
||||
}
|
||||
|
||||
return &osbuild.QEMUStageOptions{
|
||||
Filename: filename,
|
||||
Format: options,
|
||||
}
|
||||
}
|
||||
|
||||
func kernelCmdlineStageOptions(rootUUID string, kernelOptions string) *osbuild.KernelCmdlineStageOptions {
|
||||
return &osbuild.KernelCmdlineStageOptions{
|
||||
RootFsUUID: rootUUID,
|
||||
KernelOpts: kernelOptions,
|
||||
}
|
||||
}
|
||||
|
||||
func nginxConfigStageOptions(path, htmlRoot, listen string) *osbuild.NginxConfigStageOptions {
|
||||
// configure nginx to work in an unprivileged container
|
||||
cfg := &osbuild.NginxConfig{
|
||||
Listen: listen,
|
||||
Root: htmlRoot,
|
||||
Daemon: common.BoolToPtr(false),
|
||||
PID: "/tmp/nginx.pid",
|
||||
}
|
||||
return &osbuild.NginxConfigStageOptions{
|
||||
Path: path,
|
||||
Config: cfg,
|
||||
}
|
||||
}
|
||||
|
||||
func chmodStageOptions(path, mode string, recursive bool) *osbuild.ChmodStageOptions {
|
||||
return &osbuild.ChmodStageOptions{
|
||||
Items: map[string]osbuild.ChmodStagePathOptions{
|
||||
path: {Mode: mode, Recursive: recursive},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func ostreeConfigStageOptions(repo string, readOnly bool) *osbuild.OSTreeConfigStageOptions {
|
||||
return &osbuild.OSTreeConfigStageOptions{
|
||||
Repo: repo,
|
||||
Config: &osbuild.OSTreeConfig{
|
||||
Sysroot: &osbuild.SysrootOptions{
|
||||
ReadOnly: common.BoolToPtr(readOnly),
|
||||
Bootloader: "none",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func efiMkdirStageOptions() *osbuild.MkdirStageOptions {
|
||||
return &osbuild.MkdirStageOptions{
|
||||
Paths: []osbuild.Path{
|
||||
{
|
||||
Path: "/boot/efi",
|
||||
Mode: os.FileMode(0700),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue