distro: rhel90 custom filesystem support

This commit is contained in:
Gianluca Zuccarelli 2021-08-19 11:47:36 +01:00 committed by Tom Gundersen
parent 382b5370c0
commit 8374af3e6d
4 changed files with 372 additions and 289 deletions

View file

@ -5,9 +5,11 @@ import (
"errors"
"fmt"
"math/rand"
"path"
"sort"
"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"
@ -50,6 +52,8 @@ const (
blueprintPkgsKey = "blueprint"
)
var mountpointAllowList = []string{"/", "/var", "/var/*", "/home", "/opt", "/srv", "/usr"}
type distribution struct {
name string
modulePlatformID string
@ -326,6 +330,22 @@ func (t *imageType) supportsUEFI() bool {
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
@ -402,6 +422,18 @@ func (t *imageType) sources(packages []rpmmd.PackageSpec, ostreeCommits []ostree
return sources
}
func isMountpointAllowed(mountpoint string) bool {
for _, allowed := range mountpointAllowList {
// check if the path and its subdirectories
// is in the allow list
match, _ := path.Match(allowed, mountpoint)
if mountpoint == "/" || 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 {
@ -423,10 +455,12 @@ func (t *imageType) checkOptions(customizations *blueprint.Customizations, optio
return fmt.Errorf("Custom mountpoints are not supported for ostree types")
}
// only allow root mountpoint for the time-being
invalidMountpoints := []string{}
for _, m := range mountpoints {
if m.Mountpoint != "/" {
if m.Mountpoint == "/usr" && m.MinSize < 2147483648 {
m.MinSize = 2147483648
}
if !isMountpointAllowed(m.Mountpoint) {
invalidMountpoints = append(invalidMountpoints, m.Mountpoint)
}
}
@ -572,10 +606,11 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
packageSets: map[string]rpmmd.PackageSet{
osPkgsKey: qcow2CommonPackageSet(),
},
bootable: true,
defaultSize: 10 * GigaByte,
pipelines: qcow2Pipelines,
exports: []string{"qcow2"},
bootable: true,
defaultSize: 10 * GigaByte,
pipelines: qcow2Pipelines,
exports: []string{"qcow2"},
basePartitionTables: defaultBasePartitionTables,
}
vhdImgType := imageType{
@ -589,12 +624,13 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
"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"},
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{
@ -604,11 +640,12 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
packageSets: map[string]rpmmd.PackageSet{
osPkgsKey: vmdkCommonPackageSet(),
},
kernelOptions: "ro net.ifnames=0",
bootable: true,
defaultSize: 4 * GigaByte,
pipelines: vmdkPipelines,
exports: []string{"vmdk"},
kernelOptions: "ro net.ifnames=0",
bootable: true,
defaultSize: 4 * GigaByte,
pipelines: vmdkPipelines,
exports: []string{"vmdk"},
basePartitionTables: defaultBasePartitionTables,
}
openstackImgType := imageType{
@ -618,11 +655,12 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
packageSets: map[string]rpmmd.PackageSet{
osPkgsKey: openstackCommonPackageSet(),
},
kernelOptions: "ro net.ifnames=0",
bootable: true,
defaultSize: 4 * GigaByte,
pipelines: openstackPipelines,
exports: []string{"qcow2"},
kernelOptions: "ro net.ifnames=0",
bootable: true,
defaultSize: 4 * GigaByte,
pipelines: openstackPipelines,
exports: []string{"qcow2"},
basePartitionTables: defaultBasePartitionTables,
}
// EC2 services
@ -646,14 +684,15 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
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"},
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{
@ -664,13 +703,14 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
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"},
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{
@ -681,14 +721,15 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
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"},
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{
@ -699,13 +740,14 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
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"},
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{
@ -716,14 +758,15 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
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"},
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{

View file

@ -610,3 +610,87 @@ func TestDistro_TestRootMountPoint(t *testing.T) {
}
}
}
func TestDistro_CustomFileSystemSubDirectories(t *testing.T) {
r9distro := rhel90.New()
bp := blueprint.Blueprint{
Customizations: &blueprint.Customizations{
Filesystem: []blueprint.FilesystemCustomization{
{
MinSize: 1024,
Mountpoint: "/var/log",
},
},
},
}
for _, archName := range r9distro.ListArches() {
arch, _ := r9distro.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" {
continue
} else {
assert.NoError(t, err)
}
}
}
}
func TestDistro_CustomFileSystemPatternMatching(t *testing.T) {
r9distro := rhel90.New()
bp := blueprint.Blueprint{
Customizations: &blueprint.Customizations{
Filesystem: []blueprint.FilesystemCustomization{
{
MinSize: 1024,
Mountpoint: "/variable",
},
},
},
}
for _, archName := range r9distro.ListArches() {
arch, _ := r9distro.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" {
continue
} else {
assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/variable\"]")
}
}
}
}
func TestDistro_CustomUsrPartitionNotLargeEnough(t *testing.T) {
r9distro := rhel90.New()
bp := blueprint.Blueprint{
Customizations: &blueprint.Customizations{
Filesystem: []blueprint.FilesystemCustomization{
{
MinSize: 1024,
Mountpoint: "/usr",
},
},
},
}
for _, archName := range r9distro.ListArches() {
arch, _ := r9distro.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" {
continue
} else {
assert.NoError(t, err)
}
}
}
}

View file

@ -1,245 +1,183 @@
package rhel90
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,
},
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,
},
},
}
} 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,
},
{
Type: disk.FilesystemDataGUID,
UUID: disk.RootPartitionUUID,
Filesystem: &disk.Filesystem{
Type: "xfs",
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,
},
},
},
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,
},
},
}
} 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,
},
{
Type: disk.FilesystemDataGUID,
UUID: disk.RootPartitionUUID,
Filesystem: &disk.Filesystem{
Type: "xfs",
Label: "root",
Mountpoint: "/",
FSTabOptions: "defaults",
FSTabFreq: 0,
FSTabPassNo: 0,
},
},
}
}
panic("unknown arch: " + arch.Name())
},
},
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,
},
},
},
},
}
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,
},
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,
},
},
}
} 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: "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
UUID: "CB07C243-BC44-4717-853E-28852021225B",
Filesystem: &disk.Filesystem{
Type: "xfs",
UUID: uuid.Must(newRandomUUIDFromReader(rng)).String(),
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,
},
},
},
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,
},
},
}
}
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
{
Size: 1048576,
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,
},
},
},
},
}

