distro: replace BasePackages() with Packages()
Rather than getting a set of base packages from the ImageType, and then appending the requested packages from the blueprint, pass the blueprint into the new Packages() function, and return the full set of packages to be depsolved. This allows us to also append packages based on other customizations too, and use that to append chrony when the timezone is set. This matches the behavior anaconda had, and there was a TODO item to do this, which had been overlooked. Fixes #787. Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
parent
d31e3ebb65
commit
50d469fe45
14 changed files with 35 additions and 36 deletions
|
|
@ -14,6 +14,7 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/fedora31"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/fedora32"
|
||||
|
|
@ -83,7 +84,7 @@ func TestCrossArchDepsolve(t *testing.T) {
|
|||
_, _, err = rpm.Depsolve(buildPackages, []string{}, repos[archStr], distroStruct.ModulePlatformID(), archStr)
|
||||
assert.NoError(t, err)
|
||||
|
||||
basePackagesInclude, basePackagesExclude := imgType.BasePackages()
|
||||
basePackagesInclude, basePackagesExclude := imgType.Packages(blueprint.Blueprint{})
|
||||
_, _, err = rpm.Depsolve(basePackagesInclude, basePackagesExclude, repos[archStr], distroStruct.ModulePlatformID(), archStr)
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -114,20 +114,7 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
packages := make([]string, len(composeRequest.Blueprint.Packages))
|
||||
for i, pkg := range composeRequest.Blueprint.Packages {
|
||||
packages[i] = pkg.Name
|
||||
// If a package has version "*" the package name suffix must be equal to "-*-*.*"
|
||||
// Using just "-*" would find any other package containing the package name
|
||||
if pkg.Version != "" && pkg.Version != "*" {
|
||||
packages[i] += "-" + pkg.Version
|
||||
} else if pkg.Version == "*" {
|
||||
packages[i] += "-*-*.*"
|
||||
}
|
||||
}
|
||||
|
||||
pkgs, excludePkgs := imageType.BasePackages()
|
||||
packages = append(pkgs, packages...)
|
||||
packages, excludePkgs := imageType.Packages(composeRequest.Blueprint)
|
||||
|
||||
home, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import (
|
|||
)
|
||||
|
||||
func getManifest(bp blueprint.Blueprint, t distro.ImageType, a distro.Arch, d distro.Distro, rpmmd rpmmd.RPMMD, repos []rpmmd.RepoConfig) distro.Manifest {
|
||||
packages, excludePackages := t.BasePackages()
|
||||
packages, excludePackages := t.Packages(bp)
|
||||
pkgs, _, err := rpmmd.Depsolve(packages, excludePackages, repos, d.ModulePlatformID(), a.Name())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ type ImageType interface {
|
|||
|
||||
// Returns the default packages to include and exclude when making the image
|
||||
// type.
|
||||
BasePackages() ([]string, []string)
|
||||
Packages(bp blueprint.Blueprint) ([]string, []string)
|
||||
|
||||
// Returns the build packages for the output type.
|
||||
BuildPackages() []string
|
||||
|
|
|
|||
|
|
@ -155,8 +155,12 @@ func (t *imageType) Size(size uint64) uint64 {
|
|||
return size
|
||||
}
|
||||
|
||||
func (t *imageType) BasePackages() ([]string, []string) {
|
||||
packages := t.packages
|
||||
func (t *imageType) Packages(bp blueprint.Blueprint) ([]string, []string) {
|
||||
packages := append(t.packages, bp.GetPackages()...)
|
||||
timezone, _ := bp.Customizations.GetTimezoneSettings()
|
||||
if timezone != nil {
|
||||
packages = append(packages, "chrony")
|
||||
}
|
||||
if t.bootable {
|
||||
packages = append(packages, t.arch.bootloaderPackages...)
|
||||
}
|
||||
|
|
@ -439,7 +443,6 @@ func (t *imageType) pipeline(c *blueprint.Customizations, repos []rpmmd.RepoConf
|
|||
|
||||
timezone, ntpServers := c.GetTimezoneSettings()
|
||||
|
||||
// TODO install chrony when this is set?
|
||||
if timezone != nil {
|
||||
p.AddStage(osbuild.NewTimezoneStage(&osbuild.TimezoneStageOptions{*timezone}))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package fedora31_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/distro_test_common"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/fedora31"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
|
@ -227,7 +228,7 @@ func TestImageType_BasePackages(t *testing.T) {
|
|||
for _, pkgMap := range pkgMaps {
|
||||
imgType, err := arch.GetImageType(pkgMap.name)
|
||||
assert.NoError(t, err)
|
||||
basePackages, excludedPackages := imgType.BasePackages()
|
||||
basePackages, excludedPackages := imgType.Packages(blueprint.Blueprint{})
|
||||
assert.Equalf(
|
||||
t,
|
||||
append(pkgMap.basePackages, pkgMap.bootloaderPackages...),
|
||||
|
|
|
|||
|
|
@ -159,8 +159,12 @@ func (t *imageType) Size(size uint64) uint64 {
|
|||
return size
|
||||
}
|
||||
|
||||
func (t *imageType) BasePackages() ([]string, []string) {
|
||||
packages := t.packages
|
||||
func (t *imageType) Packages(bp blueprint.Blueprint) ([]string, []string) {
|
||||
packages := append(t.packages, bp.GetPackages()...)
|
||||
timezone, _ := bp.Customizations.GetTimezoneSettings()
|
||||
if timezone != nil {
|
||||
packages = append(packages, "chrony")
|
||||
}
|
||||
if t.bootable {
|
||||
packages = append(packages, t.arch.bootloaderPackages...)
|
||||
}
|
||||
|
|
@ -243,7 +247,6 @@ func (t *imageType) pipeline(c *blueprint.Customizations, options distro.ImageOp
|
|||
|
||||
timezone, ntpServers := c.GetTimezoneSettings()
|
||||
|
||||
// TODO install chrony when this is set?
|
||||
if timezone != nil {
|
||||
p.AddStage(osbuild.NewTimezoneStage(&osbuild.TimezoneStageOptions{Zone: *timezone}))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package fedora32_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/distro_test_common"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/fedora32"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
|
@ -272,7 +273,7 @@ func TestImageType_BasePackages(t *testing.T) {
|
|||
for _, pkgMap := range pkgMaps {
|
||||
imgType, err := arch.GetImageType(pkgMap.name)
|
||||
assert.NoError(t, err)
|
||||
basePackages, excludedPackages := imgType.BasePackages()
|
||||
basePackages, excludedPackages := imgType.Packages(blueprint.Blueprint{})
|
||||
assert.Equalf(
|
||||
t,
|
||||
append(pkgMap.basePackages, pkgMap.bootloaderPackages...),
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ func (t *imageType) Size(size uint64) uint64 {
|
|||
return size
|
||||
}
|
||||
|
||||
func (t *imageType) BasePackages() ([]string, []string) {
|
||||
func (t *imageType) Packages(bp blueprint.Blueprint) ([]string, []string) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -161,8 +161,12 @@ func (t *imageType) Size(size uint64) uint64 {
|
|||
return size
|
||||
}
|
||||
|
||||
func (t *imageType) BasePackages() ([]string, []string) {
|
||||
packages := t.packages
|
||||
func (t *imageType) Packages(bp blueprint.Blueprint) ([]string, []string) {
|
||||
packages := append(t.packages, bp.GetPackages()...)
|
||||
timezone, _ := bp.Customizations.GetTimezoneSettings()
|
||||
if timezone != nil {
|
||||
packages = append(packages, "chrony")
|
||||
}
|
||||
if t.bootable {
|
||||
packages = append(packages, t.arch.bootloaderPackages...)
|
||||
}
|
||||
|
|
@ -264,7 +268,6 @@ func (t *imageType) pipeline(c *blueprint.Customizations, options distro.ImageOp
|
|||
|
||||
timezone, ntpServers := c.GetTimezoneSettings()
|
||||
|
||||
// TODO install chrony when this is set?
|
||||
if timezone != nil {
|
||||
p.AddStage(osbuild.NewTimezoneStage(&osbuild.TimezoneStageOptions{Zone: *timezone}))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package rhel8_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/distro_test_common"
|
||||
"github.com/osbuild/osbuild-composer/internal/distro/rhel8"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
|
@ -333,7 +334,7 @@ func TestImageType_BasePackages(t *testing.T) {
|
|||
for _, pkgMap := range pkgMaps {
|
||||
imgType, err := arch.GetImageType(pkgMap.name)
|
||||
assert.NoError(t, err)
|
||||
basePackages, excludedPackages := imgType.BasePackages()
|
||||
basePackages, excludedPackages := imgType.Packages(blueprint.Blueprint{})
|
||||
assert.Equalf(
|
||||
t,
|
||||
append(pkgMap.basePackages, pkgMap.bootloaderPackages...),
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func (t *TestImageType) Size(size uint64) uint64 {
|
|||
return 0
|
||||
}
|
||||
|
||||
func (t *TestImageType) BasePackages() ([]string, []string) {
|
||||
func (t *TestImageType) Packages(bp blueprint.Blueprint) ([]string, []string) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"net"
|
||||
"net/http"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
"github.com/osbuild/osbuild-composer/internal/worker"
|
||||
|
||||
|
|
@ -82,7 +83,7 @@ func notFoundHandler(writer http.ResponseWriter, request *http.Request) {
|
|||
// Depsolves packages and build packages for building an image for a given
|
||||
// distro, in the given architecture
|
||||
func depsolve(rpmmd rpmmd.RPMMD, distro distro.Distro, imageType distro.ImageType, repos []rpmmd.RepoConfig, arch distro.Arch) ([]rpmmd.PackageSpec, []rpmmd.PackageSpec, error) {
|
||||
specs, excludeSpecs := imageType.BasePackages()
|
||||
specs, excludeSpecs := imageType.Packages(blueprint.Blueprint{})
|
||||
packages, _, err := rpmmd.Depsolve(specs, excludeSpecs, repos, distro.ModulePlatformID(), arch.Name())
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("RPMMD.Depsolve: %v", err)
|
||||
|
|
|
|||
|
|
@ -2544,15 +2544,13 @@ func (api *API) allRepositories() []rpmmd.RepoConfig {
|
|||
|
||||
func (api *API) depsolveBlueprint(bp *blueprint.Blueprint, imageType distro.ImageType) ([]rpmmd.PackageSpec, []rpmmd.PackageSpec, error) {
|
||||
repos := api.allRepositories()
|
||||
specs := bp.GetPackages()
|
||||
|
||||
specs := bp.GetPackages()
|
||||
excludeSpecs := []string{}
|
||||
if imageType != nil {
|
||||
// When the output type is known, include the base packages in the depsolve
|
||||
// transaction.
|
||||
packages, excludePackages := imageType.BasePackages()
|
||||
specs = append(specs, packages...)
|
||||
excludeSpecs = append(excludePackages, excludeSpecs...)
|
||||
specs, excludeSpecs = imageType.Packages(*bp)
|
||||
}
|
||||
|
||||
packages, _, err := api.rpmmd.Depsolve(specs, excludeSpecs, repos, api.distro.ModulePlatformID(), api.arch.Name())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue