distro/rhel90: copy everything from rhel85
rm internal/distro/rhel90/* cp internal/distro/rhel85/* internal/distro/rhel90/ Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
parent
8af0431883
commit
d6ade6386d
8 changed files with 3323 additions and 1116 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,7 @@
|
|||
package rhel90_test
|
||||
package rhel85_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
|
@ -9,50 +10,186 @@ import (
|
|||
"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/rhel90"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/rhel85"
|
||||
)
|
||||
|
||||
type rhelFamilyDistro struct {
|
||||
name string
|
||||
distro distro.Distro
|
||||
}
|
||||
|
||||
var rhelFamilyDistros = []rhelFamilyDistro{
|
||||
{
|
||||
name: "rhel",
|
||||
distro: rhel85.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 string
|
||||
want1 string
|
||||
wantErr bool
|
||||
name string
|
||||
args args
|
||||
want wantResult
|
||||
}{
|
||||
{
|
||||
name: "qcow2",
|
||||
args: args{"qcow2"},
|
||||
want: "disk.qcow2",
|
||||
want1: "application/x-qemu-disk",
|
||||
name: "ami",
|
||||
args: args{"ami"},
|
||||
want: wantResult{
|
||||
filename: "image.raw",
|
||||
mimeType: "application/octet-stream",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "invalid-output-type",
|
||||
args: args{"foobar"},
|
||||
wantErr: true,
|
||||
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: "tar-installer",
|
||||
args: args{"tar-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 _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
dist := rhel90.New()
|
||||
arch, _ := dist.GetArch("x86_64")
|
||||
imgType, err := arch.GetImageType(tt.args.outputFormat)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("Arch.GetImageType() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !tt.wantErr {
|
||||
got := imgType.Filename()
|
||||
got1 := imgType.MIMEType()
|
||||
if got != tt.want {
|
||||
t.Errorf("ImageType.Filename() got = %v, want %v", got, tt.want)
|
||||
}
|
||||
if got1 != tt.want1 {
|
||||
t.Errorf("ImageType.MIMEType() got1 = %v, want %v", got1, tt.want1)
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -85,29 +222,30 @@ func TestImageType_BuildPackages(t *testing.T) {
|
|||
buildPackages := map[string][]string{
|
||||
"x86_64": x8664BuildPackages,
|
||||
"aarch64": aarch64BuildPackages,
|
||||
"ppc64le": nil,
|
||||
"s390x": nil,
|
||||
}
|
||||
d := rhel90.New()
|
||||
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
|
||||
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)
|
||||
}
|
||||
}
|
||||
buildPkgs := itStruct.PackageSets(blueprint.Blueprint{})["build-packages"]
|
||||
assert.NotNil(t, buildPkgs)
|
||||
assert.ElementsMatch(t, buildPackages[archLabel], buildPkgs.Include)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestImageType_Name(t *testing.T) {
|
||||
distro := rhel90.New()
|
||||
imgMap := []struct {
|
||||
arch string
|
||||
imgNames []string
|
||||
|
|
@ -116,144 +254,142 @@ func TestImageType_Name(t *testing.T) {
|
|||
arch: "x86_64",
|
||||
imgNames: []string{
|
||||
"qcow2",
|
||||
"openstack",
|
||||
"vhd",
|
||||
"vmdk",
|
||||
"ami",
|
||||
"ec2",
|
||||
"ec2-ha",
|
||||
"edge-commit",
|
||||
"edge-container",
|
||||
"edge-installer",
|
||||
"tar",
|
||||
"tar-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 _, mapping := range imgMap {
|
||||
arch, err := distro.GetArch(mapping.arch)
|
||||
if assert.NoError(t, err) {
|
||||
for _, imgName := range mapping.imgNames {
|
||||
imgType, err := arch.GetImageType(imgName)
|
||||
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) {
|
||||
assert.Equalf(t, imgName, imgType.Name(), "arch: %s", mapping.arch)
|
||||
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 TestImageType_BasePackages(t *testing.T) {
|
||||
pkgMaps := []struct {
|
||||
name string
|
||||
basePackages []string
|
||||
bootloaderPackages []string
|
||||
excludedPackages []string
|
||||
bootable bool
|
||||
func TestImageTypeAliases(t *testing.T) {
|
||||
type args struct {
|
||||
imageTypeAliases []string
|
||||
}
|
||||
type wantResult struct {
|
||||
imageTypeName string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want wantResult
|
||||
}{
|
||||
{
|
||||
name: "qcow2",
|
||||
basePackages: []string{
|
||||
"@Core",
|
||||
"authselect-compat",
|
||||
"chrony",
|
||||
"cloud-init",
|
||||
"cloud-utils-growpart",
|
||||
"cockpit-system",
|
||||
"cockpit-ws",
|
||||
"dnf",
|
||||
"dnf-utils",
|
||||
"dosfstools",
|
||||
"dracut-config-generic",
|
||||
"hostname",
|
||||
"NetworkManager",
|
||||
"nfs-utils",
|
||||
"oddjob",
|
||||
"oddjob-mkhomedir",
|
||||
"psmisc",
|
||||
"python3-jsonschema",
|
||||
"qemu-guest-agent",
|
||||
"redhat-release",
|
||||
"redhat-release-eula",
|
||||
"rsync",
|
||||
"subscription-manager-cockpit",
|
||||
"tar",
|
||||
"tcpdump",
|
||||
"yum",
|
||||
"kernel",
|
||||
name: "edge-commit aliases",
|
||||
args: args{
|
||||
imageTypeAliases: []string{"rhel-edge-commit"},
|
||||
},
|
||||
bootloaderPackages: []string{
|
||||
"dracut-config-generic",
|
||||
"grub2-pc",
|
||||
"grub2-efi-x64",
|
||||
"shim-x64",
|
||||
want: wantResult{
|
||||
imageTypeName: "edge-commit",
|
||||
},
|
||||
excludedPackages: []string{
|
||||
"aic94xx-firmware",
|
||||
"alsa-firmware",
|
||||
"alsa-lib",
|
||||
"alsa-tools-firmware",
|
||||
"biosdevname",
|
||||
"dnf-plugin-spacewalk",
|
||||
"dracut-config-rescue",
|
||||
"fedora-release",
|
||||
"fedora-repos",
|
||||
"firewalld",
|
||||
"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-en",
|
||||
"libertas-sd8686-firmware",
|
||||
"libertas-sd8787-firmware",
|
||||
"libertas-usb8388-firmware",
|
||||
"nss",
|
||||
"plymouth",
|
||||
"rng-tools",
|
||||
"udisks2",
|
||||
},
|
||||
{
|
||||
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",
|
||||
},
|
||||
bootable: true,
|
||||
},
|
||||
}
|
||||
distro := rhel90.New()
|
||||
arch, err := distro.GetArch("x86_64")
|
||||
assert.NoError(t, err)
|
||||
|
||||
for _, pkgMap := range pkgMaps {
|
||||
imgType, err := arch.GetImageType(pkgMap.name)
|
||||
assert.NoError(t, err)
|
||||
packages := imgType.PackageSets(blueprint.Blueprint{})["packages"]
|
||||
assert.NotNil(t, packages)
|
||||
assert.Equalf(
|
||||
t,
|
||||
append(pkgMap.basePackages, pkgMap.bootloaderPackages...),
|
||||
packages.Include,
|
||||
"image type: %s",
|
||||
pkgMap.name,
|
||||
)
|
||||
assert.Equalf(t, pkgMap.excludedPackages, packages.Exclude, "image type: %s", pkgMap.name)
|
||||
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())
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -262,7 +398,7 @@ func TestImageType_BasePackages(t *testing.T) {
|
|||
func TestDistro_ManifestError(t *testing.T) {
|
||||
// Currently, the only unsupported configuration is OSTree commit types
|
||||
// with Kernel boot options
|
||||
r9distro := rhel90.New()
|
||||
r8distro := rhel85.New()
|
||||
bp := blueprint.Blueprint{
|
||||
Customizations: &blueprint.Customizations{
|
||||
Kernel: &blueprint.KernelCustomization{
|
||||
|
|
@ -270,70 +406,106 @@ func TestDistro_ManifestError(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
for _, archName := range r9distro.ListArches() {
|
||||
arch, _ := r9distro.GetArch(archName)
|
||||
|
||||
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)
|
||||
assert.NoError(t, err)
|
||||
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-installer" {
|
||||
assert.EqualError(t, err, "boot ISO image type \"edge-installer\" requires specifying a URL from which to retrieve the OSTree commit")
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestArchitecture_ListImageTypes(t *testing.T) {
|
||||
distro := rhel90.New()
|
||||
imgMap := []struct {
|
||||
arch string
|
||||
imgNames []string
|
||||
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",
|
||||
"tar",
|
||||
"tar-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 _, mapping := range imgMap {
|
||||
arch, err := distro.GetArch(mapping.arch)
|
||||
require.NoError(t, err)
|
||||
imageTypes := arch.ListImageTypes()
|
||||
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...)
|
||||
var expectedImageTypes []string
|
||||
expectedImageTypes = append(expectedImageTypes, mapping.imgNames...)
|
||||
if dist.name == "rhel" {
|
||||
expectedImageTypes = append(expectedImageTypes, mapping.rhelAdditionalImageTypes...)
|
||||
}
|
||||
|
||||
require.ElementsMatch(t, expectedImageTypes, imageTypes)
|
||||
require.ElementsMatch(t, expectedImageTypes, imageTypes)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestRhel90_ListArches(t *testing.T) {
|
||||
arches := rhel90.New().ListArches()
|
||||
func TestRhel85_ListArches(t *testing.T) {
|
||||
arches := rhel85.New().ListArches()
|
||||
assert.Equal(t, []string{"aarch64", "ppc64le", "s390x", "x86_64"}, arches)
|
||||
}
|
||||
|
||||
func TestRhel90_GetArch(t *testing.T) {
|
||||
distro := rhel90.New()
|
||||
func TestRhel85_GetArch(t *testing.T) {
|
||||
arches := []struct {
|
||||
name string
|
||||
errorExpected bool
|
||||
name string
|
||||
errorExpected bool
|
||||
errorExpectedInCentos bool
|
||||
}{
|
||||
{
|
||||
name: "x86_64",
|
||||
|
|
@ -353,34 +525,38 @@ func TestRhel90_GetArch(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
for _, a := range arches {
|
||||
actualArch, err := distro.GetArch(a.name)
|
||||
if a.errorExpected {
|
||||
assert.Nil(t, actualArch)
|
||||
assert.Error(t, err)
|
||||
} else {
|
||||
assert.Equal(t, a.name, actualArch.Name())
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
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 TestRhel90_Name(t *testing.T) {
|
||||
distro := rhel90.New()
|
||||
assert.Equal(t, "rhel-90", distro.Name())
|
||||
func TestRhel85_Name(t *testing.T) {
|
||||
distro := rhel85.New()
|
||||
assert.Equal(t, "rhel-85", distro.Name())
|
||||
}
|
||||
|
||||
func TestRhel84_ModulePlatformID(t *testing.T) {
|
||||
distro := rhel90.New()
|
||||
assert.Equal(t, "platform:el9", distro.ModulePlatformID())
|
||||
func TestRhel85_ModulePlatformID(t *testing.T) {
|
||||
distro := rhel85.New()
|
||||
assert.Equal(t, "platform:el8", distro.ModulePlatformID())
|
||||
}
|
||||
|
||||
func TestRhel90_KernelOption(t *testing.T) {
|
||||
distro_test_common.TestDistro_KernelOption(t, rhel90.New())
|
||||
func TestRhel85_KernelOption(t *testing.T) {
|
||||
distro_test_common.TestDistro_KernelOption(t, rhel85.New())
|
||||
}
|
||||
|
||||
func TestDistro_CustomFileSystemManifestError(t *testing.T) {
|
||||
r9distro := rhel90.New()
|
||||
r8distro := rhel85.New()
|
||||
bp := blueprint.Blueprint{
|
||||
Customizations: &blueprint.Customizations{
|
||||
Filesystem: []blueprint.FilesystemCustomization{
|
||||
|
|
@ -391,18 +567,24 @@ func TestDistro_CustomFileSystemManifestError(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
for _, archName := range r9distro.ListArches() {
|
||||
arch, _ := r9distro.GetArch(archName)
|
||||
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)
|
||||
assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/boot\"]")
|
||||
if imgTypeName == "edge-commit" || imgTypeName == "edge-container" {
|
||||
assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types")
|
||||
} else if imgTypeName == "edge-installer" {
|
||||
continue
|
||||
} else {
|
||||
assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/boot\"]")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDistro_TestRootMountPoint(t *testing.T) {
|
||||
r9distro := rhel90.New()
|
||||
r8distro := rhel85.New()
|
||||
bp := blueprint.Blueprint{
|
||||
Customizations: &blueprint.Customizations{
|
||||
Filesystem: []blueprint.FilesystemCustomization{
|
||||
|
|
@ -413,12 +595,18 @@ func TestDistro_TestRootMountPoint(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
for _, archName := range r9distro.ListArches() {
|
||||
arch, _ := r9distro.GetArch(archName)
|
||||
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)
|
||||
assert.NoError(t, err)
|
||||
if imgTypeName == "edge-commit" || imgTypeName == "edge-container" {
|
||||
assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types")
|
||||
} else if imgTypeName == "edge-installer" {
|
||||
continue
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
386
internal/distro/rhel90/package_sets.go
Normal file
386
internal/distro/rhel90/package_sets.go
Normal file
|
|
@ -0,0 +1,386 @@
|
|||
package rhel85
|
||||
|
||||
// This file defines package sets that are used by more than one image type.
|
||||
|
||||
import "github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
|
||||
// BUILD PACKAGE SETS
|
||||
|
||||
// distro-wide build package set
|
||||
func distroBuildPackageSet() rpmmd.PackageSet {
|
||||
return 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",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// x86_64 build package set
|
||||
func x8664BuildPackageSet() rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{"grub2-pc"},
|
||||
}
|
||||
}
|
||||
|
||||
// ppc64le build package set
|
||||
func ppc64leBuildPackageSet() rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{"grub2-ppc64le", "grub2-ppc64le-modules"},
|
||||
}
|
||||
}
|
||||
|
||||
// common ec2 image build package set
|
||||
func ec2BuildPackageSet() rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{"python3-pyyaml"},
|
||||
}
|
||||
}
|
||||
|
||||
// common edge image build package set
|
||||
func edgeBuildPackageSet() rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{"rpm-ostree"},
|
||||
Exclude: nil,
|
||||
}
|
||||
}
|
||||
|
||||
// x86_64 installer ISO build package set
|
||||
// TODO: separate into common installer and arch specific sets
|
||||
func x8664InstallerBuildPackageSet() rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"efibootmgr", "genisoimage", "grub2-efi-ia32-cdboot",
|
||||
"grub2-efi-x64", "grub2-efi-x64-cdboot", "grub2-pc",
|
||||
"grub2-pc-modules", "grub2-tools", "grub2-tools-efi",
|
||||
"grub2-tools-extra", "grub2-tools-minimal", "isomd5sum",
|
||||
"rpm-ostree", "shim-ia32", "shim-x64", "squashfs-tools",
|
||||
"syslinux", "syslinux-nonlinux", "xorriso",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// BOOT PACKAGE SETS
|
||||
|
||||
// x86_64 Legacy arch-specific boot package set
|
||||
func x8664LegacyBootPackageSet() rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{"dracut-config-generic", "grub2-pc"},
|
||||
}
|
||||
}
|
||||
|
||||
// x86_64 UEFI arch-specific boot package set
|
||||
func x8664UEFIBootPackageSet() rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{"dracut-config-generic", "grub2-efi-x64", "shim-x64"},
|
||||
}
|
||||
}
|
||||
|
||||
// aarch64 UEFI arch-specific boot package set
|
||||
func aarch64UEFIBootPackageSet() 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() 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() rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{"dracut-config-generic", "s390utils-base"},
|
||||
}
|
||||
}
|
||||
|
||||
// OS package sets
|
||||
|
||||
func qcow2CommonPackageSet() 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",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func vhdCommonPackageSet() 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",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func vmdkCommonPackageSet() 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",
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func openstackCommonPackageSet() 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",
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func ec2CommonPackageSet() 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",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// rhel-ec2 image package set
|
||||
func rhelEc2PackageSet() rpmmd.PackageSet {
|
||||
ec2PackageSet := ec2CommonPackageSet()
|
||||
ec2PackageSet.Include = append(ec2PackageSet.Include, "rh-amazon-rhui-client")
|
||||
return ec2PackageSet
|
||||
}
|
||||
|
||||
// rhel-ha-ec2 image package set
|
||||
func rhelEc2HaPackageSet() rpmmd.PackageSet {
|
||||
ec2HaPackageSet := ec2CommonPackageSet()
|
||||
ec2HaPackageSet.Include = append(ec2HaPackageSet.Include,
|
||||
"fence-agents-all",
|
||||
"pacemaker",
|
||||
"pcs",
|
||||
"rh-amazon-rhui-client-ha",
|
||||
)
|
||||
return ec2HaPackageSet
|
||||
}
|
||||
|
||||
// edge commit OS package set
|
||||
func edgeCommitPackageSet() rpmmd.PackageSet {
|
||||
return 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"},
|
||||
}
|
||||
}
|
||||
|
||||
func x8664EdgeCommitPackageSet() 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() rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{"grub2-efi-aa64", "efibootmgr", "shim-aa64", "iwl7260-firmware"},
|
||||
Exclude: nil,
|
||||
}
|
||||
}
|
||||
|
||||
// INSTALLER PACKAGE SET
|
||||
func installerPackageSet() rpmmd.PackageSet {
|
||||
// TODO: simplify
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"aajohan-comfortaa-fonts", "abattis-cantarell-fonts",
|
||||
"alsa-firmware", "alsa-tools-firmware", "anaconda",
|
||||
"anaconda-dracut", "anaconda-install-env-deps", "anaconda-widgets",
|
||||
"audit", "bind-utils", "biosdevname", "bitmap-fangsongti-fonts",
|
||||
"bzip2", "cryptsetup", "curl", "dbus-x11", "dejavu-sans-fonts",
|
||||
"dejavu-sans-mono-fonts", "device-mapper-persistent-data",
|
||||
"dmidecode", "dnf", "dracut-config-generic", "dracut-network",
|
||||
"dump", "efibootmgr", "ethtool", "ftp", "gdb-gdbserver", "gdisk",
|
||||
"gfs2-utils", "glibc-all-langpacks",
|
||||
"google-noto-sans-cjk-ttc-fonts", "grub2-efi-ia32-cdboot",
|
||||
"grub2-efi-x64-cdboot", "grub2-tools", "grub2-tools-efi",
|
||||
"grub2-tools-extra", "grub2-tools-minimal", "grubby",
|
||||
"gsettings-desktop-schemas", "hdparm", "hexedit", "hostname",
|
||||
"initscripts", "ipmitool", "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", "jomolhari-fonts",
|
||||
"kacst-farsi-fonts", "kacst-qurn-fonts", "kbd", "kbd-misc",
|
||||
"kdump-anaconda-addon", "kernel", "khmeros-base-fonts", "less",
|
||||
"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",
|
||||
"memtest86+", "metacity", "mtr", "mt-st", "net-tools", "nfs-utils",
|
||||
"nmap-ncat", "nm-connection-editor", "nss-tools",
|
||||
"openssh-clients", "openssh-server", "oscap-anaconda-addon",
|
||||
"ostree", "pciutils", "perl-interpreter", "pigz", "plymouth",
|
||||
"prefixdevname", "python3-pyatspi", "rdma-core",
|
||||
"redhat-release-eula", "rng-tools", "rpcbind", "rpm-ostree",
|
||||
"rsync", "rsyslog", "selinux-policy-targeted", "sg3_utils",
|
||||
"shim-ia32", "shim-x64", "sil-abyssinica-fonts",
|
||||
"sil-padauk-fonts", "sil-scheherazade-fonts", "smartmontools",
|
||||
"smc-meera-fonts", "spice-vdagent", "strace", "syslinux",
|
||||
"systemd", "system-storage-manager", "tar",
|
||||
"thai-scalable-waree-fonts", "tigervnc-server-minimal",
|
||||
"tigervnc-server-module", "udisks2", "udisks2-iscsi", "usbutils",
|
||||
"vim-minimal", "volume_key", "wget", "xfsdump", "xfsprogs",
|
||||
"xorg-x11-drivers", "xorg-x11-fonts-misc", "xorg-x11-server-utils",
|
||||
"xorg-x11-server-Xorg", "xorg-x11-xauth", "xz",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func edgeInstallerPackageSet() rpmmd.PackageSet {
|
||||
return rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"aajohan-comfortaa-fonts", "abattis-cantarell-fonts",
|
||||
"alsa-firmware", "alsa-tools-firmware", "anaconda",
|
||||
"anaconda-dracut", "anaconda-install-env-deps", "anaconda-widgets",
|
||||
"audit", "bind-utils", "biosdevname", "bitmap-fangsongti-fonts",
|
||||
"bzip2", "cryptsetup", "curl", "dbus-x11", "dejavu-sans-fonts",
|
||||
"dejavu-sans-mono-fonts", "device-mapper-persistent-data",
|
||||
"dmidecode", "dnf", "dracut-config-generic", "dracut-network",
|
||||
"dump", "efibootmgr", "ethtool", "ftp", "gdb-gdbserver", "gdisk",
|
||||
"gfs2-utils", "glibc-all-langpacks",
|
||||
"google-noto-sans-cjk-ttc-fonts", "grub2-efi-ia32-cdboot",
|
||||
"grub2-efi-x64-cdboot", "grub2-tools", "grub2-tools-efi",
|
||||
"grub2-tools-extra", "grub2-tools-minimal", "grubby",
|
||||
"gsettings-desktop-schemas", "hdparm", "hexedit", "hostname",
|
||||
"initscripts", "ipmitool", "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", "jomolhari-fonts",
|
||||
"kacst-farsi-fonts", "kacst-qurn-fonts", "kbd", "kbd-misc",
|
||||
"kdump-anaconda-addon", "kernel", "khmeros-base-fonts", "less",
|
||||
"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",
|
||||
"memtest86+", "metacity", "mtr", "mt-st", "net-tools", "nfs-utils",
|
||||
"nmap-ncat", "nm-connection-editor", "nss-tools",
|
||||
"openssh-clients", "openssh-server", "oscap-anaconda-addon",
|
||||
"ostree", "pciutils", "perl-interpreter", "pigz", "plymouth",
|
||||
"prefixdevname", "python3-pyatspi", "rdma-core",
|
||||
"redhat-release-eula", "rng-tools", "rpcbind", "rpm-ostree",
|
||||
"rsync", "rsyslog", "selinux-policy-targeted", "sg3_utils",
|
||||
"shim-ia32", "shim-x64", "sil-abyssinica-fonts",
|
||||
"sil-padauk-fonts", "sil-scheherazade-fonts", "smartmontools",
|
||||
"smc-meera-fonts", "spice-vdagent", "strace", "syslinux",
|
||||
"systemd", "system-storage-manager", "tar",
|
||||
"thai-scalable-waree-fonts", "tigervnc-server-minimal",
|
||||
"tigervnc-server-module", "udisks2", "udisks2-iscsi", "usbutils",
|
||||
"vim-minimal", "volume_key", "wget", "xfsdump", "xfsprogs",
|
||||
"xorg-x11-drivers", "xorg-x11-fonts-misc", "xorg-x11-server-utils",
|
||||
"xorg-x11-server-Xorg", "xorg-x11-xauth", "xz",
|
||||
},
|
||||
Exclude: nil,
|
||||
}
|
||||
}
|
||||
|
|
@ -1,139 +0,0 @@
|
|||
package rhel90
|
||||
|
||||
import "github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
|
||||
type archPackages struct {
|
||||
x8664 []string
|
||||
aarch64 []string
|
||||
ppc64le []string
|
||||
s390x []string
|
||||
}
|
||||
|
||||
var packages = struct {
|
||||
GenericBuild []string
|
||||
Bootloader archPackages
|
||||
Build archPackages
|
||||
Qcow2 rpmmd.PackageSet
|
||||
}{
|
||||
GenericBuild: []string{
|
||||
"dnf",
|
||||
"dosfstools",
|
||||
"e2fsprogs",
|
||||
"glibc",
|
||||
"policycoreutils",
|
||||
"python39",
|
||||
"python3-iniparse", // dependency of org.osbuild.rhsm stage
|
||||
"qemu-img",
|
||||
"selinux-policy-targeted",
|
||||
"systemd",
|
||||
"tar",
|
||||
"xfsprogs",
|
||||
"xz",
|
||||
},
|
||||
Bootloader: archPackages{
|
||||
x8664: []string{
|
||||
"dracut-config-generic",
|
||||
"grub2-pc",
|
||||
"grub2-efi-x64",
|
||||
"shim-x64",
|
||||
},
|
||||
aarch64: []string{
|
||||
"dracut-config-generic",
|
||||
"efibootmgr",
|
||||
"grub2-efi-aa64",
|
||||
"grub2-tools",
|
||||
"shim-aa64",
|
||||
},
|
||||
ppc64le: []string{
|
||||
"dracut-config-generic",
|
||||
"powerpc-utils",
|
||||
"grub2-ppc64le",
|
||||
"grub2-ppc64le-modules",
|
||||
},
|
||||
s390x: []string{
|
||||
"dracut-config-generic",
|
||||
"s390utils-base",
|
||||
},
|
||||
},
|
||||
Build: archPackages{
|
||||
x8664: []string{
|
||||
"grub2-pc",
|
||||
},
|
||||
aarch64: nil,
|
||||
ppc64le: []string{
|
||||
"grub2-ppc64le",
|
||||
"grub2-ppc64le-modules",
|
||||
},
|
||||
s390x: []string{
|
||||
"s390utils-core",
|
||||
},
|
||||
},
|
||||
Qcow2: rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"@Core",
|
||||
"authselect-compat",
|
||||
"chrony",
|
||||
"cloud-init",
|
||||
"cloud-utils-growpart",
|
||||
"cockpit-system",
|
||||
"cockpit-ws",
|
||||
"dnf",
|
||||
"dnf-utils",
|
||||
"dosfstools",
|
||||
"dracut-config-generic",
|
||||
"hostname",
|
||||
"NetworkManager",
|
||||
"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",
|
||||
"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-en",
|
||||
"libertas-sd8686-firmware",
|
||||
"libertas-sd8787-firmware",
|
||||
"libertas-usb8388-firmware",
|
||||
"nss",
|
||||
"plymouth",
|
||||
"rng-tools",
|
||||
"udisks2",
|
||||
},
|
||||
},
|
||||
}
|
||||
245
internal/distro/rhel90/partition_tables.go
Normal file
245
internal/distro/rhel90/partition_tables.go
Normal file
|
|
@ -0,0 +1,245 @@
|
|||
package rhel85
|
||||
|
||||
import (
|
||||
"io"
|
||||
"math/rand"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/disk"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
)
|
||||
|
||||
func defaultPartitionTable(imageOptions distro.ImageOptions, arch distro.Arch, rng *rand.Rand) disk.PartitionTable {
|
||||
var sectorSize uint64 = 512
|
||||
if arch.Name() == "x86_64" {
|
||||
return disk.PartitionTable{
|
||||
Size: imageOptions.Size,
|
||||
UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
|
||||
Type: "gpt",
|
||||
Partitions: []disk.Partition{
|
||||
{
|
||||
Bootable: true,
|
||||
Size: 2048,
|
||||
Start: 2048,
|
||||
Type: "21686148-6449-6E6F-744E-656564454649",
|
||||
UUID: "FAC7F1FB-3E8D-4137-A512-961DE09A5549",
|
||||
},
|
||||
{
|
||||
Start: 4096,
|
||||
Size: 204800,
|
||||
Type: "C12A7328-F81F-11D2-BA4B-00A0C93EC93B",
|
||||
UUID: "68B2905B-DF3E-4FB3-80FA-49D1E773AA33",
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "vfat",
|
||||
UUID: "7B77-95E7",
|
||||
Mountpoint: "/boot/efi",
|
||||
FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
Start: 208896,
|
||||
Size: imageOptions.Size/sectorSize - 208896 - 100,
|
||||
Type: "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
|
||||
UUID: "6264D520-3FB9-423F-8AB8-7A0A8E3D3562",
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
UUID: uuid.Must(newRandomUUIDFromReader(rng)).String(),
|
||||
Label: "root",
|
||||
Mountpoint: "/",
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
} else if arch.Name() == "aarch64" {
|
||||
return disk.PartitionTable{
|
||||
Size: imageOptions.Size,
|
||||
UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
|
||||
Type: "gpt",
|
||||
Partitions: []disk.Partition{
|
||||
{
|
||||
Start: 2048,
|
||||
Size: 204800,
|
||||
Type: "C12A7328-F81F-11D2-BA4B-00A0C93EC93B",
|
||||
UUID: "68B2905B-DF3E-4FB3-80FA-49D1E773AA33",
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "vfat",
|
||||
UUID: "7B77-95E7",
|
||||
Mountpoint: "/boot/efi",
|
||||
FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
Start: 206848,
|
||||
Size: imageOptions.Size/sectorSize - 206848 - 100,
|
||||
Type: "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
|
||||
UUID: "6264D520-3FB9-423F-8AB8-7A0A8E3D3562",
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
UUID: uuid.Must(newRandomUUIDFromReader(rng)).String(),
|
||||
Label: "root",
|
||||
Mountpoint: "/",
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
} else if arch.Name() == "ppc64le" {
|
||||
return disk.PartitionTable{
|
||||
Size: imageOptions.Size,
|
||||
UUID: "0x14fc63d2",
|
||||
Type: "dos",
|
||||
Partitions: []disk.Partition{
|
||||
{
|
||||
Start: 2048,
|
||||
Size: 8192,
|
||||
Type: "41",
|
||||
Bootable: true,
|
||||
},
|
||||
{
|
||||
Start: 10240,
|
||||
Size: imageOptions.Size/sectorSize - 10240 - 100,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
UUID: uuid.Must(newRandomUUIDFromReader(rng)).String(),
|
||||
Mountpoint: "/",
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
} else if arch.Name() == "s390x" {
|
||||
return disk.PartitionTable{
|
||||
Size: imageOptions.Size,
|
||||
UUID: "0x14fc63d2",
|
||||
Type: "dos",
|
||||
Partitions: []disk.Partition{
|
||||
{
|
||||
Start: 2048,
|
||||
Size: imageOptions.Size/sectorSize - 2048 - 100,
|
||||
Bootable: true,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
UUID: uuid.Must(newRandomUUIDFromReader(rng)).String(),
|
||||
Mountpoint: "/",
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
panic("unknown arch: " + arch.Name())
|
||||
}
|
||||
|
||||
func ec2PartitionTable(imageOptions distro.ImageOptions, arch distro.Arch, rng *rand.Rand) disk.PartitionTable {
|
||||
var sectorSize uint64 = 512
|
||||
if arch.Name() == "x86_64" {
|
||||
return disk.PartitionTable{
|
||||
Size: imageOptions.Size,
|
||||
UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
|
||||
Type: "gpt",
|
||||
Partitions: []disk.Partition{
|
||||
{
|
||||
Bootable: true,
|
||||
Size: 2048,
|
||||
Start: 2048,
|
||||
Type: "21686148-6449-6E6F-744E-656564454649",
|
||||
UUID: "FAC7F1FB-3E8D-4137-A512-961DE09A5549",
|
||||
},
|
||||
{
|
||||
Start: 4096,
|
||||
Size: imageOptions.Size/sectorSize - 4096 - 100,
|
||||
Type: "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
|
||||
UUID: "6264D520-3FB9-423F-8AB8-7A0A8E3D3562",
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
UUID: uuid.Must(newRandomUUIDFromReader(rng)).String(),
|
||||
Label: "root",
|
||||
Mountpoint: "/",
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
} else if arch.Name() == "aarch64" {
|
||||
return disk.PartitionTable{
|
||||
Size: imageOptions.Size,
|
||||
UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
|
||||
Type: "gpt",
|
||||
Partitions: []disk.Partition{
|
||||
{
|
||||
Start: 2048,
|
||||
Size: 409600,
|
||||
Type: "C12A7328-F81F-11D2-BA4B-00A0C93EC93B",
|
||||
UUID: "68B2905B-DF3E-4FB3-80FA-49D1E773AA33",
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "vfat",
|
||||
UUID: "7B77-95E7",
|
||||
Mountpoint: "/boot/efi",
|
||||
FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
Start: 411648,
|
||||
Size: 1048576,
|
||||
Type: "C12A7328-F81F-11D2-BA4B-00A0C93EC93B",
|
||||
UUID: "68B2905B-DF3E-4FB3-80FA-49D1E773AA33",
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
UUID: "2AE383D1-F57C-4F04-A1BD-32FC12A578EA",
|
||||
Mountpoint: "/boot",
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
Start: 1460224,
|
||||
Size: imageOptions.Size/sectorSize - 1460224 - 100,
|
||||
Type: "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
|
||||
UUID: "6264D520-3FB9-423F-8AB8-7A0A8E3D3562",
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
UUID: uuid.Must(newRandomUUIDFromReader(rng)).String(),
|
||||
Label: "root",
|
||||
Mountpoint: "/",
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
panic("unsupported EC2 arch: " + arch.Name())
|
||||
}
|
||||
|
||||
func newRandomUUIDFromReader(r io.Reader) (uuid.UUID, error) {
|
||||
var id uuid.UUID
|
||||
_, err := io.ReadFull(r, id[:])
|
||||
if err != nil {
|
||||
return uuid.Nil, err
|
||||
}
|
||||
id[6] = (id[6] & 0x0f) | 0x40 // Version 4
|
||||
id[8] = (id[8] & 0x3f) | 0x80 // Variant is 10
|
||||
return id, nil
|
||||
}
|
||||
1010
internal/distro/rhel90/pipelines.go
Normal file
1010
internal/distro/rhel90/pipelines.go
Normal file
File diff suppressed because it is too large
Load diff
74
internal/distro/rhel90/stage_inputs.go
Normal file
74
internal/distro/rhel90/stage_inputs.go
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
package rhel85
|
||||
|
||||
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() *osbuild.XorrisofsStageInputs {
|
||||
input := new(osbuild.XorrisofsStageInput)
|
||||
input.Type = "org.osbuild.tree"
|
||||
input.Origin = "org.osbuild.pipeline"
|
||||
input.References = osbuild.XorrisofsStageReferences{"name:bootiso-tree"}
|
||||
return &osbuild.XorrisofsStageInputs{Tree: input}
|
||||
}
|
||||
|
||||
func copyPipelineTreeInputs(name, inputPipeline string) *osbuild.CopyStageInputs {
|
||||
inputName := "root-tree"
|
||||
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}
|
||||
}
|
||||
515
internal/distro/rhel90/stage_options.go
Normal file
515
internal/distro/rhel90/stage_options.go
Normal file
|
|
@ -0,0 +1,515 @@
|
|||
package rhel85
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
"github.com/osbuild/osbuild-composer/internal/crypt"
|
||||
"github.com/osbuild/osbuild-composer/internal/disk"
|
||||
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,
|
||||
Exclude: &osbuild.Exclude{
|
||||
// NOTE: Make configurable?
|
||||
Docs: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// 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 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",
|
||||
"anaconda",
|
||||
"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",
|
||||
"biosdevname",
|
||||
"dracut-systemd",
|
||||
"pollcdrom",
|
||||
"usrmount",
|
||||
"base",
|
||||
"fs-lib",
|
||||
"img-lib",
|
||||
"shutdown",
|
||||
"uefi-lib",
|
||||
}
|
||||
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-5-0-BaseOS-%s", arch)
|
||||
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: []string{
|
||||
"IA32",
|
||||
"X64",
|
||||
},
|
||||
Vendor: "redhat",
|
||||
},
|
||||
ISOLinux: osbuild.ISOLinux{
|
||||
Enabled: true,
|
||||
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) *osbuild.XorrisofsStageOptions {
|
||||
return &osbuild.XorrisofsStageOptions{
|
||||
Filename: filename,
|
||||
VolID: fmt.Sprintf("RHEL-8-5-0-BaseOS-%s", arch),
|
||||
SysID: "LINUX",
|
||||
Boot: osbuild.XorrisofsBoot{
|
||||
Image: "isolinux/isolinux.bin",
|
||||
Catalog: "isolinux/boot.cat",
|
||||
},
|
||||
EFI: "images/efiboot.img",
|
||||
IsohybridMBR: "/usr/share/syslinux/isohdpfx.bin",
|
||||
}
|
||||
}
|
||||
|
||||
func grub2StageOptions(rootPartition *disk.Partition, kernelOptions string, kernel *blueprint.KernelCustomization, kernelVer string, uefi bool, legacy string) *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 uefi {
|
||||
stageOptions.UEFI = &osbuild.GRUB2UEFI{
|
||||
Vendor: "redhat",
|
||||
}
|
||||
}
|
||||
|
||||
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, device *osbuild.Device) (*osbuild.SfdiskStageOptions, *osbuild.SfdiskStageDevices) {
|
||||
stageDevices := &osbuild.SfdiskStageDevices{
|
||||
Device: *device,
|
||||
}
|
||||
|
||||
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, stageDevices
|
||||
}
|
||||
|
||||
// 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.CopyStageDevices,
|
||||
*osbuild.CopyStageMounts,
|
||||
) {
|
||||
// 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.CopyStageMounts(mounts)
|
||||
stageDevices := osbuild.CopyStageDevices(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")
|
||||
}
|
||||
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: "/boot/grub2",
|
||||
}
|
||||
|
||||
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,
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue