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

Remove ISOLabelTmpl from all installer image kinds #542

Merged
merged 2 commits into from
Mar 25, 2024
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
13 changes: 13 additions & 0 deletions pkg/distro/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,19 @@ type Distro interface {
// files on the host system and required for the subscription support.
Releasever() string

// Returns the OS version of the distro, which may contain minor versions
// if the distro supports them. This is used in various places where the
// minor version of the distro is needed to determine the correct
// configuration.
OsVersion() string

// Returns the module platform id of the distro. This is used by DNF
// for modularity support.
ModulePlatformID() string

// Returns the product name of the distro.
Product() string

// Returns the ostree reference template
OSTreeRef() string

Expand Down Expand Up @@ -96,6 +105,10 @@ type ImageType interface {
// Returns the default OSTree ref for the image type.
OSTreeRef() string

// Returns the ISO Label for the image type. Returns an error if the image
// type is not an ISO.
ISOLabel() (string, error)

// Returns the proper image size for a given output format. If the input size
// is 0 the default value for the format will be returned.
Size(size uint64) uint64
Expand Down
30 changes: 26 additions & 4 deletions pkg/distro/fedora/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ var (
osPkgsKey: minimalrpmPackageSet,
installerPkgsKey: imageInstallerPackageSet,
},
bootable: true,
bootISO: true,
rpmOstree: false,
image: imageInstallerImage,
bootable: true,
bootISO: true,
rpmOstree: false,
image: imageInstallerImage,
// We don't know the variant of the OS pipeline being installed
isoLabel: getISOLabelFunc("Unknown"),
buildPipelines: []string{"build"},
payloadPipelines: []string{"anaconda-tree", "rootfs-image", "efiboot-tree", "os", "bootiso-tree", "bootiso"},
exports: []string{"bootiso"},
Expand All @@ -107,6 +109,7 @@ var (
bootISO: true,
rpmOstree: false,
image: liveInstallerImage,
isoLabel: getISOLabelFunc("Workstation"),
buildPipelines: []string{"build"},
payloadPipelines: []string{"anaconda-tree", "rootfs-image", "efiboot-tree", "bootiso-tree", "bootiso"},
exports: []string{"bootiso"},
Expand Down Expand Up @@ -183,6 +186,7 @@ var (
rpmOstree: true,
bootISO: true,
image: iotInstallerImage,
isoLabel: getISOLabelFunc("IoT"),
buildPipelines: []string{"build"},
payloadPipelines: []string{"anaconda-tree", "rootfs-image", "efiboot-tree", "bootiso-tree", "bootiso"},
exports: []string{"bootiso"},
Expand All @@ -203,6 +207,7 @@ var (
bootable: true,
bootISO: true,
image: iotSimplifiedInstallerImage,
isoLabel: getISOLabelFunc("IoT"),
buildPipelines: []string{"build"},
payloadPipelines: []string{"ostree-deployment", "image", "xz", "coi-tree", "efiboot-tree", "bootiso-tree", "bootiso"},
exports: []string{"bootiso"},
Expand Down Expand Up @@ -412,6 +417,15 @@ var defaultDistroImageConfig = &distro.ImageConfig{
Locale: common.ToPtr("en_US"),
}

func getISOLabelFunc(variant string) isoLabelFunc {
const ISO_LABEL = "%s-%s-%s-%s"

return func(t *imageType) string {
return fmt.Sprintf(ISO_LABEL, t.Arch().Distro().Product(), t.Arch().Distro().OsVersion(), variant, t.Arch().Name())
}

}

func getDistro(version int) distribution {
return distribution{
name: fmt.Sprintf("fedora-%d", version),
Expand All @@ -433,6 +447,14 @@ func (d *distribution) Releasever() string {
return d.releaseVersion
}

func (d *distribution) OsVersion() string {
return d.releaseVersion
}

func (d *distribution) Product() string {
return d.product
}

func (d *distribution) ModulePlatformID() string {
return d.modulePlatformID
}
Expand Down
29 changes: 22 additions & 7 deletions pkg/distro/fedora/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (
"github.com/osbuild/images/pkg/rpmmd"
)

const ISO_LABEL = "%s-%s-%s-%s"

// HELPERS

func osCustomizations(
Expand Down Expand Up @@ -333,9 +331,14 @@ func liveInstallerImage(workload workload.Workload,
img.Variant = "Workstation"
img.OSVersion = d.osVersion
img.Release = fmt.Sprintf("%s %s", d.product, d.osVersion)
img.ISOLabel = fmt.Sprintf(ISO_LABEL, img.Product, img.OSVersion, img.Variant, img.Platform.GetArch())
img.Preview = common.VersionGreaterThanOrEqual(img.OSVersion, VERSION_BRANCHED)

var err error
img.ISOLabel, err = t.ISOLabel()
if err != nil {
return nil, err
}

img.Filename = t.Filename()

return img, nil
Expand Down Expand Up @@ -389,10 +392,14 @@ func imageInstallerImage(workload workload.Workload,
img.OSVersion = d.osVersion
img.Release = fmt.Sprintf("%s %s", d.product, d.osVersion)

// We don't know the variant of the OS pipeline being installed
img.ISOLabel = fmt.Sprintf(ISO_LABEL, img.Product, img.OSVersion, img.Variant, img.Platform.GetArch())
img.Preview = common.VersionGreaterThanOrEqual(img.OSVersion, VERSION_BRANCHED)

var err error
img.ISOLabel, err = t.ISOLabel()
if err != nil {
return nil, err
}

img.Filename = t.Filename()

return img, nil
Expand Down Expand Up @@ -555,9 +562,13 @@ func iotInstallerImage(workload workload.Workload,
img.Remote = "fedora-iot"
img.OSVersion = d.osVersion
img.Release = fmt.Sprintf("%s %s", d.product, d.osVersion)
img.ISOLabel = fmt.Sprintf(ISO_LABEL, img.Product, img.OSVersion, img.Variant, img.Platform.GetArch())
img.Preview = common.VersionGreaterThanOrEqual(img.OSVersion, VERSION_BRANCHED)

img.ISOLabel, err = t.ISOLabel()
if err != nil {
return nil, err
}

img.Filename = t.Filename()

return img, nil
Expand Down Expand Up @@ -711,7 +722,11 @@ func iotSimplifiedInstallerImage(workload workload.Workload,
img.Variant = "IoT"
img.OSName = "fedora"
img.OSVersion = d.osVersion
img.ISOLabel = fmt.Sprintf(ISO_LABEL, img.Product, img.OSVersion, img.Variant, img.Platform.GetArch())

img.ISOLabel, err = t.ISOLabel()
if err != nil {
return nil, err
}

return img, nil
}
Expand Down
15 changes: 15 additions & 0 deletions pkg/distro/fedora/imagetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type imageFunc func(workload workload.Workload, t *imageType, bp *blueprint.Blue

type packageSetFunc func(t *imageType) rpmmd.PackageSet

type isoLabelFunc func(t *imageType) string

type imageType struct {
arch *architecture
platform platform.Platform
Expand All @@ -43,6 +45,7 @@ type imageType struct {
payloadPipelines []string
exports []string
image imageFunc
isoLabel isoLabelFunc

// bootISO: installable ISO
bootISO bool
Expand Down Expand Up @@ -79,6 +82,18 @@ func (t *imageType) OSTreeRef() string {
return ""
}

func (t *imageType) ISOLabel() (string, error) {
if !t.bootISO {
return "", fmt.Errorf("image type %q is not an ISO", t.name)
}

if t.isoLabel != nil {
return t.isoLabel(t), nil
}

return "", nil
}

func (t *imageType) Size(size uint64) uint64 {
// Microsoft Azure requires vhd images to be rounded up to the nearest MB
if t.name == "vhd" && size%common.MebiByte != 0 {
Expand Down
8 changes: 8 additions & 0 deletions pkg/distro/rhel7/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ func (d *distribution) Releasever() string {
return d.releaseVersion
}

func (d *distribution) OsVersion() string {
return d.osVersion
}

func (d *distribution) Product() string {
return d.product
}

func (d *distribution) ModulePlatformID() string {
return d.modulePlatformID
}
Expand Down
17 changes: 17 additions & 0 deletions pkg/distro/rhel7/imagetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ type packageSetFunc func(t *imageType) rpmmd.PackageSet

type imageFunc func(workload workload.Workload, t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, packageSets map[string]rpmmd.PackageSet, containers []container.SourceSpec, rng *rand.Rand) (image.ImageKind, error)

type isoLabelFunc func(t *imageType) string

type imageType struct {
arch *architecture
platform platform.Platform
Expand All @@ -41,7 +43,10 @@ type imageType struct {
payloadPipelines []string
exports []string
image imageFunc
isoLabel isoLabelFunc

// bootISO: installable ISO
bootISO bool
// bootable image
bootable bool
// List of valid arches for the image type
Expand Down Expand Up @@ -69,6 +74,18 @@ func (t *imageType) OSTreeRef() string {
return ""
}

func (t *imageType) ISOLabel() (string, error) {
if !t.bootISO {
return "", fmt.Errorf("image type %q is not an ISO", t.name)
}

if t.isoLabel != nil {
return t.isoLabel(t), nil
}

return "", nil
}

func (t *imageType) Size(size uint64) uint64 {
if size == 0 {
size = t.defaultSize
Expand Down
1 change: 1 addition & 0 deletions pkg/distro/rhel8/bare_metal.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func imageInstaller() imageType {
bootISO: true,
bootable: true,
image: imageInstallerImage,
isoLabel: distroISOLabelFunc,
buildPipelines: []string{"build"},
payloadPipelines: []string{"anaconda-tree", "rootfs-image", "efiboot-tree", "os", "bootiso-tree", "bootiso"},
exports: []string{"bootiso"},
Expand Down
11 changes: 8 additions & 3 deletions pkg/distro/rhel8/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ type distribution struct {
modulePlatformID string
vendor string
ostreeRefTmpl string
isolabelTmpl string
runner runner.Runner
arches map[string]distro.Arch
defaultImageConfig *distro.ImageConfig
Expand Down Expand Up @@ -77,6 +76,14 @@ func (d *distribution) Releasever() string {
return d.releaseVersion
}

func (d *distribution) OsVersion() string {
return d.osVersion
}

func (d *distribution) Product() string {
return d.product
}

func (d *distribution) ModulePlatformID() string {
return d.modulePlatformID
}
Expand Down Expand Up @@ -135,7 +142,6 @@ func newDistro(name string, minor int) *distribution {
modulePlatformID: "platform:el8",
vendor: "redhat",
ostreeRefTmpl: "rhel/8/%s/edge",
isolabelTmpl: fmt.Sprintf("RHEL-8-%d-0-BaseOS-%%s", minor),
runner: &runner.RHEL{Major: uint64(8), Minor: uint64(minor)},
defaultImageConfig: defaultDistroImageConfig,
}
Expand All @@ -148,7 +154,6 @@ func newDistro(name string, minor int) *distribution {
modulePlatformID: "platform:el8",
vendor: "centos",
ostreeRefTmpl: "centos/8/%s/edge",
isolabelTmpl: "CentOS-Stream-8-%s-dvd",
runner: &runner.CentOS{Version: uint64(8)},
defaultImageConfig: defaultDistroImageConfig,
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/distro/rhel8/edge.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func edgeInstallerImgType(rd distribution) imageType {
rpmOstree: true,
bootISO: true,
image: edgeInstallerImage,
isoLabel: distroISOLabelFunc,
buildPipelines: []string{"build"},
payloadPipelines: []string{"anaconda-tree", "rootfs-image", "efiboot-tree", "bootiso-tree", "bootiso"},
exports: []string{"bootiso"},
Expand Down Expand Up @@ -136,6 +137,7 @@ func edgeSimplifiedInstallerImgType(rd distribution) imageType {
bootable: true,
bootISO: true,
image: edgeSimplifiedInstallerImage,
isoLabel: distroISOLabelFunc,
buildPipelines: []string{"build"},
payloadPipelines: []string{"ostree-deployment", "image", "xz", "coi-tree", "efiboot-tree", "bootiso-tree", "bootiso"},
exports: []string{"bootiso"},
Expand Down
20 changes: 16 additions & 4 deletions pkg/distro/rhel8/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,13 @@ func imageInstallerImage(workload workload.Workload,
// put the kickstart file in the root of the iso
img.ISORootKickstart = true

d := t.arch.distro
var err error
img.ISOLabel, err = t.ISOLabel()
if err != nil {
return nil, err
}

img.ISOLabelTmpl = d.isolabelTmpl
d := t.arch.distro
img.Product = d.product
img.OSName = "redhat"
img.OSVersion = d.osVersion
Expand Down Expand Up @@ -461,7 +465,11 @@ func edgeInstallerImage(workload workload.Workload,
img.AdditionalAnacondaModules = []string{"org.fedoraproject.Anaconda.Modules.Users"}
}

img.ISOLabelTmpl = d.isolabelTmpl
img.ISOLabel, err = t.ISOLabel()
if err != nil {
return nil, err
}

img.Product = d.product
img.Variant = "edge"
img.OSName = "rhel"
Expand Down Expand Up @@ -585,8 +593,12 @@ func edgeSimplifiedInstallerImage(workload workload.Workload,
}
}

img.ISOLabel, err = t.ISOLabel()
if err != nil {
return nil, err
}

d := t.arch.distro
img.ISOLabelTmpl = d.isolabelTmpl
img.Product = d.product
img.Variant = "edge"
img.OSName = "redhat"
Expand Down
Loading
Loading