Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fedora: add base support for ppc64le and s390x architectures #198

Merged
merged 4 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion pkg/distro/fedora/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,16 @@ func newDistro(version int) distro.Distro {
distro: &rd,
}

ppc64le := architecture{
distro: &rd,
name: platform.ARCH_PPC64LE.String(),
}

s390x := architecture{
distro: &rd,
name: platform.ARCH_S390X.String(),
}
thozza marked this conversation as resolved.
Show resolved Hide resolved

ociImgType := qcow2ImgType
ociImgType.name = "oci"

Expand Down Expand Up @@ -852,6 +862,36 @@ func newDistro(version int) distro.Distro {
)
}

rd.addArches(x86_64, aarch64)
ppc64le.addImageTypes(
&platform.PPC64LE{
BIOS: true,
BasePlatform: platform.BasePlatform{
ImageFormat: platform.FORMAT_QCOW2,
QCOW2Compat: "1.1",
},
},
qcow2ImgType,
)
ppc64le.addImageTypes(
&platform.PPC64LE{},
containerImgType,
)

s390x.addImageTypes(
&platform.S390X{
Zipl: true,
BasePlatform: platform.BasePlatform{
ImageFormat: platform.FORMAT_QCOW2,
QCOW2Compat: "1.1",
},
},
qcow2ImgType,
)
s390x.addImageTypes(
&platform.S390X{},
containerImgType,
)

rd.addArches(x86_64, aarch64, ppc64le, s390x)
return &rd
}
60 changes: 37 additions & 23 deletions pkg/distro/fedora/distro_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,24 +481,26 @@ func TestDistro_ManifestError(t *testing.T) {
for _, archName := range fedoraDistro.ListArches() {
arch, _ := fedoraDistro.GetArch(archName)
for _, imgTypeName := range arch.ListImageTypes() {
imgType, _ := arch.GetImageType(imgTypeName)
imgOpts := distro.ImageOptions{
Size: imgType.Size(0),
}
_, _, err := imgType.Manifest(&bp, imgOpts, nil, 0)
if imgTypeName == "iot-commit" || imgTypeName == "iot-container" {
assert.EqualError(t, err, "kernel boot parameter customizations are not supported for ostree types")
} else if imgTypeName == "iot-installer" || imgTypeName == "iot-simplified-installer" {
assert.EqualError(t, err, fmt.Sprintf("boot ISO image type \"%s\" requires specifying a URL from which to retrieve the OSTree commit", imgTypeName))
} else if imgTypeName == "image-installer" {
assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for boot ISO image type \"%s\": (allowed: User, Group)", imgTypeName))
} else if imgTypeName == "live-installer" {
assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for boot ISO image type \"%s\": (allowed: None)", imgTypeName))
} else if imgTypeName == "iot-raw-image" || imgTypeName == "iot-qcow2-image" {
assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for image type %q: (allowed: User, Group, Directories, Files, Services)", imgTypeName))
} else {
assert.NoError(t, err)
}
t.Run(fmt.Sprintf("%s/%s", archName, imgTypeName), func(t *testing.T) {
imgType, _ := arch.GetImageType(imgTypeName)
imgOpts := distro.ImageOptions{
Size: imgType.Size(0),
}
_, _, err := imgType.Manifest(&bp, imgOpts, nil, 0)
if imgTypeName == "iot-commit" || imgTypeName == "iot-container" {
assert.EqualError(t, err, "kernel boot parameter customizations are not supported for ostree types")
} else if imgTypeName == "iot-installer" || imgTypeName == "iot-simplified-installer" {
assert.EqualError(t, err, fmt.Sprintf("boot ISO image type \"%s\" requires specifying a URL from which to retrieve the OSTree commit", imgTypeName))
} else if imgTypeName == "image-installer" {
assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for boot ISO image type \"%s\": (allowed: User, Group)", imgTypeName))
} else if imgTypeName == "live-installer" {
assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for boot ISO image type \"%s\": (allowed: None)", imgTypeName))
} else if imgTypeName == "iot-raw-image" || imgTypeName == "iot-qcow2-image" {
assert.EqualError(t, err, fmt.Sprintf("unsupported blueprint customizations found for image type %q: (allowed: User, Group, Directories, Files, Services)", imgTypeName))
} else {
assert.NoError(t, err)
}
})
}
}
}
Expand Down Expand Up @@ -559,6 +561,20 @@ func TestArchitecture_ListImageTypes(t *testing.T) {
"40": {"iot-simplified-installer"},
},
},
{
arch: "ppc64le",
imgNames: []string{
"container",
"qcow2",
},
},
{
arch: "s390x",
imgNames: []string{
"container",
"qcow2",
},
},
}

for _, dist := range fedoraFamilyDistros {
Expand All @@ -580,7 +596,7 @@ func TestArchitecture_ListImageTypes(t *testing.T) {

func TestFedora_ListArches(t *testing.T) {
arches := fedora.NewF37().ListArches()
assert.Equal(t, []string{"aarch64", "x86_64"}, arches)
assert.Equal(t, []string{"aarch64", "ppc64le", "s390x", "x86_64"}, arches)
}

func TestFedora37_GetArch(t *testing.T) {
Expand All @@ -596,12 +612,10 @@ func TestFedora37_GetArch(t *testing.T) {
name: "aarch64",
},
{
name: "s390x",
errorExpected: true,
name: "s390x",
},
{
name: "ppc64le",
errorExpected: true,
name: "ppc64le",
},
{
name: "foo-arch",
Expand Down
61 changes: 61 additions & 0 deletions pkg/distro/fedora/partition_tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,67 @@ var defaultBasePartitionTables = distro.BasePartitionTableMap{
},
},
},
platform.ARCH_PPC64LE.String(): disk.PartitionTable{
UUID: "0x14fc63d2",
Type: "dos",
Partitions: []disk.Partition{
{
Size: 4 * common.MebiByte,
Type: "41",
Bootable: true,
},
{
Size: 500 * common.MebiByte,
Payload: &disk.Filesystem{
Type: "ext4",
Mountpoint: "/boot",
Label: "boot",
FSTabOptions: "defaults",
FSTabFreq: 0,
FSTabPassNo: 0,
},
},
{
Size: 2 * common.GibiByte,
Payload: &disk.Filesystem{
Type: "ext4",
Mountpoint: "/",
FSTabOptions: "defaults",
FSTabFreq: 0,
FSTabPassNo: 0,
},
},
},
},

platform.ARCH_S390X.String(): disk.PartitionTable{
UUID: "0x14fc63d2",
Type: "dos",
Partitions: []disk.Partition{
{
Size: 500 * common.MebiByte,
Payload: &disk.Filesystem{
Type: "ext4",
Mountpoint: "/boot",
Label: "boot",
FSTabOptions: "defaults",
FSTabFreq: 0,
FSTabPassNo: 0,
},
},
{
Size: 2 * common.GibiByte,
Bootable: true,
Payload: &disk.Filesystem{
Type: "ext4",
Mountpoint: "/",
FSTabOptions: "defaults",
FSTabFreq: 0,
FSTabPassNo: 0,
},
},
},
},
}

var minimalrawPartitionTables = distro.BasePartitionTableMap{
Expand Down
28 changes: 20 additions & 8 deletions pkg/platform/ppc64le.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,29 @@ func (p *PPC64LE) GetBIOSPlatform() string {
}

func (p *PPC64LE) GetPackages() []string {
return []string{
"dracut-config-generic",
"powerpc-utils",
"grub2-ppc64le",
"grub2-ppc64le-modules",
packages := p.BasePlatform.FirmwarePackages

if p.BIOS {
packages = append(packages,
"dracut-config-generic",
"powerpc-utils",
"grub2-ppc64le",
"grub2-ppc64le-modules",
)
}

return packages
}

func (p *PPC64LE) GetBuildPackages() []string {
return []string{
"grub2-ppc64le",
"grub2-ppc64le-modules",
packages := []string{}

if p.BIOS {
packages = append(packages,
"grub2-ppc64le",
"grub2-ppc64le-modules",
)
}

return packages
}
24 changes: 15 additions & 9 deletions pkg/platform/s390x.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,24 @@ func (p *S390X) GetZiplSupport() bool {

func (p *S390X) GetPackages() []string {
packages := p.BasePlatform.FirmwarePackages
// TODO: should these packages be present also in images not intended for booting?
packages = append(packages,
"dracut-config-generic",
"s390utils-base",
"s390utils-core",
)

if p.Zipl {
packages = append(packages,
"dracut-config-generic",
"s390utils-base",
"s390utils-core",
)
}

return packages
}

func (p *S390X) GetBuildPackages() []string {
// TODO: should these packages be present also in images not intended for booting?
return []string{
"s390utils-base",
packages := []string{}

if p.Zipl {
packages = append(packages, "s390utils-base")
}

return packages
}
Loading
Loading