composer: add provisional multi-arch support
The pipeline generation now takes the architecture as an argument. Currently only x86_64 is supported. The architecture is detected at start-up, and passed down to each pipeline translation. For osbuild-pipeline we now requrie the architecture to be passed in. Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
parent
dcc9cdedee
commit
d33fc5f010
11 changed files with 48 additions and 20 deletions
|
|
@ -30,7 +30,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, checksums map[string]string, outputFormat string) (*pipeline.Pipeline, error)
|
||||
Pipeline(b *blueprint.Blueprint, checksums map[string]string, outputArchitecture, outputFormat string) (*pipeline.Pipeline, error)
|
||||
|
||||
// Returns a osbuild runner that can be used on this distro.
|
||||
Runner() string
|
||||
|
|
@ -41,7 +41,7 @@ var registered map[string]Distro
|
|||
func init() {
|
||||
registered = map[string]Distro{
|
||||
"fedora-30": fedora30.New(),
|
||||
"rhel-8.2": rhel82.New(),
|
||||
"rhel-8.2": rhel82.New(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -100,10 +100,10 @@ func readOSRelease(r io.Reader) (map[string]string, error) {
|
|||
key := strings.TrimSpace(parts[0])
|
||||
value := strings.TrimSpace(parts[1])
|
||||
if value[0] == '"' {
|
||||
if len(value) < 2 || value[len(value) - 1] != '"' {
|
||||
if len(value) < 2 || value[len(value)-1] != '"' {
|
||||
return nil, errors.New("readOSRelease: invalid input")
|
||||
}
|
||||
value = value[1:len(value) - 1]
|
||||
value = value[1 : len(value)-1]
|
||||
}
|
||||
|
||||
osrelease[key] = value
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ func TestDistro_Pipeline(t *testing.T) {
|
|||
for _, fileInfo := range fileInfos {
|
||||
type compose struct {
|
||||
Distro string `json:"distro"`
|
||||
Arch string `json:"arch"`
|
||||
OutputFormat string `json:"output-format"`
|
||||
Checksums map[string]string `json:"checksums"`
|
||||
Blueprint *blueprint.Blueprint `json:"blueprint"`
|
||||
|
|
@ -46,7 +47,7 @@ func TestDistro_Pipeline(t *testing.T) {
|
|||
t.Errorf("unknown distro: %v", tt.Compose.Distro)
|
||||
return
|
||||
}
|
||||
got, err := d.Pipeline(tt.Compose.Blueprint, tt.Compose.Checksums, tt.Compose.OutputFormat)
|
||||
got, err := d.Pipeline(tt.Compose.Blueprint, tt.Compose.Checksums, tt.Compose.Arch, tt.Compose.OutputFormat)
|
||||
if (err != nil) != (tt.Pipeline == nil) {
|
||||
t.Errorf("distro.Pipeline() error = %v", err)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -270,12 +270,16 @@ func (r *Fedora30) FilenameFromType(outputFormat string) (string, string, error)
|
|||
return "", "", errors.New("invalid output format: " + outputFormat)
|
||||
}
|
||||
|
||||
func (r *Fedora30) Pipeline(b *blueprint.Blueprint, checksums map[string]string, outputFormat string) (*pipeline.Pipeline, error) {
|
||||
func (r *Fedora30) Pipeline(b *blueprint.Blueprint, checksums map[string]string, outputArchitecture, outputFormat string) (*pipeline.Pipeline, error) {
|
||||
output, exists := r.outputs[outputFormat]
|
||||
if !exists {
|
||||
return nil, errors.New("invalid output format: " + outputFormat)
|
||||
}
|
||||
|
||||
if outputArchitecture != "x86_64" {
|
||||
return nil, errors.New("invalid output architecture: " + outputArchitecture)
|
||||
}
|
||||
|
||||
p := &pipeline.Pipeline{}
|
||||
p.SetBuild(r.buildPipeline(checksums), "org.osbuild.fedora30")
|
||||
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ func New() *RHEL82 {
|
|||
DefaultTarget: "multi-user.target",
|
||||
IncludeFSTab: true,
|
||||
KernelOptions: "ro console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto",
|
||||
Assembler: r.qemuAssembler("raw.xz", "image.raw.xz", 6 * GigaByte),
|
||||
Assembler: r.qemuAssembler("raw.xz", "image.raw.xz", 6*GigaByte),
|
||||
}
|
||||
|
||||
r.outputs["ext4-filesystem"] = output{
|
||||
|
|
@ -294,12 +294,16 @@ func (r *RHEL82) FilenameFromType(outputFormat string) (string, string, error) {
|
|||
return "", "", errors.New("invalid output format: " + outputFormat)
|
||||
}
|
||||
|
||||
func (r *RHEL82) Pipeline(b *blueprint.Blueprint, checksums map[string]string, outputFormat string) (*pipeline.Pipeline, error) {
|
||||
func (r *RHEL82) Pipeline(b *blueprint.Blueprint, checksums map[string]string, outputArchitecture, outputFormat string) (*pipeline.Pipeline, error) {
|
||||
output, exists := r.outputs[outputFormat]
|
||||
if !exists {
|
||||
return nil, errors.New("invalid output format: " + outputFormat)
|
||||
}
|
||||
|
||||
if outputArchitecture != "x86_64" {
|
||||
return nil, errors.New("invalid output architecture: " + outputArchitecture)
|
||||
}
|
||||
|
||||
p := &pipeline.Pipeline{}
|
||||
p.SetBuild(r.buildPipeline(checksums), "org.osbuild.rhel82")
|
||||
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ func (d *TestDistro) FilenameFromType(outputFormat string) (string, string, erro
|
|||
return "", "", errors.New("invalid output format: " + outputFormat)
|
||||
}
|
||||
|
||||
func (d *TestDistro) Pipeline(b *blueprint.Blueprint, checksums map[string]string, outputFormat string) (*pipeline.Pipeline, error) {
|
||||
return nil, errors.New("invalid output format: " + outputFormat)
|
||||
func (d *TestDistro) Pipeline(b *blueprint.Blueprint, checksums map[string]string, outputArch, outputFormat string) (*pipeline.Pipeline, error) {
|
||||
return nil, errors.New("invalid output format or arch: " + outputFormat + " @ " + outputArch)
|
||||
}
|
||||
|
||||
func (d *TestDistro) Runner() string {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue