distro/pipeline: take depsolved packages as argument
This is unused for now, but will allow us to generate pipelines with the pre-depsolved NEVRAs, so osbuild does not need to depsolve again. Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
parent
59da8b066f
commit
fefe5db4ce
11 changed files with 17 additions and 17 deletions
|
|
@ -88,7 +88,7 @@ func main() {
|
|||
packages = append(pkgs, packages...)
|
||||
|
||||
rpmmd := rpmmd.NewRPMMD()
|
||||
_, checksums, err := rpmmd.Depsolve(packages, exclude_pkgs, d.Repositories(archArg), d.ModulePlatformID(), false)
|
||||
packageSpecs, checksums, err := rpmmd.Depsolve(packages, exclude_pkgs, d.Repositories(archArg), d.ModulePlatformID(), false)
|
||||
if err != nil {
|
||||
panic("Could not depsolve: " + err.Error())
|
||||
}
|
||||
|
|
@ -97,12 +97,12 @@ func main() {
|
|||
if err != nil {
|
||||
panic("Could not get build packages: " + err.Error())
|
||||
}
|
||||
_, _, err = rpmmd.Depsolve(buildPkgs, nil, d.Repositories(archArg), d.ModulePlatformID(), false)
|
||||
buildPackageSpecs, _, err := rpmmd.Depsolve(buildPkgs, nil, d.Repositories(archArg), d.ModulePlatformID(), false)
|
||||
if err != nil {
|
||||
panic("Could not depsolve build packages: " + err.Error())
|
||||
}
|
||||
|
||||
pipeline, err := d.Pipeline(blueprint, nil, checksums, archArg, imageType, 0)
|
||||
pipeline, err := d.Pipeline(blueprint, nil, packageSpecs, buildPackageSpecs, checksums, archArg, imageType, 0)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ type Distro interface {
|
|||
// Returns an osbuild pipeline that generates an image in the given
|
||||
// output format with all packages and customizations specified in the
|
||||
// given blueprint.
|
||||
Pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, checksums map[string]string, outputArchitecture, outputFormat string, size uint64) (*osbuild.Pipeline, error)
|
||||
Pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, checksums map[string]string, outputArchitecture, outputFormat string, size uint64) (*osbuild.Pipeline, error)
|
||||
|
||||
// Returns a osbuild runner that can be used on this distro.
|
||||
Runner() string
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ func TestDistro_Pipeline(t *testing.T) {
|
|||
return
|
||||
}
|
||||
size := d.GetSizeForOutputType(tt.Compose.OutputFormat, 0)
|
||||
got, err := d.Pipeline(tt.Compose.Blueprint, nil, tt.Compose.Checksums, tt.Compose.Arch, tt.Compose.OutputFormat, size)
|
||||
got, err := d.Pipeline(tt.Compose.Blueprint, nil, nil, nil, tt.Compose.Checksums, tt.Compose.Arch, tt.Compose.OutputFormat, size)
|
||||
if (err != nil) != (tt.Pipeline == nil) {
|
||||
t.Errorf("distro.Pipeline() error = %v", err)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -386,7 +386,7 @@ func (r *Fedora30) BuildPackages(outputArchitecture string) ([]string, error) {
|
|||
return append(r.buildPackages, arch.BuildPackages...), nil
|
||||
}
|
||||
|
||||
func (r *Fedora30) Pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, checksums map[string]string, outputArchitecture, outputFormat string, size uint64) (*osbuild.Pipeline, error) {
|
||||
func (r *Fedora30) Pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, checksums map[string]string, outputArchitecture, outputFormat string, size uint64) (*osbuild.Pipeline, error) {
|
||||
output, exists := r.outputs[outputFormat]
|
||||
if !exists {
|
||||
return nil, errors.New("invalid output format: " + outputFormat)
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ func (d *FedoraTestDistro) BuildPackages(outputArchitecture string) ([]string, e
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
func (d *FedoraTestDistro) Pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, checksums map[string]string, outputArch, outputFormat string, size uint64) (*osbuild.Pipeline, error) {
|
||||
func (d *FedoraTestDistro) Pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, buildPackages, basePackages []rpmmd.PackageSpec, checksums map[string]string, outputArch, outputFormat string, size uint64) (*osbuild.Pipeline, error) {
|
||||
if outputFormat == "qcow2" && outputArch == "x86_64" {
|
||||
return &osbuild.Pipeline{}, nil
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -525,7 +525,7 @@ func (r *RHEL82) BuildPackages(outputArchitecture string) ([]string, error) {
|
|||
return append(r.buildPackages, arch.BuildPackages...), nil
|
||||
}
|
||||
|
||||
func (r *RHEL82) Pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, checksums map[string]string, outputArchitecture, outputFormat string, size uint64) (*osbuild.Pipeline, error) {
|
||||
func (r *RHEL82) Pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, checksums map[string]string, outputArchitecture, outputFormat string, size uint64) (*osbuild.Pipeline, error) {
|
||||
output, exists := r.outputs[outputFormat]
|
||||
if !exists {
|
||||
return nil, errors.New("invalid output format: " + outputFormat)
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ func (d *TestDistro) BuildPackages(outputArchitecture string) ([]string, error)
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
func (d *TestDistro) Pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, checksums map[string]string, outputArch, outputFormat string, size uint64) (*osbuild.Pipeline, error) {
|
||||
func (d *TestDistro) Pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, checksums map[string]string, outputArch, outputFormat string, size uint64) (*osbuild.Pipeline, error) {
|
||||
if outputFormat == "test_output" && outputArch == "test_arch" {
|
||||
return &osbuild.Pipeline{}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ func TestCreate(t *testing.T) {
|
|||
store := store.New(nil, distroStruct, *registry)
|
||||
api := jobqueue.New(nil, store)
|
||||
|
||||
err := store.PushCompose(id, &blueprint.Blueprint{}, map[string]string{"test-repo": "test:foo"}, "x86_64", "qcow2", 0, nil)
|
||||
err := store.PushCompose(id, &blueprint.Blueprint{}, nil, nil, map[string]string{"test-repo": "test:foo"}, "x86_64", "qcow2", 0, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("error pushing compose: %v", err)
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ func testUpdateTransition(t *testing.T, from, to string, expectedStatus int, exp
|
|||
api := jobqueue.New(nil, store)
|
||||
|
||||
if from != "VOID" {
|
||||
err := store.PushCompose(id, &blueprint.Blueprint{}, map[string]string{"test": "test:foo"}, "x86_64", "qcow2", 0, nil)
|
||||
err := store.PushCompose(id, &blueprint.Blueprint{}, nil, nil, map[string]string{"test": "test:foo"}, "x86_64", "qcow2", 0, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("error pushing compose: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ func (api *API) submit(writer http.ResponseWriter, request *http.Request, _ http
|
|||
composeUUID := uuid.New()
|
||||
// nil is used as an upload target, because LocalTarget is already used in the PushCompose function
|
||||
// TODO: replace this with generalized version of push compose
|
||||
err = api.store.PushCompose(composeUUID, &blueprint.Blueprint{}, make(map[string]string), composeRequest.Architectures[0], composeRequest.ImageTypes[0], 0, nil)
|
||||
err = api.store.PushCompose(composeUUID, &blueprint.Blueprint{}, nil, nil, make(map[string]string), composeRequest.Architectures[0], composeRequest.ImageTypes[0], 0, nil)
|
||||
if err != nil {
|
||||
if api.logger != nil {
|
||||
api.logger.Println("RCM API failed to push compose:", err)
|
||||
|
|
|
|||
|
|
@ -506,7 +506,7 @@ func (s *Store) getImageBuildDirectory(composeID uuid.UUID, imageBuildID int) st
|
|||
return fmt.Sprintf("%s/%d", s.getComposeDirectory(composeID), imageBuildID)
|
||||
}
|
||||
|
||||
func (s *Store) PushCompose(composeID uuid.UUID, bp *blueprint.Blueprint, checksums map[string]string, arch, composeType string, size uint64, uploadTarget *target.Target) error {
|
||||
func (s *Store) PushCompose(composeID uuid.UUID, bp *blueprint.Blueprint, packages, buildPackages []rpmmd.PackageSpec, checksums map[string]string, arch, composeType string, size uint64, uploadTarget *target.Target) error {
|
||||
targets := []*target.Target{}
|
||||
|
||||
// Compatibility layer for image types in Weldr API v0
|
||||
|
|
@ -539,7 +539,7 @@ func (s *Store) PushCompose(composeID uuid.UUID, bp *blueprint.Blueprint, checks
|
|||
repos = append(repos, source.RepoConfig())
|
||||
}
|
||||
|
||||
pipelineStruct, err := s.distro.Pipeline(bp, repos, checksums, arch, composeType, size)
|
||||
pipelineStruct, err := s.distro.Pipeline(bp, repos, packages, buildPackages, checksums, arch, composeType, size)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -608,7 +608,7 @@ func (s *Store) PushComposeRequest(request common.ComposeRequest) error {
|
|||
if !exists {
|
||||
panic("fatal error, image type should exist but it does not")
|
||||
}
|
||||
pipelineStruct, err := distroStruct.Pipeline(&request.Blueprint, request.Repositories, nil, arch, imgTypeCompatStr, 0)
|
||||
pipelineStruct, err := distroStruct.Pipeline(&request.Blueprint, request.Repositories, nil, nil, nil, arch, imgTypeCompatStr, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1263,7 +1263,7 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
|
|||
}
|
||||
|
||||
if bp != nil {
|
||||
_, _, checksums, err := api.depsolveBlueprint(bp, cr.ComposeType, api.arch, true)
|
||||
packages, buildPackages, checksums, err := api.depsolveBlueprint(bp, cr.ComposeType, api.arch, true)
|
||||
if err != nil {
|
||||
errors := responseError{
|
||||
ID: "DepsolveError",
|
||||
|
|
@ -1273,7 +1273,7 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
|
|||
return
|
||||
}
|
||||
|
||||
err = api.store.PushCompose(reply.BuildID, bp, checksums, api.arch, cr.ComposeType, size, uploadTarget)
|
||||
err = api.store.PushCompose(reply.BuildID, bp, packages, buildPackages, checksums, api.arch, cr.ComposeType, size, uploadTarget)
|
||||
|
||||
// TODO: we should probably do some kind of blueprint validation in future
|
||||
// for now, let's just 500 and bail out
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue