distro/fedora: add container image type
Add a container image type that is based on the existing fedora container image. There is a delta in terms of the configuration because osbuild does not yet provide all the neccessary means, but the package set is already very close.
This commit is contained in:
parent
59edcc4a46
commit
c5a5da5f56
13 changed files with 45265 additions and 4 deletions
|
|
@ -6,6 +6,7 @@ import (
|
|||
"io/ioutil"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
|
|
@ -202,6 +203,10 @@ func TestDistro_KernelOption(t *testing.T, d distro.Distro) {
|
|||
imgType, err := arch.GetImageType(typeName)
|
||||
assert.NoError(t, err)
|
||||
nk := kernelCount(imgType)
|
||||
// No kernel packages in containers
|
||||
if strings.HasSuffix(typeName, "container") {
|
||||
continue
|
||||
}
|
||||
// at least one kernel for general image types
|
||||
// exactly one kernel for OSTree commits
|
||||
if nk < 1 || (isOSTree(imgType) && nk != 1) {
|
||||
|
|
|
|||
|
|
@ -299,6 +299,30 @@ var (
|
|||
exports: []string{"image"},
|
||||
basePartitionTables: defaultBasePartitionTables,
|
||||
}
|
||||
|
||||
containerImgType = imageType{
|
||||
name: "container",
|
||||
filename: "container.tar",
|
||||
mimeType: "application/x-tar",
|
||||
packageSets: map[string]packageSetFunc{
|
||||
buildPkgsKey: distroBuildPackageSet,
|
||||
osPkgsKey: containerPackageSet,
|
||||
},
|
||||
packageSetChains: map[string][]string{
|
||||
osPkgsKey: {osPkgsKey, blueprintPkgsKey},
|
||||
},
|
||||
defaultImageConfig: &distro.ImageConfig{
|
||||
NoSElinux: true,
|
||||
ExcludeDocs: true,
|
||||
Locale: "C.UTF-8",
|
||||
Timezone: "Etc/UTC",
|
||||
},
|
||||
pipelines: containerPipelines,
|
||||
bootable: false,
|
||||
buildPipelines: []string{"build"},
|
||||
payloadPipelines: []string{"os", "container"},
|
||||
exports: []string{"container"},
|
||||
}
|
||||
)
|
||||
|
||||
type distribution struct {
|
||||
|
|
@ -571,7 +595,7 @@ func (t *imageType) PackageSets(bp blueprint.Blueprint, repos []rpmmd.RepoConfig
|
|||
}
|
||||
|
||||
// blueprint packages
|
||||
bpPackages := bp.GetPackagesEx(t.bootable)
|
||||
bpPackages := bp.GetPackagesEx(t.rpmOstree || t.bootable)
|
||||
timezone, _ := bp.Customizations.GetTimezoneSettings()
|
||||
if timezone != nil {
|
||||
bpPackages = append(bpPackages, "chrony")
|
||||
|
|
@ -579,7 +603,7 @@ func (t *imageType) PackageSets(bp blueprint.Blueprint, repos []rpmmd.RepoConfig
|
|||
|
||||
// if we have file system customization that will need to a new mount point
|
||||
// the layout is converted to LVM so we need to corresponding packages
|
||||
if !t.rpmOstree {
|
||||
if t.bootable && !t.rpmOstree {
|
||||
|
||||
pt, exists := t.basePartitionTables[t.arch.Name()]
|
||||
if !exists {
|
||||
|
|
@ -603,8 +627,11 @@ func (t *imageType) PackageSets(bp blueprint.Blueprint, repos []rpmmd.RepoConfig
|
|||
mergedSets[blueprintPkgsKey] = rpmmd.PackageSet{Include: bpPackages}
|
||||
kernel := bp.Customizations.GetKernel().Name
|
||||
|
||||
// add bp kernel to main OS package set to avoid duplicate kernels
|
||||
mergedSets[osPkgsKey] = mergedSets[osPkgsKey].Append(rpmmd.PackageSet{Include: []string{kernel}})
|
||||
// add bp kernel to main OS package set to avoid duplicate kernels,
|
||||
// but we don't want to add the kernel for the container artefact
|
||||
if t.rpmOstree || t.bootable {
|
||||
mergedSets[osPkgsKey] = mergedSets[osPkgsKey].Append(rpmmd.PackageSet{Include: []string{kernel}})
|
||||
}
|
||||
return distro.MakePackageSetChains(t, mergedSets, repos)
|
||||
|
||||
}
|
||||
|
|
@ -834,6 +861,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
|
||||
x86_64.addImageTypes(
|
||||
amiImgType,
|
||||
containerImgType,
|
||||
qcow2ImgType,
|
||||
openstackImgType,
|
||||
vhdImgType,
|
||||
|
|
@ -845,6 +873,7 @@ func newDistro(distroName string) distro.Distro {
|
|||
)
|
||||
aarch64.addImageTypes(
|
||||
amiImgType,
|
||||
containerImgType,
|
||||
qcow2ImgType,
|
||||
openstackImgType,
|
||||
ociImgType,
|
||||
|
|
|
|||
|
|
@ -114,6 +114,14 @@ func TestFilenameFromType(t *testing.T) {
|
|||
mimeType: "application/x-tar",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "container",
|
||||
args: args{"container"},
|
||||
want: wantResult{
|
||||
filename: "container.tar",
|
||||
mimeType: "application/x-tar",
|
||||
},
|
||||
},
|
||||
// Alias
|
||||
{
|
||||
name: "iot-container",
|
||||
|
|
@ -426,6 +434,7 @@ func TestArchitecture_ListImageTypes(t *testing.T) {
|
|||
"fedora-iot-container",
|
||||
"fedora-iot-installer",
|
||||
"oci",
|
||||
"container",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -438,6 +447,7 @@ func TestArchitecture_ListImageTypes(t *testing.T) {
|
|||
"fedora-iot-container",
|
||||
"fedora-iot-installer",
|
||||
"oci",
|
||||
"container",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -730,3 +730,64 @@ func anacondaPackageSet(t *imageType) rpmmd.PackageSet {
|
|||
func iotInstallerPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
return anacondaPackageSet(t)
|
||||
}
|
||||
|
||||
func containerPackageSet(t *imageType) rpmmd.PackageSet {
|
||||
ps := rpmmd.PackageSet{
|
||||
Include: []string{
|
||||
"bash",
|
||||
"coreutils",
|
||||
"dnf-yum",
|
||||
"dnf",
|
||||
"fedora-release-container",
|
||||
"fedora-repos-modular",
|
||||
"glibc-minimal-langpack",
|
||||
"rootfiles",
|
||||
"rpm",
|
||||
"sudo",
|
||||
"tar",
|
||||
"vim-minimal",
|
||||
},
|
||||
Exclude: []string{
|
||||
"crypto-policies-scripts",
|
||||
"dbus-broker",
|
||||
"deltarpm",
|
||||
"dosfstools",
|
||||
"e2fsprogs",
|
||||
"elfutils-debuginfod-client",
|
||||
"fuse-libs",
|
||||
"gawk-all-langpacks",
|
||||
"glibc-gconv-extra",
|
||||
"glibc-langpack-en",
|
||||
"gnupg2-smime",
|
||||
"grubby",
|
||||
"kernel-core",
|
||||
"kernel-debug-core",
|
||||
"kernel",
|
||||
"langpacks-en_GB",
|
||||
"langpacks-en",
|
||||
"libss",
|
||||
"libxcrypt-compat",
|
||||
"nano",
|
||||
"openssl-pkcs11",
|
||||
"pinentry",
|
||||
"python3-unbound",
|
||||
"shared-mime-info",
|
||||
"sssd-client",
|
||||
"sudo-python-plugin",
|
||||
"systemd",
|
||||
"trousers",
|
||||
"whois-nls",
|
||||
"xkeyboard-config",
|
||||
},
|
||||
}
|
||||
|
||||
// util-linux-core was created in Fedora 35 as a smaller
|
||||
// version of util-linux
|
||||
if t.arch.distro.releaseVersion == "34" {
|
||||
ps.Include = append(ps.Include, "util-linux")
|
||||
} else {
|
||||
ps.Include = append(ps.Include, "util-linux-core")
|
||||
}
|
||||
|
||||
return ps
|
||||
}
|
||||
|
|
|
|||
|
|
@ -348,3 +348,21 @@ func bootISOPipeline(buildPipeline *pipeline.BuildPipeline, treePipeline *pipeli
|
|||
p.ISOLinux = isolinux
|
||||
return p
|
||||
}
|
||||
|
||||
func containerPipelines(t *imageType, customizations *blueprint.Customizations, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSetSpecs map[string][]rpmmd.PackageSpec, rng *rand.Rand) ([]osbuild.Pipeline, error) {
|
||||
pipelines := make([]osbuild.Pipeline, 0)
|
||||
|
||||
buildPipeline := pipeline.NewBuildPipeline(t.arch.distro.runner, repos, packageSetSpecs[buildPkgsKey])
|
||||
pipelines = append(pipelines, buildPipeline.Serialize())
|
||||
|
||||
treePipeline, err := osPipeline(&buildPipeline, t, repos, packageSetSpecs[osPkgsKey], customizations, options, rng)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pipelines = append(pipelines, treePipeline.Serialize())
|
||||
|
||||
ociPipeline := pipeline.NewOCIContainerPipeline(&buildPipeline, &treePipeline.Pipeline, t.Arch().Name(), t.Filename())
|
||||
pipelines = append(pipelines, ociPipeline.Serialize())
|
||||
|
||||
return pipelines, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -374,6 +374,7 @@ var imageTypeCompatMapping = map[string]string{
|
|||
"oci": "oci",
|
||||
"gce": "GCP",
|
||||
"gce-rhui": "GCE RHUI",
|
||||
"container": "container",
|
||||
}
|
||||
|
||||
func imageTypeToCompatString(imgType distro.ImageType) string {
|
||||
|
|
|
|||
7427
test/data/manifests/fedora_34-aarch64-container-boot.json
Normal file
7427
test/data/manifests/fedora_34-aarch64-container-boot.json
Normal file
File diff suppressed because it is too large
Load diff
7490
test/data/manifests/fedora_34-x86_64-container-boot.json
Normal file
7490
test/data/manifests/fedora_34-x86_64-container-boot.json
Normal file
File diff suppressed because it is too large
Load diff
7463
test/data/manifests/fedora_35-aarch64-container-boot.json
Normal file
7463
test/data/manifests/fedora_35-aarch64-container-boot.json
Normal file
File diff suppressed because it is too large
Load diff
7526
test/data/manifests/fedora_35-x86_64-container-boot.json
Normal file
7526
test/data/manifests/fedora_35-x86_64-container-boot.json
Normal file
File diff suppressed because it is too large
Load diff
7559
test/data/manifests/fedora_36-aarch64-container-boot.json
Normal file
7559
test/data/manifests/fedora_36-aarch64-container-boot.json
Normal file
File diff suppressed because it is too large
Load diff
7661
test/data/manifests/fedora_36-x86_64-container-boot.json
Normal file
7661
test/data/manifests/fedora_36-x86_64-container-boot.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -28,6 +28,17 @@
|
|||
"x86_64"
|
||||
]
|
||||
},
|
||||
"container": {
|
||||
"compose-request": {
|
||||
"distro": "",
|
||||
"arch": "",
|
||||
"image-type": "container",
|
||||
"repositories": [],
|
||||
"filename": "container.tar",
|
||||
"blueprint": {}
|
||||
},
|
||||
"overrides": {}
|
||||
},
|
||||
"ec2": {
|
||||
"compose-request": {
|
||||
"distro": "",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue