Skip to content

Commit

Permalink
rhel85: depsolve blueprint packages separately
Browse files Browse the repository at this point in the history
To avoid packages specified in a blueprint from conflicting with exclude
lists, we depsolve blueprint packages separately and pass them into the
Manifest generator under the new "blueprint" package set key.

This approach has the added benefit that dependencies of packages
specified in the blueprint are not subject to exclusion in addition to
the explicitly named packages.

The OS pipeline which installs the packages for the base system merges
the two package sets before running the RPM stage. The signature of the
function is changed to explicitly require blueprint packages be
specified (though `nil` or empty slice is valid).

The kernel selection test is adapted to merge the package sets before
counting kernel package.

Adaptation of changes in
#1349
  • Loading branch information
achilleas-k authored and ondrejbudai committed Jul 24, 2021
1 parent cc0f75b commit cba720e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
3 changes: 2 additions & 1 deletion internal/distro/distro_test_common/distro_test_common.go
Expand Up @@ -125,7 +125,8 @@ var knownKernels = []string{"kernel", "kernel-debug", "kernel-rt"}

// Returns the number of known kernels in the package list
func kernelCount(imgType distro.ImageType) int {
pkgs := imgType.PackageSets(blueprint.Blueprint{})["packages"].Include
sets := imgType.PackageSets(blueprint.Blueprint{})
pkgs := sets["packages"].Append(sets["blueprint"]).Include
n := 0
for _, pkg := range pkgs {
for _, kernel := range knownKernels {
Expand Down
5 changes: 4 additions & 1 deletion internal/distro/rhel85/distro.go
Expand Up @@ -213,7 +213,10 @@ func (t *imageType) PackageSets(bp blueprint.Blueprint) map[string]rpmmd.Package
if timezone != nil {
bpPackages = append(bpPackages, "chrony")
}
mergedSets["packages"] = mergedSets["packages"].Append(rpmmd.PackageSet{Include: bpPackages})

// depsolve bp packages separately
// bp packages aren't restricted by exclude lists
mergedSets["blueprint"] = rpmmd.PackageSet{Include: bpPackages}
return mergedSets

}
Expand Down
17 changes: 9 additions & 8 deletions internal/distro/rhel85/pipelines.go
Expand Up @@ -16,7 +16,7 @@ import (
func qcow2Pipelines(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)
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs["build"]))
treePipeline, err := osPipeline(repos, packageSetSpecs["packages"], customizations, options, t.enabledServices, t.disabledServices, t.defaultTarget)
treePipeline, err := osPipeline(repos, packageSetSpecs["packages"], packageSetSpecs["blueprint"], customizations, options, t.enabledServices, t.disabledServices, t.defaultTarget)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -64,7 +64,7 @@ func qcow2Pipelines(t *imageType, customizations *blueprint.Customizations, opti
func vhdPipelines(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)
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs["build"]))
treePipeline, err := osPipeline(repos, packageSetSpecs["packages"], customizations, options, t.enabledServices, t.disabledServices, t.defaultTarget)
treePipeline, err := osPipeline(repos, packageSetSpecs["packages"], packageSetSpecs["blueprint"], customizations, options, t.enabledServices, t.disabledServices, t.defaultTarget)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -101,7 +101,7 @@ func vhdPipelines(t *imageType, customizations *blueprint.Customizations, option
func vmdkPipelines(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)
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs["build"]))
treePipeline, err := osPipeline(repos, packageSetSpecs["packages"], customizations, options, t.enabledServices, t.disabledServices, t.defaultTarget)
treePipeline, err := osPipeline(repos, packageSetSpecs["packages"], packageSetSpecs["blueprint"], customizations, options, t.enabledServices, t.disabledServices, t.defaultTarget)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -138,7 +138,7 @@ func vmdkPipelines(t *imageType, customizations *blueprint.Customizations, optio
func openstackPipelines(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)
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs["build"]))
treePipeline, err := osPipeline(repos, packageSetSpecs["packages"], customizations, options, t.enabledServices, t.disabledServices, t.defaultTarget)
treePipeline, err := osPipeline(repos, packageSetSpecs["packages"], packageSetSpecs["blueprint"], customizations, options, t.enabledServices, t.disabledServices, t.defaultTarget)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -175,7 +175,7 @@ func openstackPipelines(t *imageType, customizations *blueprint.Customizations,
func amiPipelines(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)
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs["build"]))
treePipeline, err := osPipeline(repos, packageSetSpecs["packages"], customizations, options, t.enabledServices, t.disabledServices, t.defaultTarget)
treePipeline, err := osPipeline(repos, packageSetSpecs["packages"], packageSetSpecs["blueprint"], customizations, options, t.enabledServices, t.disabledServices, t.defaultTarget)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -210,7 +210,7 @@ func tarPipelines(t *imageType, customizations *blueprint.Customizations, option
pipelines := make([]osbuild.Pipeline, 0)
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs["build"]))

treePipeline, err := osPipeline(repos, packageSetSpecs["packages"], customizations, options, t.enabledServices, t.disabledServices, t.defaultTarget)
treePipeline, err := osPipeline(repos, packageSetSpecs["packages"], packageSetSpecs["blueprint"], customizations, options, t.enabledServices, t.disabledServices, t.defaultTarget)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -250,7 +250,7 @@ func tarInstallerPipelines(t *imageType, customizations *blueprint.Customization
pipelines := make([]osbuild.Pipeline, 0)
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs["build"]))

treePipeline, err := osPipeline(repos, packageSetSpecs["packages"], customizations, options, t.enabledServices, t.disabledServices, t.defaultTarget)
treePipeline, err := osPipeline(repos, packageSetSpecs["packages"], packageSetSpecs["blueprint"], customizations, options, t.enabledServices, t.disabledServices, t.defaultTarget)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -325,9 +325,10 @@ func buildPipeline(repos []rpmmd.RepoConfig, buildPackageSpecs []rpmmd.PackageSp
return p
}

func osPipeline(repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpec, c *blueprint.Customizations, options distro.ImageOptions, enabledServices, disabledServices []string, defaultTarget string) (*osbuild.Pipeline, error) {
func osPipeline(repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpec, bpPackages []rpmmd.PackageSpec, c *blueprint.Customizations, options distro.ImageOptions, enabledServices, disabledServices []string, defaultTarget string) (*osbuild.Pipeline, error) {
p := new(osbuild.Pipeline)
p.Name = "os"
packages = append(packages, bpPackages...)
p.AddStage(osbuild.NewRPMStage(rpmStageOptions(repos), rpmStageInputs(packages)))
p.AddStage(osbuild.NewFixBLSStage())
language, keyboard := c.GetPrimaryLocale()
Expand Down

0 comments on commit cba720e

Please sign in to comment.