distro/ImageType: let PackageSets depend on ImageOptions
The package sets for an image can depend on the blueprint, and by the same logic there is no reason it should not be able to depend on the image options. This is so far a non-functional change, but makes a follow-up commit simpler (though still without actually depending on the image options to compute the package sets).
This commit is contained in:
parent
1cb2f0276d
commit
be5ea6a9b8
23 changed files with 141 additions and 72 deletions
|
|
@ -117,7 +117,7 @@ func makeManifestJob(name string, imgType distro.ImageType, cr composeRequest, d
|
|||
bp = blueprint.Blueprint(*cr.Blueprint)
|
||||
}
|
||||
|
||||
packageSpecs, err := depsolve(cacheDir, imgType, bp, repos, distribution, archName)
|
||||
packageSpecs, err := depsolve(cacheDir, imgType, bp, options, repos, distribution, archName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("[%s] depsolve failed: %s", filename, err.Error())
|
||||
}
|
||||
|
|
@ -187,10 +187,10 @@ func readRepos() DistroArchRepoMap {
|
|||
return darm
|
||||
}
|
||||
|
||||
func depsolve(cacheDir string, imageType distro.ImageType, bp blueprint.Blueprint, repos []rpmmd.RepoConfig, d distro.Distro, arch string) (map[string][]rpmmd.PackageSpec, error) {
|
||||
func depsolve(cacheDir string, imageType distro.ImageType, bp blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig, d distro.Distro, arch string) (map[string][]rpmmd.PackageSpec, error) {
|
||||
solver := dnfjson.NewSolver(d.ModulePlatformID(), d.Releasever(), arch, cacheDir)
|
||||
solver.SetDNFJSONPath("./dnf-json")
|
||||
packageSets := imageType.PackageSets(bp, repos)
|
||||
packageSets := imageType.PackageSets(bp, options, repos)
|
||||
depsolvedSets := make(map[string][]rpmmd.PackageSpec)
|
||||
for name, pkgSet := range packageSets {
|
||||
res, err := solver.Depsolve(pkgSet)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
// This package contains tests related to dnf-json and rpmmd package.
|
||||
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
package main
|
||||
|
|
@ -15,6 +16,7 @@ import (
|
|||
"github.com/osbuild/osbuild-composer/internal/distro/fedora"
|
||||
rhel "github.com/osbuild/osbuild-composer/internal/distro/rhel8"
|
||||
"github.com/osbuild/osbuild-composer/internal/dnfjson"
|
||||
"github.com/osbuild/osbuild-composer/internal/ostree"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
)
|
||||
|
||||
|
|
@ -49,7 +51,15 @@ func TestCrossArchDepsolve(t *testing.T) {
|
|||
imgType, err := arch.GetImageType(imgTypeStr)
|
||||
require.NoError(t, err)
|
||||
|
||||
packages := imgType.PackageSets(blueprint.Blueprint{}, repos[archStr])
|
||||
packages := imgType.PackageSets(blueprint.Blueprint{},
|
||||
distro.ImageOptions{
|
||||
OSTree: ostree.RequestParams{
|
||||
URL: "foo",
|
||||
Ref: "bar",
|
||||
Parent: "baz",
|
||||
},
|
||||
},
|
||||
repos[archStr])
|
||||
|
||||
for _, set := range packages {
|
||||
_, err = solver.Depsolve(set)
|
||||
|
|
@ -92,7 +102,7 @@ func TestDepsolvePackageSets(t *testing.T) {
|
|||
qcow2Image, err := x86Arch.GetImageType(qcow2ImageTypeName)
|
||||
require.Nilf(t, err, "failed to get %q image type of %q/%q distro/arch", qcow2ImageTypeName, distroStruct.Name(), distro.X86_64ArchName)
|
||||
|
||||
imagePkgSets := qcow2Image.PackageSets(blueprint.Blueprint{Packages: []blueprint.Package{{Name: "bind"}}}, x86Repos)
|
||||
imagePkgSets := qcow2Image.PackageSets(blueprint.Blueprint{Packages: []blueprint.Package{{Name: "bind"}}}, distro.ImageOptions{}, x86Repos)
|
||||
imagePkgSetChains := qcow2Image.PackageSetsChains()
|
||||
require.NotEmptyf(t, imagePkgSetChains, "the %q image has no package set chains defined", qcow2ImageTypeName)
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
"github.com/osbuild/osbuild-composer/internal/distroregistry"
|
||||
"github.com/osbuild/osbuild-composer/internal/ostree"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -29,12 +31,12 @@ func main() {
|
|||
|
||||
dr := distroregistry.NewDefault()
|
||||
|
||||
distro := dr.GetDistro(distroName)
|
||||
if distro == nil {
|
||||
d := dr.GetDistro(distroName)
|
||||
if d == nil {
|
||||
panic(fmt.Errorf("Distro %q does not exist", distroName))
|
||||
}
|
||||
|
||||
arch, err := distro.GetArch(archName)
|
||||
arch, err := d.GetArch(archName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
@ -46,6 +48,12 @@ func main() {
|
|||
|
||||
encoder := json.NewEncoder(os.Stdout)
|
||||
encoder.SetIndent("", " ")
|
||||
pkgset := image.PackageSets(blueprint.Blueprint{}, nil)
|
||||
pkgset := image.PackageSets(blueprint.Blueprint{}, distro.ImageOptions{
|
||||
OSTree: ostree.RequestParams{
|
||||
URL: "foo",
|
||||
Ref: "bar",
|
||||
Parent: "baz",
|
||||
},
|
||||
}, nil)
|
||||
_ = encoder.Encode(pkgset)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ import (
|
|||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
"github.com/osbuild/osbuild-composer/internal/distroregistry"
|
||||
"github.com/osbuild/osbuild-composer/internal/dnfjson"
|
||||
"github.com/osbuild/osbuild-composer/internal/ostree"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
)
|
||||
|
||||
|
|
@ -137,6 +137,20 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
if composeRequest.OSTree.Ref == "" {
|
||||
// use default OSTreeRef for image type
|
||||
composeRequest.OSTree.Ref = imageType.OSTreeRef()
|
||||
}
|
||||
|
||||
options := distro.ImageOptions{
|
||||
Size: imageType.Size(0),
|
||||
OSTree: ostree.RequestParams{
|
||||
Ref: composeRequest.OSTree.Ref,
|
||||
Parent: composeRequest.OSTree.Parent,
|
||||
URL: composeRequest.OSTree.URL,
|
||||
},
|
||||
}
|
||||
|
||||
home, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
panic("os.UserHomeDir(): " + err.Error())
|
||||
|
|
@ -150,7 +164,7 @@ func main() {
|
|||
// let the cache grow to fit much more repository metadata than we usually allow
|
||||
solver.SetMaxCacheSize(3 * 1024 * 1024 * 1024)
|
||||
|
||||
packageSets := imageType.PackageSets(composeRequest.Blueprint, repos)
|
||||
packageSets := imageType.PackageSets(composeRequest.Blueprint, options, repos)
|
||||
depsolvedSets := make(map[string][]rpmmd.PackageSpec)
|
||||
|
||||
for name, pkgSet := range packageSets {
|
||||
|
|
@ -168,21 +182,8 @@ func main() {
|
|||
panic(err)
|
||||
}
|
||||
} else {
|
||||
|
||||
if composeRequest.OSTree.Ref == "" {
|
||||
// use default OSTreeRef for image type
|
||||
composeRequest.OSTree.Ref = imageType.OSTreeRef()
|
||||
}
|
||||
|
||||
manifest, err := imageType.Manifest(composeRequest.Blueprint.Customizations,
|
||||
distro.ImageOptions{
|
||||
Size: imageType.Size(0),
|
||||
OSTree: ostree.RequestParams{
|
||||
Ref: composeRequest.OSTree.Ref,
|
||||
Parent: composeRequest.OSTree.Parent,
|
||||
URL: composeRequest.OSTree.URL,
|
||||
},
|
||||
},
|
||||
options,
|
||||
repos,
|
||||
depsolvedSets,
|
||||
seedArg)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import (
|
|||
)
|
||||
|
||||
func getManifest(bp blueprint.Blueprint, t distro.ImageType, a distro.Arch, d distro.Distro, cacheDir string, repos []rpmmd.RepoConfig) (distro.Manifest, []rpmmd.PackageSpec) {
|
||||
packageSets := t.PackageSets(bp, repos)
|
||||
packageSets := t.PackageSets(bp, distro.ImageOptions{}, repos)
|
||||
pkgSpecSets := make(map[string][]rpmmd.PackageSpec)
|
||||
solver := dnfjson.NewSolver(d.ModulePlatformID(), d.Releasever(), a.Name(), cacheDir)
|
||||
for name, packages := range packageSets {
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ func (s *Server) enqueueCompose(distribution distro.Distro, bp blueprint.Bluepri
|
|||
ir := irs[0]
|
||||
|
||||
depsolveJobID, err := s.workers.EnqueueDepsolve(&worker.DepsolveJob{
|
||||
PackageSets: ir.imageType.PackageSets(bp, ir.repositories),
|
||||
PackageSets: ir.imageType.PackageSets(bp, ir.imageOptions, ir.repositories),
|
||||
ModulePlatformID: distribution.ModulePlatformID(),
|
||||
Arch: ir.arch.Name(),
|
||||
Releasever: distribution.Releasever(),
|
||||
|
|
@ -155,7 +155,7 @@ func (s *Server) enqueueKojiCompose(taskID uint64, server, name, version, releas
|
|||
var buildIDs []uuid.UUID
|
||||
for _, ir := range irs {
|
||||
depsolveJobID, err := s.workers.EnqueueDepsolve(&worker.DepsolveJob{
|
||||
PackageSets: ir.imageType.PackageSets(bp, ir.repositories),
|
||||
PackageSets: ir.imageType.PackageSets(bp, ir.imageOptions, ir.repositories),
|
||||
ModulePlatformID: distribution.ModulePlatformID(),
|
||||
Arch: ir.arch.Name(),
|
||||
Releasever: distribution.Releasever(),
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ type ImageType interface {
|
|||
// Returns the sets of packages to include and exclude when building the image.
|
||||
// Indexed by a string label. How each set is labeled and used depends on the
|
||||
// image type.
|
||||
PackageSets(bp blueprint.Blueprint, repos []rpmmd.RepoConfig) map[string][]rpmmd.PackageSet
|
||||
PackageSets(bp blueprint.Blueprint, options ImageOptions, repos []rpmmd.RepoConfig) map[string][]rpmmd.PackageSet
|
||||
|
||||
// Returns the names of the pipelines that set up the build environment (buildroot).
|
||||
BuildPipelines() []string
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/distro_test_common"
|
||||
"github.com/osbuild/osbuild-composer/internal/distroregistry"
|
||||
"github.com/osbuild/osbuild-composer/internal/ostree"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
|
@ -116,7 +117,13 @@ func TestImageType_PackageSetsChains(t *testing.T) {
|
|||
imageType, err := arch.GetImageType(imageTypeName)
|
||||
require.Nil(t, err)
|
||||
|
||||
imagePkgSets := imageType.PackageSets(blueprint.Blueprint{}, nil)
|
||||
imagePkgSets := imageType.PackageSets(blueprint.Blueprint{}, distro.ImageOptions{
|
||||
OSTree: ostree.RequestParams{
|
||||
URL: "foo",
|
||||
Ref: "bar",
|
||||
Parent: "baz",
|
||||
},
|
||||
}, nil)
|
||||
for packageSetName := range imageType.PackageSetsChains() {
|
||||
_, ok := imagePkgSets[packageSetName]
|
||||
assert.Truef(t, ok, "package set %q defined in a package set chain is not present in the image package sets", packageSetName)
|
||||
|
|
|
|||
|
|
@ -96,6 +96,13 @@ func TestDistro_Manifest(t *testing.T, pipelinePath string, prefix string, regis
|
|||
imgPackageSpecSets = getImageTypePkgSpecSets(
|
||||
imageType,
|
||||
*tt.ComposeRequest.Blueprint,
|
||||
distro.ImageOptions{
|
||||
OSTree: ostree.RequestParams{
|
||||
URL: "foo",
|
||||
Ref: "bar",
|
||||
Parent: "baz",
|
||||
},
|
||||
},
|
||||
repos,
|
||||
dnfCacheDir,
|
||||
dnfJsonPath,
|
||||
|
|
@ -138,8 +145,8 @@ func TestDistro_Manifest(t *testing.T, pipelinePath string, prefix string, regis
|
|||
}
|
||||
}
|
||||
|
||||
func getImageTypePkgSpecSets(imageType distro.ImageType, bp blueprint.Blueprint, repos []rpmmd.RepoConfig, cacheDir, dnfJsonPath string) map[string][]rpmmd.PackageSpec {
|
||||
imgPackageSets := imageType.PackageSets(bp, repos)
|
||||
func getImageTypePkgSpecSets(imageType distro.ImageType, bp blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig, cacheDir, dnfJsonPath string) map[string][]rpmmd.PackageSpec {
|
||||
imgPackageSets := imageType.PackageSets(bp, options, repos)
|
||||
|
||||
solver := dnfjson.NewSolver(imageType.Arch().Distro().ModulePlatformID(), imageType.Arch().Distro().Releasever(), imageType.Arch().Name(), cacheDir)
|
||||
depsolvedSets := make(map[string][]rpmmd.PackageSpec)
|
||||
|
|
@ -155,7 +162,13 @@ func getImageTypePkgSpecSets(imageType distro.ImageType, bp blueprint.Blueprint,
|
|||
}
|
||||
|
||||
func isOSTree(imgType distro.ImageType) bool {
|
||||
packageSets := imgType.PackageSets(blueprint.Blueprint{}, nil)
|
||||
packageSets := imgType.PackageSets(blueprint.Blueprint{}, distro.ImageOptions{
|
||||
OSTree: ostree.RequestParams{
|
||||
URL: "foo",
|
||||
Ref: "bar",
|
||||
Parent: "baz",
|
||||
},
|
||||
}, nil)
|
||||
for _, set := range packageSets["build-packages"] {
|
||||
for _, pkg := range set.Include {
|
||||
if pkg == "rpm-ostree" {
|
||||
|
|
@ -170,7 +183,13 @@ var knownKernels = []string{"kernel", "kernel-debug", "kernel-rt"}
|
|||
|
||||
// Returns the number of known kernels in the package list
|
||||
func kernelCount(imgType distro.ImageType) int {
|
||||
sets := imgType.PackageSets(blueprint.Blueprint{}, nil)
|
||||
sets := imgType.PackageSets(blueprint.Blueprint{}, distro.ImageOptions{
|
||||
OSTree: ostree.RequestParams{
|
||||
URL: "foo",
|
||||
Ref: "bar",
|
||||
Parent: "baz",
|
||||
},
|
||||
}, nil)
|
||||
n := 0
|
||||
for _, pset := range sets["packages"] {
|
||||
for _, pkg := range pset.Include {
|
||||
|
|
@ -182,6 +201,7 @@ func kernelCount(imgType distro.ImageType) int {
|
|||
|
||||
}
|
||||
}
|
||||
// TODO: is this not included in the above?
|
||||
for _, bset := range sets["blueprint"] {
|
||||
for _, pkg := range bset.Include {
|
||||
for _, kernel := range knownKernels {
|
||||
|
|
@ -192,16 +212,23 @@ func kernelCount(imgType distro.ImageType) int {
|
|||
|
||||
}
|
||||
}
|
||||
m := 0
|
||||
for _, iset := range sets["installer"] {
|
||||
for _, pkg := range iset.Include {
|
||||
for _, kernel := range knownKernels {
|
||||
if kernel == pkg {
|
||||
n++
|
||||
m++
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// TODO: fix this! some installers mistakenly include other
|
||||
// package sets. These are however not used in building the image
|
||||
// until this is fixed, count the installers separately.
|
||||
if m > 0 {
|
||||
return m
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
|
|
@ -260,8 +287,20 @@ func GetTestingPackageSpecSets(packageName, arch string, pkgSetNames []string) m
|
|||
// defined by the provided ImageType, which is useful for unit testing.
|
||||
func GetTestingImagePackageSpecSets(packageName string, i distro.ImageType) map[string][]rpmmd.PackageSpec {
|
||||
arch := i.Arch().Name()
|
||||
imagePackageSets := make([]string, 0, len(i.PackageSets(blueprint.Blueprint{}, nil)))
|
||||
for pkgSetName := range i.PackageSets(blueprint.Blueprint{}, nil) {
|
||||
imagePackageSets := make([]string, 0, len(i.PackageSets(blueprint.Blueprint{}, distro.ImageOptions{
|
||||
OSTree: ostree.RequestParams{
|
||||
URL: "foo",
|
||||
Ref: "bar",
|
||||
Parent: "baz",
|
||||
},
|
||||
}, nil)))
|
||||
for pkgSetName := range i.PackageSets(blueprint.Blueprint{}, distro.ImageOptions{
|
||||
OSTree: ostree.RequestParams{
|
||||
URL: "foo",
|
||||
Ref: "bar",
|
||||
Parent: "baz",
|
||||
},
|
||||
}, nil) {
|
||||
imagePackageSets = append(imagePackageSets, pkgSetName)
|
||||
}
|
||||
return GetTestingPackageSpecSets(packageName, arch, imagePackageSets)
|
||||
|
|
|
|||
|
|
@ -567,7 +567,7 @@ func (t *imageType) getPackages(name string) rpmmd.PackageSet {
|
|||
return getter(t)
|
||||
}
|
||||
|
||||
func (t *imageType) PackageSets(bp blueprint.Blueprint, repos []rpmmd.RepoConfig) map[string][]rpmmd.PackageSet {
|
||||
func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig) map[string][]rpmmd.PackageSet {
|
||||
// merge package sets that appear in the image type with the package sets
|
||||
// of the same name from the distro and arch
|
||||
mergedSets := make(map[string]rpmmd.PackageSet)
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ func TestImageType_BuildPackages(t *testing.T) {
|
|||
if assert.NoErrorf(t, err, "d.GetArch(%v) returned err = %v; expected nil", archLabel, err) {
|
||||
continue
|
||||
}
|
||||
buildPkgs := itStruct.PackageSets(blueprint.Blueprint{}, nil)["build"]
|
||||
buildPkgs := itStruct.PackageSets(blueprint.Blueprint{}, distro.ImageOptions{}, nil)["build"]
|
||||
assert.NotNil(t, buildPkgs)
|
||||
assert.Len(t, buildPkgs, 1)
|
||||
assert.ElementsMatch(t, buildPackages[archLabel], buildPkgs[0].Include)
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ func (t *imageType) getPackages(name string) rpmmd.PackageSet {
|
|||
return getter(t)
|
||||
}
|
||||
|
||||
func (t *imageType) PackageSets(bp blueprint.Blueprint, repos []rpmmd.RepoConfig) map[string][]rpmmd.PackageSet {
|
||||
func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig) map[string][]rpmmd.PackageSet {
|
||||
// merge package sets that appear in the image type with the package sets
|
||||
// of the same name from the distro and arch
|
||||
mergedSets := make(map[string]rpmmd.PackageSet)
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ func TestImageType_BuildPackages(t *testing.T) {
|
|||
if assert.NoErrorf(t, err, "d.GetArch(%v) returned err = %v; expected nil", archLabel, err) {
|
||||
continue
|
||||
}
|
||||
buildPkgs := itStruct.PackageSets(blueprint.Blueprint{}, nil)["build"]
|
||||
buildPkgs := itStruct.PackageSets(blueprint.Blueprint{}, distro.ImageOptions{}, nil)["build"]
|
||||
assert.NotNil(t, buildPkgs)
|
||||
assert.Len(t, buildPkgs, 1)
|
||||
assert.ElementsMatch(t, buildPackages[archLabel], buildPkgs[0].Include)
|
||||
|
|
|
|||
|
|
@ -359,7 +359,7 @@ func (t *imageType) getPackages(name string) rpmmd.PackageSet {
|
|||
return getter(t)
|
||||
}
|
||||
|
||||
func (t *imageType) PackageSets(bp blueprint.Blueprint, repos []rpmmd.RepoConfig) map[string][]rpmmd.PackageSet {
|
||||
func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig) map[string][]rpmmd.PackageSet {
|
||||
// merge package sets that appear in the image type with the package sets
|
||||
// of the same name from the distro and arch
|
||||
mergedSets := make(map[string]rpmmd.PackageSet)
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ func TestImageType_BuildPackages(t *testing.T) {
|
|||
if assert.NoErrorf(t, err, "d.GetArch(%v) returned err = %v; expected nil", archLabel, err) {
|
||||
continue
|
||||
}
|
||||
buildPkgs := itStruct.PackageSets(blueprint.Blueprint{}, nil)["build"]
|
||||
buildPkgs := itStruct.PackageSets(blueprint.Blueprint{}, distro.ImageOptions{}, nil)["build"]
|
||||
assert.NotNil(t, buildPkgs)
|
||||
assert.Len(t, buildPkgs, 1)
|
||||
assert.ElementsMatch(t, buildPackages[archLabel], buildPkgs[0].Include)
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ func (t *imageType) BuildPackages() []string {
|
|||
return packages
|
||||
}
|
||||
|
||||
func (t *imageType) PackageSets(bp blueprint.Blueprint, repos []rpmmd.RepoConfig) map[string][]rpmmd.PackageSet {
|
||||
func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig) map[string][]rpmmd.PackageSet {
|
||||
includePackages, excludePackages := t.Packages(bp)
|
||||
return map[string][]rpmmd.PackageSet{
|
||||
"packages": {{
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ func TestImageType_BuildPackages(t *testing.T) {
|
|||
if assert.NoErrorf(t, err, "d.GetArch(%v) returned err = %v; expected nil", archLabel, err) {
|
||||
continue
|
||||
}
|
||||
buildPkgs := itStruct.PackageSets(blueprint.Blueprint{}, nil)["build-packages"]
|
||||
buildPkgs := itStruct.PackageSets(blueprint.Blueprint{}, distro.ImageOptions{}, nil)["build-packages"]
|
||||
assert.NotNil(t, buildPkgs)
|
||||
assert.Len(t, buildPkgs, 1)
|
||||
assert.ElementsMatch(t, buildPackages[archLabel], buildPkgs[0].Include)
|
||||
|
|
@ -408,7 +408,7 @@ func TestImageType_BasePackages(t *testing.T) {
|
|||
for _, pkgMap := range pkgMaps {
|
||||
imgType, err := arch.GetImageType(pkgMap.name)
|
||||
assert.NoError(t, err)
|
||||
packages := imgType.PackageSets(blueprint.Blueprint{}, nil)["packages"]
|
||||
packages := imgType.PackageSets(blueprint.Blueprint{}, distro.ImageOptions{}, nil)["packages"]
|
||||
assert.NotNil(t, packages)
|
||||
assert.Len(t, packages, 1)
|
||||
expectedPackages := append(pkgMap.basePackages, pkgMap.bootloaderPackages...)
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ func (t *imageTypeS2) BuildPackages() []string {
|
|||
return buildPackages
|
||||
}
|
||||
|
||||
func (t *imageTypeS2) PackageSets(bp blueprint.Blueprint, repos []rpmmd.RepoConfig) map[string][]rpmmd.PackageSet {
|
||||
func (t *imageTypeS2) PackageSets(bp blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig) map[string][]rpmmd.PackageSet {
|
||||
sets := map[string][]rpmmd.PackageSet{
|
||||
"build-packages": {{
|
||||
Include: t.BuildPackages(),
|
||||
|
|
|
|||
|
|
@ -305,7 +305,7 @@ func (t *imageType) getPackages(name string) rpmmd.PackageSet {
|
|||
return getter(t)
|
||||
}
|
||||
|
||||
func (t *imageType) PackageSets(bp blueprint.Blueprint, repos []rpmmd.RepoConfig) map[string][]rpmmd.PackageSet {
|
||||
func (t *imageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig) map[string][]rpmmd.PackageSet {
|
||||
// merge package sets that appear in the image type with the package sets
|
||||
// of the same name from the distro and arch
|
||||
mergedSets := make(map[string]rpmmd.PackageSet)
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ func TestImageType_BuildPackages(t *testing.T) {
|
|||
if assert.NoErrorf(t, err, "d.GetArch(%v) returned err = %v; expected nil", archLabel, err) {
|
||||
continue
|
||||
}
|
||||
buildPkgs := itStruct.PackageSets(blueprint.Blueprint{}, nil)["build"]
|
||||
buildPkgs := itStruct.PackageSets(blueprint.Blueprint{}, distro.ImageOptions{}, nil)["build"]
|
||||
assert.NotNil(t, buildPkgs)
|
||||
assert.Len(t, buildPkgs, 1)
|
||||
assert.ElementsMatch(t, buildPackages[archLabel], buildPkgs[0].Include)
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ func (t *TestImageType) PartitionType() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (t *TestImageType) PackageSets(bp blueprint.Blueprint, repos []rpmmd.RepoConfig) map[string][]rpmmd.PackageSet {
|
||||
func (t *TestImageType) PackageSets(bp blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig) map[string][]rpmmd.PackageSet {
|
||||
return map[string][]rpmmd.PackageSet{
|
||||
buildPkgsKey: {{
|
||||
Include: []string{
|
||||
|
|
|
|||
|
|
@ -123,8 +123,10 @@ func (h *apiHandlers) PostCompose(ctx echo.Context) error {
|
|||
panic("Could not initialize empty blueprint.")
|
||||
}
|
||||
|
||||
options := distro.ImageOptions{Size: imageType.Size(0)}
|
||||
|
||||
solver := h.server.solver.NewWithConfig(d.ModulePlatformID(), d.Releasever(), arch.Name())
|
||||
packageSets := imageType.PackageSets(*bp, repositories)
|
||||
packageSets := imageType.PackageSets(*bp, options, repositories)
|
||||
depsolvedSets := make(map[string][]rpmmd.PackageSpec, len(packageSets))
|
||||
|
||||
for name, pkgSet := range packageSets {
|
||||
|
|
@ -135,7 +137,7 @@ func (h *apiHandlers) PostCompose(ctx echo.Context) error {
|
|||
depsolvedSets[name] = res
|
||||
}
|
||||
|
||||
manifest, err := imageType.Manifest(nil, distro.ImageOptions{Size: imageType.Size(0)}, repositories, depsolvedSets, manifestSeed)
|
||||
manifest, err := imageType.Manifest(nil, options, repositories, depsolvedSets, manifestSeed)
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadGateway, fmt.Sprintf("Failed to get manifest for %s/%s/%s: %s", ir.ImageType, ir.Architecture, request.Distribution, err))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2128,7 +2128,7 @@ func (api *API) blueprintsTagHandler(writer http.ResponseWriter, request *http.R
|
|||
// depsolveBlueprintForImageType handles depsolving the blueprint package list and
|
||||
// the packages required for the image type.
|
||||
// NOTE: The imageType *must* be from the same distribution as the blueprint.
|
||||
func (api *API) depsolveBlueprintForImageType(bp blueprint.Blueprint, imageType distro.ImageType) (map[string][]rpmmd.PackageSpec, error) {
|
||||
func (api *API) depsolveBlueprintForImageType(bp blueprint.Blueprint, options distro.ImageOptions, imageType distro.ImageType) (map[string][]rpmmd.PackageSpec, error) {
|
||||
// Depsolve using the host distro if none has been specified
|
||||
if bp.Distro == "" {
|
||||
bp.Distro = api.hostDistroName
|
||||
|
|
@ -2146,7 +2146,7 @@ func (api *API) depsolveBlueprintForImageType(bp blueprint.Blueprint, imageType
|
|||
releasever := imageType.Arch().Distro().Releasever()
|
||||
solver := api.solver.NewWithConfig(platformID, releasever, api.archName)
|
||||
|
||||
packageSets := imageType.PackageSets(bp, imageTypeRepos)
|
||||
packageSets := imageType.PackageSets(bp, options, imageTypeRepos)
|
||||
depsolvedSets := make(map[string][]rpmmd.PackageSpec, len(packageSets))
|
||||
|
||||
for name, pkgSet := range packageSets {
|
||||
|
|
@ -2286,16 +2286,6 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
|
|||
cr.OSTree = ostreeParams
|
||||
}
|
||||
|
||||
packageSets, err := api.depsolveBlueprintForImageType(*bp, imageType)
|
||||
if err != nil {
|
||||
errors := responseError{
|
||||
ID: "DepsolveError",
|
||||
Msg: err.Error(),
|
||||
}
|
||||
statusResponseError(writer, http.StatusInternalServerError, errors)
|
||||
return
|
||||
}
|
||||
|
||||
var size uint64
|
||||
|
||||
// check if filesytem customizations have been set.
|
||||
|
|
@ -2313,6 +2303,25 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
|
|||
}
|
||||
seed := bigSeed.Int64()
|
||||
|
||||
options := distro.ImageOptions{
|
||||
Size: size,
|
||||
OSTree: ostree.RequestParams{
|
||||
Ref: cr.OSTree.Ref,
|
||||
Parent: cr.OSTree.Parent,
|
||||
URL: cr.OSTree.URL,
|
||||
},
|
||||
}
|
||||
|
||||
packageSets, err := api.depsolveBlueprintForImageType(*bp, options, imageType)
|
||||
if err != nil {
|
||||
errors := responseError{
|
||||
ID: "DepsolveError",
|
||||
Msg: err.Error(),
|
||||
}
|
||||
statusResponseError(writer, http.StatusInternalServerError, errors)
|
||||
return
|
||||
}
|
||||
|
||||
imageRepos, err := api.allRepositoriesByImageType(imageType)
|
||||
// this should not happen if the api.depsolveBlueprintForImageType() call above worked
|
||||
if err != nil {
|
||||
|
|
@ -2325,14 +2334,7 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
|
|||
}
|
||||
|
||||
manifest, err := imageType.Manifest(bp.Customizations,
|
||||
distro.ImageOptions{
|
||||
Size: size,
|
||||
OSTree: ostree.RequestParams{
|
||||
Ref: cr.OSTree.Ref,
|
||||
Parent: cr.OSTree.Parent,
|
||||
URL: cr.OSTree.URL,
|
||||
},
|
||||
},
|
||||
options,
|
||||
imageRepos,
|
||||
packageSets,
|
||||
seed)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue