Skip to content

Commit

Permalink
distro/fedora: add minimum directory sizes to image types
Browse files Browse the repository at this point in the history
For all image types that don't specify a requiredPartitionSizes, add the
defaults that are used in the NewPartitionTable() so that
NewCustomPartitionTable() has similar behaviour.

The only image type that explicitly doesn't specify minimum sizes is the
iot-raw-image, which has a pre-existing empty map.
  • Loading branch information
achilleas-k authored and mvo5 committed Nov 20, 2024
1 parent 8da48fb commit bb93c0b
Showing 1 changed file with 120 additions and 100 deletions.
220 changes: 120 additions & 100 deletions pkg/distro/fedora/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ var (
oscap.Standard,
}

// Default directory size minimums for all image types.
requiredDirectorySizes = map[string]uint64{
"/": 1 * datasizes.GiB,
"/usr": 2 * datasizes.GiB,
}

// Services
iotServices = []string{
"NetworkManager.service",
Expand Down Expand Up @@ -92,10 +98,11 @@ var (
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"},
isoLabel: getISOLabelFunc("Unknown"),
buildPipelines: []string{"build"},
payloadPipelines: []string{"anaconda-tree", "rootfs-image", "efiboot-tree", "os", "bootiso-tree", "bootiso"},
exports: []string{"bootiso"},
requiredPartitionSizes: requiredDirectorySizes,
}

liveInstallerImgType = imageType{
Expand All @@ -106,14 +113,15 @@ var (
packageSets: map[string]packageSetFunc{
installerPkgsKey: liveInstallerPackageSet,
},
bootable: true,
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"},
bootable: true,
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"},
requiredPartitionSizes: requiredDirectorySizes,
}

iotCommitImgType = imageType{
Expand All @@ -128,11 +136,12 @@ var (
EnabledServices: iotServices,
DracutConf: []*osbuild.DracutConfStageOptions{osbuild.FIPSDracutConfStageOptions},
},
rpmOstree: true,
image: iotCommitImage,
buildPipelines: []string{"build"},
payloadPipelines: []string{"os", "ostree-commit", "commit-archive"},
exports: []string{"commit-archive"},
rpmOstree: true,
image: iotCommitImage,
buildPipelines: []string{"build"},
payloadPipelines: []string{"os", "ostree-commit", "commit-archive"},
exports: []string{"commit-archive"},
requiredPartitionSizes: requiredDirectorySizes,
}

iotBootableContainer = imageType{
Expand All @@ -142,11 +151,12 @@ var (
packageSets: map[string]packageSetFunc{
osPkgsKey: bootableContainerPackageSet,
},
rpmOstree: true,
image: bootableContainerImage,
buildPipelines: []string{"build"},
payloadPipelines: []string{"os", "ostree-commit", "ostree-encapsulate"},
exports: []string{"ostree-encapsulate"},
rpmOstree: true,
image: bootableContainerImage,
buildPipelines: []string{"build"},
payloadPipelines: []string{"os", "ostree-commit", "ostree-encapsulate"},
exports: []string{"ostree-encapsulate"},
requiredPartitionSizes: requiredDirectorySizes,
}

iotOCIImgType = imageType{
Expand All @@ -164,12 +174,13 @@ var (
EnabledServices: iotServices,
DracutConf: []*osbuild.DracutConfStageOptions{osbuild.FIPSDracutConfStageOptions},
},
rpmOstree: true,
bootISO: false,
image: iotContainerImage,
buildPipelines: []string{"build"},
payloadPipelines: []string{"os", "ostree-commit", "container-tree", "container"},
exports: []string{"container"},
rpmOstree: true,
bootISO: false,
image: iotContainerImage,
buildPipelines: []string{"build"},
payloadPipelines: []string{"os", "ostree-commit", "container-tree", "container"},
exports: []string{"container"},
requiredPartitionSizes: requiredDirectorySizes,
}

iotInstallerImgType = imageType{
Expand All @@ -184,13 +195,14 @@ var (
Locale: common.ToPtr("en_US.UTF-8"),
EnabledServices: iotServices,
},
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"},
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"},
requiredPartitionSizes: requiredDirectorySizes,
}

iotSimplifiedInstallerImgType = imageType{
Expand All @@ -210,17 +222,18 @@ var (
LockRootUser: common.ToPtr(true),
IgnitionPlatform: common.ToPtr("metal"),
},
defaultSize: 10 * datasizes.GibiByte,
rpmOstree: true,
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"},
basePartitionTables: iotSimplifiedInstallerPartitionTables,
kernelOptions: ostreeDeploymentKernelOptions,
defaultSize: 10 * datasizes.GibiByte,
rpmOstree: true,
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"},
basePartitionTables: iotSimplifiedInstallerPartitionTables,
kernelOptions: ostreeDeploymentKernelOptions,
requiredPartitionSizes: requiredDirectorySizes,
}

iotRawImgType = imageType{
Expand Down Expand Up @@ -269,15 +282,16 @@ var (
LockRootUser: common.ToPtr(true),
IgnitionPlatform: common.ToPtr("qemu"),
},
defaultSize: 10 * datasizes.GibiByte,
rpmOstree: true,
bootable: true,
image: iotImage,
buildPipelines: []string{"build"},
payloadPipelines: []string{"ostree-deployment", "image", "qcow2"},
exports: []string{"qcow2"},
basePartitionTables: iotBasePartitionTables,
kernelOptions: ostreeDeploymentKernelOptions,
defaultSize: 10 * datasizes.GibiByte,
rpmOstree: true,
bootable: true,
image: iotImage,
buildPipelines: []string{"build"},
payloadPipelines: []string{"ostree-deployment", "image", "qcow2"},
exports: []string{"qcow2"},
basePartitionTables: iotBasePartitionTables,
kernelOptions: ostreeDeploymentKernelOptions,
requiredPartitionSizes: requiredDirectorySizes,
}

qcow2ImgType = imageType{
Expand All @@ -291,14 +305,15 @@ var (
defaultImageConfig: &distro.ImageConfig{
DefaultTarget: common.ToPtr("multi-user.target"),
},
kernelOptions: cloudKernelOptions,
bootable: true,
defaultSize: 5 * datasizes.GibiByte,
image: diskImage,
buildPipelines: []string{"build"},
payloadPipelines: []string{"os", "image", "qcow2"},
exports: []string{"qcow2"},
basePartitionTables: defaultBasePartitionTables,
kernelOptions: cloudKernelOptions,
bootable: true,
defaultSize: 5 * datasizes.GibiByte,
image: diskImage,
buildPipelines: []string{"build"},
payloadPipelines: []string{"os", "image", "qcow2"},
exports: []string{"qcow2"},
basePartitionTables: defaultBasePartitionTables,
requiredPartitionSizes: requiredDirectorySizes,
}

vmdkDefaultImageConfig = &distro.ImageConfig{
Expand All @@ -318,15 +333,16 @@ var (
packageSets: map[string]packageSetFunc{
osPkgsKey: vmdkCommonPackageSet,
},
defaultImageConfig: vmdkDefaultImageConfig,
kernelOptions: cloudKernelOptions,
bootable: true,
defaultSize: 2 * datasizes.GibiByte,
image: diskImage,
buildPipelines: []string{"build"},
payloadPipelines: []string{"os", "image", "vmdk"},
exports: []string{"vmdk"},
basePartitionTables: defaultBasePartitionTables,
defaultImageConfig: vmdkDefaultImageConfig,
kernelOptions: cloudKernelOptions,
bootable: true,
defaultSize: 2 * datasizes.GibiByte,
image: diskImage,
buildPipelines: []string{"build"},
payloadPipelines: []string{"os", "image", "vmdk"},
exports: []string{"vmdk"},
basePartitionTables: defaultBasePartitionTables,
requiredPartitionSizes: requiredDirectorySizes,
}

ovaImgType = imageType{
Expand All @@ -336,15 +352,16 @@ var (
packageSets: map[string]packageSetFunc{
osPkgsKey: vmdkCommonPackageSet,
},
defaultImageConfig: vmdkDefaultImageConfig,
kernelOptions: cloudKernelOptions,
bootable: true,
defaultSize: 2 * datasizes.GibiByte,
image: diskImage,
buildPipelines: []string{"build"},
payloadPipelines: []string{"os", "image", "vmdk", "ovf", "archive"},
exports: []string{"archive"},
basePartitionTables: defaultBasePartitionTables,
defaultImageConfig: vmdkDefaultImageConfig,
kernelOptions: cloudKernelOptions,
bootable: true,
defaultSize: 2 * datasizes.GibiByte,
image: diskImage,
buildPipelines: []string{"build"},
payloadPipelines: []string{"os", "image", "vmdk", "ovf", "archive"},
exports: []string{"archive"},
basePartitionTables: defaultBasePartitionTables,
requiredPartitionSizes: requiredDirectorySizes,
}

containerImgType = imageType{
Expand All @@ -360,11 +377,12 @@ var (
Locale: common.ToPtr("C.UTF-8"),
Timezone: common.ToPtr("Etc/UTC"),
},
image: containerImage,
bootable: false,
buildPipelines: []string{"build"},
payloadPipelines: []string{"os", "container"},
exports: []string{"container"},
image: containerImage,
bootable: false,
buildPipelines: []string{"build"},
payloadPipelines: []string{"os", "container"},
exports: []string{"container"},
requiredPartitionSizes: requiredDirectorySizes,
}

wslImgType = imageType{
Expand All @@ -385,11 +403,12 @@ var (
},
},
},
image: containerImage,
bootable: false,
buildPipelines: []string{"build"},
payloadPipelines: []string{"os", "container"},
exports: []string{"container"},
image: containerImage,
bootable: false,
buildPipelines: []string{"build"},
payloadPipelines: []string{"os", "container"},
exports: []string{"container"},
requiredPartitionSizes: requiredDirectorySizes,
}

minimalrawImgType = imageType{
Expand All @@ -410,15 +429,16 @@ var (
Timeout: 5,
},
},
rpmOstree: false,
kernelOptions: defaultKernelOptions,
bootable: true,
defaultSize: 2 * datasizes.GibiByte,
image: diskImage,
buildPipelines: []string{"build"},
payloadPipelines: []string{"os", "image", "xz"},
exports: []string{"xz"},
basePartitionTables: minimalrawPartitionTables,
rpmOstree: false,
kernelOptions: defaultKernelOptions,
bootable: true,
defaultSize: 2 * datasizes.GibiByte,
image: diskImage,
buildPipelines: []string{"build"},
payloadPipelines: []string{"os", "image", "xz"},
exports: []string{"xz"},
basePartitionTables: minimalrawPartitionTables,
requiredPartitionSizes: requiredDirectorySizes,
}
)

Expand Down

0 comments on commit bb93c0b

Please sign in to comment.