distro/rhel85: const strings for package set keys

const string keys make the names easier to reuse or change and is less
error prone.
This commit is contained in:
Achilleas Koutsou 2021-07-13 16:45:54 +02:00 committed by Ondřej Budai
parent 5909ca202d
commit 8d64cb9665

View file

@ -18,6 +18,34 @@ const osVersion = "8.5"
const modulePlatformID = "platform:el8" const modulePlatformID = "platform:el8"
const ostreeRef = "rhel/8/%s/edge" const ostreeRef = "rhel/8/%s/edge"
const (
// package set names
// build package set name
buildPkgsKey = "build"
// bootable image package set name
bootPkgsKey = "boot"
// main/common os image package set name
osPkgsKey = "packages"
// edge os image package set name
edgePkgsKey = "edge"
// edge build package set name
edgeBuildPkgsKey = "build.edge"
// container package set name
containerPkgsKey = "container"
// installer package set name
installerPkgsKey = "installer"
// blueprint package set name
blueprintPkgsKey = "blueprint"
)
type distribution struct { type distribution struct {
name string name string
modulePlatformID string modulePlatformID string
@ -185,26 +213,26 @@ func (t *imageType) PackageSets(bp blueprint.Blueprint) map[string]rpmmd.Package
mergedSets[name] = imageSets[name].Append(archSets[name]).Append(distroSets[name]) mergedSets[name] = imageSets[name].Append(archSets[name]).Append(distroSets[name])
} }
if _, hasPackages := imageSets["packages"]; !hasPackages { if _, hasPackages := imageSets[osPkgsKey]; !hasPackages {
// should this be possible?? // should this be possible??
mergedSets["packages"] = rpmmd.PackageSet{} mergedSets[osPkgsKey] = rpmmd.PackageSet{}
} }
// build is usually not defined on the image type // build is usually not defined on the image type
// handle it explicitly when it's not // handle it explicitly when it's not
if _, hasBuild := imageSets["build"]; !hasBuild { if _, hasBuild := imageSets[buildPkgsKey]; !hasBuild {
mergedSets["build"] = archSets["build"].Append(distroSets["build"]) mergedSets[buildPkgsKey] = archSets[buildPkgsKey].Append(distroSets[buildPkgsKey])
} }
// package sets from flags // package sets from flags
if t.bootable { if t.bootable {
// add boot sets // add boot sets
mergedSets["packages"] = mergedSets["packages"].Append(archSets["boot"]).Append(distroSets["boot"]) mergedSets[osPkgsKey] = mergedSets[osPkgsKey].Append(archSets[bootPkgsKey]).Append(distroSets[bootPkgsKey])
} }
if t.rpmOstree { if t.rpmOstree {
// add ostree sets // add ostree sets
mergedSets["build"] = mergedSets["build"].Append(archSets["build.edge"]).Append(distroSets["build.edge"]) mergedSets[buildPkgsKey] = mergedSets[buildPkgsKey].Append(archSets[edgeBuildPkgsKey]).Append(distroSets[edgeBuildPkgsKey])
mergedSets["packages"] = mergedSets["packages"].Append(archSets["edge"]).Append(distroSets["edge"]) mergedSets[osPkgsKey] = mergedSets[osPkgsKey].Append(archSets[edgePkgsKey]).Append(distroSets[edgePkgsKey])
} }
// blueprint packages // blueprint packages
@ -216,7 +244,7 @@ func (t *imageType) PackageSets(bp blueprint.Blueprint) map[string]rpmmd.Package
// depsolve bp packages separately // depsolve bp packages separately
// bp packages aren't restricted by exclude lists // bp packages aren't restricted by exclude lists
mergedSets["blueprint"] = rpmmd.PackageSet{Include: bpPackages} mergedSets[blueprintPkgsKey] = rpmmd.PackageSet{Include: bpPackages}
return mergedSets return mergedSets
} }
@ -339,8 +367,8 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
modulePlatformID: modulePlatformID, modulePlatformID: modulePlatformID,
ostreeRef: ostreeRef, ostreeRef: ostreeRef,
packageSets: map[string]rpmmd.PackageSet{ packageSets: map[string]rpmmd.PackageSet{
"build": distroBuildPackageSet(), buildPkgsKey: distroBuildPackageSet(),
"build.edge": edgeBuildPackageSet(), edgeBuildPkgsKey: edgeBuildPackageSet(),
}, },
} }
@ -349,9 +377,9 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
name: "x86_64", name: "x86_64",
distro: rd, distro: rd,
packageSets: map[string]rpmmd.PackageSet{ packageSets: map[string]rpmmd.PackageSet{
"build": x8664BuildPackageSet(), buildPkgsKey: x8664BuildPackageSet(),
"boot": x8664BootPackageSet(), bootPkgsKey: x8664BootPackageSet(),
"edge": x8664EdgeCommitPackageSet(), edgePkgsKey: x8664EdgeCommitPackageSet(),
}, },
legacy: "i386-pc", legacy: "i386-pc",
uefi: true, uefi: true,
@ -361,8 +389,8 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
name: "aarch64", name: "aarch64",
distro: rd, distro: rd,
packageSets: map[string]rpmmd.PackageSet{ packageSets: map[string]rpmmd.PackageSet{
"boot": aarch64BootPackageSet(), bootPkgsKey: aarch64BootPackageSet(),
"edge": aarch64EdgeCommitPackageSet(), edgePkgsKey: aarch64EdgeCommitPackageSet(),
}, },
uefi: true, uefi: true,
} }
@ -371,8 +399,8 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
distro: rd, distro: rd,
name: "ppc64le", name: "ppc64le",
packageSets: map[string]rpmmd.PackageSet{ packageSets: map[string]rpmmd.PackageSet{
"boot": ppc64leBootPackageSet(), bootPkgsKey: ppc64leBootPackageSet(),
"build": ppc64leBuildPackageSet(), buildPkgsKey: ppc64leBuildPackageSet(),
}, },
legacy: "powerpc-ieee1275", legacy: "powerpc-ieee1275",
uefi: false, uefi: false,
@ -381,7 +409,7 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
distro: rd, distro: rd,
name: "s390x", name: "s390x",
packageSets: map[string]rpmmd.PackageSet{ packageSets: map[string]rpmmd.PackageSet{
"boot": s390xBootPackageSet(), bootPkgsKey: s390xBootPackageSet(),
}, },
uefi: false, uefi: false,
} }
@ -397,8 +425,8 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
filename: "commit.tar", filename: "commit.tar",
mimeType: "application/x-tar", mimeType: "application/x-tar",
packageSets: map[string]rpmmd.PackageSet{ packageSets: map[string]rpmmd.PackageSet{
"build": edgeBuildPackageSet(), buildPkgsKey: edgeBuildPackageSet(),
"packages": edgeCommitPackageSet(), osPkgsKey: edgeCommitPackageSet(),
}, },
enabledServices: edgeServices, enabledServices: edgeServices,
rpmOstree: true, rpmOstree: true,
@ -410,24 +438,24 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
filename: "container.tar", filename: "container.tar",
mimeType: "application/x-tar", mimeType: "application/x-tar",
packageSets: map[string]rpmmd.PackageSet{ packageSets: map[string]rpmmd.PackageSet{
"build": edgeBuildPackageSet(), buildPkgsKey: edgeBuildPackageSet(),
"packages": edgeCommitPackageSet(), osPkgsKey: edgeCommitPackageSet(),
"container": {Include: []string{"httpd"}}, containerPkgsKey: {Include: []string{"httpd"}},
}, },
enabledServices: edgeServices, enabledServices: edgeServices,
rpmOstree: true, rpmOstree: true,
bootISO: false, bootISO: false,
pipelines: edgeContainerPipelines, pipelines: edgeContainerPipelines,
exports: []string{"container"}, exports: []string{containerPkgsKey},
} }
edgeInstallerImgType := imageType{ edgeInstallerImgType := imageType{
name: "edge-installer", name: "edge-installer",
filename: "installer.iso", filename: "installer.iso",
mimeType: "application/x-iso9660-image", mimeType: "application/x-iso9660-image",
packageSets: map[string]rpmmd.PackageSet{ packageSets: map[string]rpmmd.PackageSet{
"build": edgeBuildPackageSet(), buildPkgsKey: edgeBuildPackageSet(),
"packages": edgeCommitPackageSet(), osPkgsKey: edgeCommitPackageSet(),
"installer": edgeInstallerPackageSet(), installerPkgsKey: edgeInstallerPackageSet(),
}, },
enabledServices: edgeServices, enabledServices: edgeServices,
rpmOstree: true, rpmOstree: true,
@ -443,7 +471,7 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
defaultTarget: "multi-user.target", defaultTarget: "multi-user.target",
kernelOptions: "console=tty0 console=ttyS0,115200n8 no_timer_check net.ifnames=0 crashkernel=auto", kernelOptions: "console=tty0 console=ttyS0,115200n8 no_timer_check net.ifnames=0 crashkernel=auto",
packageSets: map[string]rpmmd.PackageSet{ packageSets: map[string]rpmmd.PackageSet{
"packages": qcow2CommonPackageSet(), osPkgsKey: qcow2CommonPackageSet(),
}, },
bootable: true, bootable: true,
defaultSize: 10 * GigaByte, defaultSize: 10 * GigaByte,
@ -456,7 +484,7 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
filename: "disk.vhd", filename: "disk.vhd",
mimeType: "application/x-vhd", mimeType: "application/x-vhd",
packageSets: map[string]rpmmd.PackageSet{ packageSets: map[string]rpmmd.PackageSet{
"packages": vhdCommonPackageSet(), osPkgsKey: vhdCommonPackageSet(),
}, },
enabledServices: []string{ enabledServices: []string{
"sshd", "sshd",
@ -475,7 +503,7 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
filename: "disk.vmdk", filename: "disk.vmdk",
mimeType: "application/x-vmdk", mimeType: "application/x-vmdk",
packageSets: map[string]rpmmd.PackageSet{ packageSets: map[string]rpmmd.PackageSet{
"packages": vmdkCommonPackageSet(), osPkgsKey: vmdkCommonPackageSet(),
}, },
kernelOptions: "ro net.ifnames=0", kernelOptions: "ro net.ifnames=0",
bootable: true, bootable: true,
@ -489,7 +517,7 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
filename: "disk.qcow2", filename: "disk.qcow2",
mimeType: "application/x-qemu-disk", mimeType: "application/x-qemu-disk",
packageSets: map[string]rpmmd.PackageSet{ packageSets: map[string]rpmmd.PackageSet{
"packages": openstackCommonPackageSet(), osPkgsKey: openstackCommonPackageSet(),
}, },
kernelOptions: "ro net.ifnames=0", kernelOptions: "ro net.ifnames=0",
bootable: true, bootable: true,
@ -503,7 +531,7 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
filename: "image.raw", filename: "image.raw",
mimeType: "application/octet-stream", mimeType: "application/octet-stream",
packageSets: map[string]rpmmd.PackageSet{ packageSets: map[string]rpmmd.PackageSet{
"packages": amiCommonPackageSet(), osPkgsKey: amiCommonPackageSet(),
}, },
defaultTarget: "multi-user.target", defaultTarget: "multi-user.target",
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto", kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto",
@ -518,7 +546,7 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
filename: "root.tar.xz", filename: "root.tar.xz",
mimeType: "application/x-tar", mimeType: "application/x-tar",
packageSets: map[string]rpmmd.PackageSet{ packageSets: map[string]rpmmd.PackageSet{
"packages": { osPkgsKey: {
Include: []string{"policycoreutils", "selinux-policy-targeted"}, Include: []string{"policycoreutils", "selinux-policy-targeted"},
Exclude: []string{"rng-tools"}, Exclude: []string{"rng-tools"},
}, },
@ -531,12 +559,12 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
filename: "installer.iso", filename: "installer.iso",
mimeType: "application/x-iso9660-image", mimeType: "application/x-iso9660-image",
packageSets: map[string]rpmmd.PackageSet{ packageSets: map[string]rpmmd.PackageSet{
"build": x8664InstallerBuildPackageSet(), buildPkgsKey: x8664InstallerBuildPackageSet(),
"packages": { osPkgsKey: {
Include: []string{"lvm2", "policycoreutils", "selinux-policy-targeted"}, Include: []string{"lvm2", "policycoreutils", "selinux-policy-targeted"},
Exclude: []string{"rng-tools"}, Exclude: []string{"rng-tools"},
}, },
"installer": installerPackageSet(), installerPkgsKey: installerPackageSet(),
}, },
rpmOstree: false, rpmOstree: false,
bootISO: true, bootISO: true,