distro: expose the ModulePlatfromID
This is needed for depsolving, so expose it from the distro package so it can be passed to dnf-json (and not only to osbuild) as that does depsolving too. Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
parent
d133454d91
commit
f0f2e80a97
5 changed files with 82 additions and 2 deletions
|
|
@ -25,6 +25,10 @@ type Distro interface {
|
|||
// Return strong-typed distribution
|
||||
Distribution() common.Distribution
|
||||
|
||||
// Returns the module platform id of the distro. This is used by DNF
|
||||
// for modularity support.
|
||||
ModulePlatformID() string
|
||||
|
||||
// Returns a list of repositories from which this distribution gets its
|
||||
// content.
|
||||
Repositories(arch string) []rpmmd.RepoConfig
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ type output struct {
|
|||
}
|
||||
|
||||
const Distro = common.Fedora30
|
||||
const ModulePlatformID = "platform:f30"
|
||||
|
||||
func New(confPaths []string) *Fedora30 {
|
||||
const GigaByte = 1024 * 1024 * 1024
|
||||
|
|
@ -311,6 +312,10 @@ func (r *Fedora30) Distribution() common.Distribution {
|
|||
return Distro
|
||||
}
|
||||
|
||||
func (r *Fedora30) ModulePlatformID() string {
|
||||
return ModulePlatformID
|
||||
}
|
||||
|
||||
func (r *Fedora30) Repositories(arch string) []rpmmd.RepoConfig {
|
||||
return r.arches[arch].Repositories
|
||||
}
|
||||
|
|
@ -448,7 +453,7 @@ func (r *Fedora30) dnfStageOptions(arch arch, additionalRepos []rpmmd.RepoConfig
|
|||
options := &osbuild.DNFStageOptions{
|
||||
ReleaseVersion: "30",
|
||||
BaseArchitecture: arch.Name,
|
||||
ModulePlatformId: "platform:f30",
|
||||
ModulePlatformId: ModulePlatformID,
|
||||
}
|
||||
|
||||
for _, repo := range append(arch.Repositories, additionalRepos...) {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ import (
|
|||
|
||||
type FedoraTestDistro struct{}
|
||||
|
||||
const ModulePlatformID = "platform:f30"
|
||||
|
||||
func New() *FedoraTestDistro {
|
||||
return &FedoraTestDistro{}
|
||||
}
|
||||
|
|
@ -23,6 +25,10 @@ func (d *FedoraTestDistro) Distribution() common.Distribution {
|
|||
return common.Fedora30
|
||||
}
|
||||
|
||||
func (d *FedoraTestDistro) ModulePlatformID() string {
|
||||
return ModulePlatformID
|
||||
}
|
||||
|
||||
func (d *FedoraTestDistro) Repositories(arch string) []rpmmd.RepoConfig {
|
||||
return []rpmmd.RepoConfig{
|
||||
{
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ type output struct {
|
|||
}
|
||||
|
||||
const Distro = common.RHEL82
|
||||
const ModulePlatformID = "platform:el8"
|
||||
|
||||
func New(confPaths []string) *RHEL82 {
|
||||
const GigaByte = 1024 * 1024 * 1024
|
||||
|
|
@ -446,6 +447,10 @@ func (r *RHEL82) Distribution() common.Distribution {
|
|||
return Distro
|
||||
}
|
||||
|
||||
func (r *RHEL82) ModulePlatformID() string {
|
||||
return ModulePlatformID
|
||||
}
|
||||
|
||||
func (r *RHEL82) Repositories(arch string) []rpmmd.RepoConfig {
|
||||
return r.arches[arch].Repositories
|
||||
}
|
||||
|
|
@ -592,7 +597,7 @@ func (r *RHEL82) dnfStageOptions(arch arch, additionalRepos []rpmmd.RepoConfig,
|
|||
options := &osbuild.DNFStageOptions{
|
||||
ReleaseVersion: "8",
|
||||
BaseArchitecture: arch.Name,
|
||||
ModulePlatformId: "platform:el8",
|
||||
ModulePlatformId: ModulePlatformID,
|
||||
}
|
||||
for _, repo := range append(arch.Repositories, additionalRepos...) {
|
||||
options.AddRepository(&osbuild.DNFRepository{
|
||||
|
|
|
|||
60
internal/distro/test/distro.go
Normal file
60
internal/distro/test/distro.go
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
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) Repositories(arch string) []rpmmd.RepoConfig {
|
||||
return []rpmmd.RepoConfig{
|
||||
{
|
||||
Id: "test-id",
|
||||
Name: "Test Name",
|
||||
BaseURL: "http://example.com/test/os/" + arch,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
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) Pipeline(b *blueprint.Blueprint, additionalRepos []rpmmd.RepoConfig, checksums map[string]string, 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) Runner() string {
|
||||
return "org.osbuild.test"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue