From f4ee0bfabf96cfb1184f80e4b4e5b00773aef110 Mon Sep 17 00:00:00 2001 From: Gianluca Zuccarelli Date: Thu, 8 Jul 2021 13:54:25 +0100 Subject: [PATCH] distro: add root filesystem support --- internal/distro/fedora33/distro.go | 17 +++++++++++++++++ internal/distro/rhel8/distro.go | 20 ++++++++++++++++++++ internal/distro/rhel84/distro.go | 17 +++++++++++++++++ internal/distro/rhel84/distro_v2.go | 17 +++++++++++++++++ internal/distro/rhel85/distro.go | 18 ++++++++++++++++++ internal/distro/rhel90/distro.go | 15 +++++++++++++++ 6 files changed, 104 insertions(+) diff --git a/internal/distro/fedora33/distro.go b/internal/distro/fedora33/distro.go index 8f3e23499..7afe96807 100644 --- a/internal/distro/fedora33/distro.go +++ b/internal/distro/fedora33/distro.go @@ -289,6 +289,23 @@ func (t *imageType) pipeline(c *blueprint.Customizations, options distro.ImageOp return nil, fmt.Errorf("kernel boot parameter customizations are not supported for ostree types") } + mountpoints := c.GetFilesystems() + + if mountpoints != nil && t.rpmOstree { + return nil, fmt.Errorf("Custom mountpoints are not supported for ostree types") + } + + invalidMountpoints := []string{} + for _, m := range mountpoints { + if m.Mountpoint != "/" { + invalidMountpoints = append(invalidMountpoints, m.Mountpoint) + } + } + + if len(invalidMountpoints) > 0 { + return nil, fmt.Errorf("The following custom mountpoints are not supported %+q", invalidMountpoints) + } + p := &osbuild.Pipeline{} p.SetBuild(t.buildPipeline(repos, *t.arch, buildPackageSpecs), "org.osbuild.fedora33") diff --git a/internal/distro/rhel8/distro.go b/internal/distro/rhel8/distro.go index 0dc1f0584..7f6426f00 100644 --- a/internal/distro/rhel8/distro.go +++ b/internal/distro/rhel8/distro.go @@ -288,6 +288,26 @@ func (t *imageType) pipeline(c *blueprint.Customizations, options distro.ImageOp return nil, fmt.Errorf("kernel boot parameter customizations are not supported for ostree types") } + mountpoints := c.GetFilesystems() + + if mountpoints != nil && t.rpmOstree { + return nil, fmt.Errorf("Custom mountpoints are not supported for ostree types") + } + + // create a slice for storing + // invalid mountpoints in order to return + // a detailed message + invalidMountpoints := []string{} + for _, m := range mountpoints { + if m.Mountpoint != "/" { + invalidMountpoints = append(invalidMountpoints, m.Mountpoint) + } + } + + if len(invalidMountpoints) > 0 { + return nil, fmt.Errorf("The following custom mountpoints are not supported %+q", invalidMountpoints) + } + p := &osbuild.Pipeline{} p.SetBuild(t.buildPipeline(repos, *t.arch, buildPackageSpecs), "org.osbuild.rhel82") diff --git a/internal/distro/rhel84/distro.go b/internal/distro/rhel84/distro.go index d6fa228d7..3b1e3aa2f 100644 --- a/internal/distro/rhel84/distro.go +++ b/internal/distro/rhel84/distro.go @@ -317,6 +317,23 @@ func (t *imageType) pipeline(c *blueprint.Customizations, options distro.ImageOp return nil, fmt.Errorf("kernel boot parameter customizations are not supported for ostree types") } + mountpoints := c.GetFilesystems() + + if mountpoints != nil && t.rpmOstree { + return nil, fmt.Errorf("Custom mountpoints are not supported for ostree types") + } + + invalidMountpoints := []string{} + for _, m := range mountpoints { + if m.Mountpoint != "/" { + invalidMountpoints = append(invalidMountpoints, m.Mountpoint) + } + } + + if len(invalidMountpoints) > 0 { + return nil, fmt.Errorf("The following custom mountpoints are not supported %+q", invalidMountpoints) + } + var pt *disk.PartitionTable if t.partitionTableGenerator != nil { table := t.partitionTableGenerator(options, t.arch, rng) diff --git a/internal/distro/rhel84/distro_v2.go b/internal/distro/rhel84/distro_v2.go index f50723506..707a41e52 100644 --- a/internal/distro/rhel84/distro_v2.go +++ b/internal/distro/rhel84/distro_v2.go @@ -206,6 +206,23 @@ func (t *imageTypeS2) pipelines(customizations *blueprint.Customizations, option return nil, fmt.Errorf("kernel boot parameter customizations are not supported for ostree types") } + mountpoints := customizations.GetFilesystems() + + if mountpoints != nil && t.rpmOstree { + return nil, fmt.Errorf("Custom mountpoints are not supported for ostree types") + } + + invalidMountpoints := []string{} + for _, m := range mountpoints { + if m.Mountpoint != "/" { + invalidMountpoints = append(invalidMountpoints, m.Mountpoint) + } + } + + if len(invalidMountpoints) > 0 { + return nil, fmt.Errorf("The following custom mountpoints are not supported %+q", invalidMountpoints) + } + pipelines := make([]osbuild.Pipeline, 0) pipelines = append(pipelines, *t.buildPipeline(repos, packageSetSpecs["build-packages"])) diff --git a/internal/distro/rhel85/distro.go b/internal/distro/rhel85/distro.go index 196c6191c..c7f56ab88 100644 --- a/internal/distro/rhel85/distro.go +++ b/internal/distro/rhel85/distro.go @@ -368,6 +368,24 @@ func (t *imageType) checkOptions(customizations *blueprint.Customizations, optio return fmt.Errorf("kernel boot parameter customizations are not supported for ostree types") } + mountpoints := customizations.GetFilesystems() + + if mountpoints != nil && t.rpmOstree { + return fmt.Errorf("Custom mountpoints are not supported for ostree types") + } + + // only allow root mountpoint for the time-being + invalidMountpoints := []string{} + for _, m := range mountpoints { + if m.Mountpoint != "/" { + invalidMountpoints = append(invalidMountpoints, m.Mountpoint) + } + } + + if len(invalidMountpoints) > 0 { + return fmt.Errorf("The following custom mountpoints are not supported %+q", invalidMountpoints) + } + return nil } diff --git a/internal/distro/rhel90/distro.go b/internal/distro/rhel90/distro.go index 06998519f..5502a95dd 100644 --- a/internal/distro/rhel90/distro.go +++ b/internal/distro/rhel90/distro.go @@ -288,6 +288,21 @@ func sources(packages []rpmmd.PackageSpec) *osbuild.Sources { } func (t *imageType) pipeline(c *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, rng *rand.Rand) (*osbuild.Pipeline, error) { + + mountpoints := c.GetFilesystems() + + // only allow root mountpoint for the time-being + invalidMountpoints := []string{} + for _, m := range mountpoints { + if m.Mountpoint != "/" { + invalidMountpoints = append(invalidMountpoints, m.Mountpoint) + } + } + + if len(invalidMountpoints) > 0 { + return nil, fmt.Errorf("The following custom mountpoints are not supported %+q", invalidMountpoints) + } + var pt *disk.PartitionTable if t.partitionTableGenerator != nil { table := t.partitionTableGenerator(options, t.arch, rng)