View file

@ -23,7 +23,11 @@ func qcow2Pipelines(t *imageType, customizations *blueprint.Customizations, opti
return nil, err
}
partitionTable := defaultPartitionTable(options, t.arch, rng)
partitionTable, err := t.getPartitionTable(customizations.GetFilesystems(), options, rng)
if err != nil {
return nil, err
}
treePipeline = prependKernelCmdlineStage(treePipeline, t, &partitionTable)
if options.Subscription == nil {
@ -70,7 +74,11 @@ func vhdPipelines(t *imageType, customizations *blueprint.Customizations, option
return nil, err
}
partitionTable := defaultPartitionTable(options, t.arch, rng)
partitionTable, err := t.getPartitionTable(customizations.GetFilesystems(), options, rng)
if err != nil {
return nil, err
}
treePipeline = prependKernelCmdlineStage(treePipeline, t, &partitionTable)
treePipeline.AddStage(osbuild.NewFSTabStage(partitionTable.FSTabStageOptionsV2()))
kernelVer := kernelVerStr(packageSetSpecs[blueprintPkgsKey], customizations.GetKernel().Name, t.Arch().Name())
@ -98,7 +106,11 @@ func vmdkPipelines(t *imageType, customizations *blueprint.Customizations, optio
return nil, err
}
partitionTable := defaultPartitionTable(options, t.arch, rng)
partitionTable, err := t.getPartitionTable(customizations.GetFilesystems(), options, rng)
if err != nil {
return nil, err
}
treePipeline = prependKernelCmdlineStage(treePipeline, t, &partitionTable)
treePipeline.AddStage(osbuild.NewFSTabStage(partitionTable.FSTabStageOptionsV2()))
kernelVer := kernelVerStr(packageSetSpecs[blueprintPkgsKey], customizations.GetKernel().Name, t.Arch().Name())
@ -126,7 +138,10 @@ func openstackPipelines(t *imageType, customizations *blueprint.Customizations,
return nil, err
}
partitionTable := defaultPartitionTable(options, t.arch, rng)
partitionTable, err := t.getPartitionTable(customizations.GetFilesystems(), options, rng)
if err != nil {
return nil, err
}
treePipeline = prependKernelCmdlineStage(treePipeline, t, &partitionTable)
treePipeline.AddStage(osbuild.NewFSTabStage(partitionTable.FSTabStageOptionsV2()))
kernelVer := kernelVerStr(packageSetSpecs[blueprintPkgsKey], customizations.GetKernel().Name, t.Arch().Name())
@ -391,9 +406,12 @@ func ec2CommonPipelines(t *imageType, customizations *blueprint.Customizations,
pipelines := make([]osbuild.Pipeline, 0)
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey]))
partitionTable := ec2PartitionTable(options, t.arch, rng)
partitionTable, err := t.getPartitionTable(customizations.GetFilesystems(), options, rng)
if err != nil {
return nil, err
}
var treePipeline *osbuild.Pipeline
var err error
switch arch := t.arch.Name(); arch {
// rhel-ec2-x86_64, rhel-ha-ec2
case distro.X86_64ArchName: