Mixing the way to build a distribution with where to get the source packages from is wrong: it breaks pre-release repos, local mirrors, and other use cases. To accommodate those, we introduced `/etc/osbuild-composer/repositories`. However, that doesn't work for the RCM API, which receives repository URLs to use from outside requests. This API has been wrongly using the `additionalRepos` parameter to inject those repos. That's broken, because the resulting manifests contained both the installed repos and the repos from the request. To fix this, stop exposing repositories from the distros, but require passing them on every call to `Manifest()`. This makes `additionalRepos` redundant. Fixes #341
74 lines
2.1 KiB
Go
74 lines
2.1 KiB
Go
package test
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
|
"github.com/osbuild/osbuild-composer/internal/osbuild"
|
|
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
|
)
|
|
|
|
type TestDistro struct{}
|
|
|
|
const Name = "test-distro"
|
|
const ModulePlatformID = "platform:test"
|
|
|
|
func New() *TestDistro {
|
|
return &TestDistro{}
|
|
}
|
|
|
|
func (d *TestDistro) Name() string {
|
|
return Name
|
|
}
|
|
|
|
func (d *TestDistro) ModulePlatformID() string {
|
|
return ModulePlatformID
|
|
}
|
|
|
|
func (d *TestDistro) ListOutputFormats() []string {
|
|
return []string{"test_format"}
|
|
}
|
|
|
|
func (d *TestDistro) FilenameFromType(outputFormat string) (string, string, error) {
|
|
if outputFormat == "test_format" {
|
|
return "test.img", "application/x-test", nil
|
|
}
|
|
|
|
return "", "", errors.New("invalid output format: " + outputFormat)
|
|
}
|
|
|
|
func (d *TestDistro) BasePackages(outputFormat, outputArchitecture string) ([]string, []string, error) {
|
|
return nil, nil, nil
|
|
}
|
|
|
|
func (d *TestDistro) BuildPackages(outputArchitecture string) ([]string, error) {
|
|
return nil, nil
|
|
}
|
|
|
|
func (d *TestDistro) pipeline(c *blueprint.Customizations, repos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArch, outputFormat string, size uint64) (*osbuild.Pipeline, error) {
|
|
if outputFormat == "test_output" && outputArch == "test_arch" {
|
|
return &osbuild.Pipeline{}, nil
|
|
}
|
|
|
|
return nil, errors.New("invalid output format or arch: " + outputFormat + " @ " + outputArch)
|
|
}
|
|
|
|
func (d *TestDistro) sources(packages []rpmmd.PackageSpec) *osbuild.Sources {
|
|
return &osbuild.Sources{}
|
|
}
|
|
|
|
func (r *TestDistro) Manifest(c *blueprint.Customizations, repos []rpmmd.RepoConfig, packageSpecs, buildPackageSpecs []rpmmd.PackageSpec, outputArchitecture, outputFormat string, size uint64) (*osbuild.Manifest, error) {
|
|
pipeline, err := r.pipeline(c, repos, packageSpecs, buildPackageSpecs, outputArchitecture, outputFormat, size)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &osbuild.Manifest{
|
|
Sources: *r.sources(append(packageSpecs, buildPackageSpecs...)),
|
|
Pipeline: *pipeline,
|
|
}, nil
|
|
}
|
|
|
|
func (d *TestDistro) Runner() string {
|
|
return "org.osbuild.test"
|
|
}
|