Merge pull request #75 from stgraber/master
definition: Set ArchitectureMapped, ArchitectureKernel and Architectu…
This commit is contained in:
commit
2e325862b8
@ -114,7 +114,7 @@ func (l *LXDImage) createMetadata() error {
|
||||
|
||||
l.Metadata.Architecture = l.definition.Image.Architecture
|
||||
l.Metadata.CreationDate = time.Now().UTC().Unix()
|
||||
l.Metadata.Properties["architecture"] = l.definition.Image.MappedArchitecture
|
||||
l.Metadata.Properties["architecture"] = l.definition.Image.ArchitectureMapped
|
||||
l.Metadata.Properties["os"] = l.definition.Image.Distribution
|
||||
l.Metadata.Properties["release"] = l.definition.Image.Release
|
||||
l.Metadata.Properties["variant"] = l.definition.Image.Variant
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
lxd "github.com/lxc/lxd/shared"
|
||||
lxdarch "github.com/lxc/lxd/shared/osarch"
|
||||
|
||||
"github.com/lxc/lxd/shared"
|
||||
)
|
||||
@ -32,7 +33,11 @@ type DefinitionImage struct {
|
||||
Variant string `yaml:"variant,omitempty"`
|
||||
Name string `yaml:"name,omitempty"`
|
||||
Serial string `yaml:"serial,omitempty"`
|
||||
MappedArchitecture string `yaml:"mapped_architecture,omitempty"`
|
||||
|
||||
// Internal fields (YAML input ignored)
|
||||
ArchitectureMapped string `yaml:"architecture_mapped,omitempty"`
|
||||
ArchitectureKernel string `yaml:"architecture_kernel,omitempty"`
|
||||
ArchitecturePersonality string `yaml:"architecture_personality,omitempty"`
|
||||
}
|
||||
|
||||
// A DefinitionSource specifies the download type and location
|
||||
@ -224,12 +229,34 @@ func (d *Definition) Validate() error {
|
||||
}
|
||||
}
|
||||
|
||||
var err error
|
||||
d.Image.MappedArchitecture, err = d.getMappedArchitecture()
|
||||
// Mapped architecture (distro name)
|
||||
archMapped, err := d.getMappedArchitecture()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
d.Image.ArchitectureMapped = archMapped
|
||||
|
||||
// Kernel architecture and personality
|
||||
archID, err := lxdarch.ArchitectureId(d.Image.Architecture)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
archName, err := lxdarch.ArchitectureName(archID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
d.Image.ArchitectureMapped = archName
|
||||
|
||||
archPersonality, err := lxdarch.ArchitecturePersonality(archID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
d.Image.ArchitecturePersonality = archPersonality
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -24,10 +24,10 @@ func NewAlpineLinuxHTTP() *AlpineLinuxHTTP {
|
||||
// Run downloads an Alpine Linux mini root filesystem.
|
||||
func (s *AlpineLinuxHTTP) Run(definition shared.Definition, rootfsDir string) error {
|
||||
fname := fmt.Sprintf("alpine-minirootfs-%s-%s.tar.gz", definition.Image.Release,
|
||||
definition.Image.MappedArchitecture)
|
||||
definition.Image.ArchitectureMapped)
|
||||
tarball := fmt.Sprintf("%s/v%s/releases/%s/%s", definition.Source.URL,
|
||||
strings.Join(strings.Split(definition.Image.Release, ".")[0:2], "."),
|
||||
definition.Image.MappedArchitecture, fname)
|
||||
definition.Image.ArchitectureMapped, fname)
|
||||
|
||||
url, err := url.Parse(tarball)
|
||||
if err != nil {
|
||||
|
@ -24,7 +24,7 @@ func NewArchLinuxHTTP() *ArchLinuxHTTP {
|
||||
// Run downloads an Arch Linux tarball.
|
||||
func (s *ArchLinuxHTTP) Run(definition shared.Definition, rootfsDir string) error {
|
||||
fname := fmt.Sprintf("archlinux-bootstrap-%s-%s.tar.gz",
|
||||
definition.Image.Release, definition.Image.MappedArchitecture)
|
||||
definition.Image.Release, definition.Image.ArchitectureMapped)
|
||||
tarball := fmt.Sprintf("%s/%s/%s", definition.Source.URL,
|
||||
definition.Image.Release, fname)
|
||||
|
||||
@ -68,7 +68,7 @@ func (s *ArchLinuxHTTP) Run(definition shared.Definition, rootfsDir string) erro
|
||||
// Move everything inside 'root.x86_64' (which was is the tarball) to its
|
||||
// parent directory
|
||||
files, err := filepath.Glob(fmt.Sprintf("%s/*", filepath.Join(rootfsDir,
|
||||
"root", definition.Image.MappedArchitecture)))
|
||||
"root", definition.Image.ArchitectureMapped)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -81,5 +81,5 @@ func (s *ArchLinuxHTTP) Run(definition shared.Definition, rootfsDir string) erro
|
||||
}
|
||||
|
||||
return os.RemoveAll(filepath.Join(rootfsDir, "root",
|
||||
definition.Image.MappedArchitecture))
|
||||
definition.Image.ArchitectureMapped))
|
||||
}
|
||||
|
@ -30,10 +30,10 @@ func NewCentOSHTTP() *CentOSHTTP {
|
||||
func (s *CentOSHTTP) Run(definition shared.Definition, rootfsDir string) error {
|
||||
baseURL := fmt.Sprintf("%s/%s/isos/%s/", definition.Source.URL,
|
||||
strings.Split(definition.Image.Release, ".")[0],
|
||||
definition.Image.MappedArchitecture)
|
||||
definition.Image.ArchitectureMapped)
|
||||
|
||||
s.fname = getRelease(definition.Source.URL, definition.Image.Release,
|
||||
definition.Source.Variant, definition.Image.MappedArchitecture)
|
||||
definition.Source.Variant, definition.Image.ArchitectureMapped)
|
||||
if s.fname == "" {
|
||||
return fmt.Errorf("Couldn't get name of iso")
|
||||
}
|
||||
|
@ -27,8 +27,8 @@ func (s *Debootstrap) Run(definition shared.Definition, rootfsDir string) error
|
||||
args = append(args, "--variant", definition.Source.Variant)
|
||||
}
|
||||
|
||||
if definition.Image.MappedArchitecture != "" {
|
||||
args = append(args, "--arch", definition.Image.MappedArchitecture)
|
||||
if definition.Image.ArchitectureMapped != "" {
|
||||
args = append(args, "--arch", definition.Image.ArchitectureMapped)
|
||||
}
|
||||
|
||||
if len(definition.Source.Keys) > 0 {
|
||||
|
@ -34,11 +34,11 @@ func (s *UbuntuHTTP) Run(definition shared.Definition, rootfsDir string) error {
|
||||
|
||||
if strings.ContainsAny(definition.Image.Release, "0123456789") {
|
||||
s.fname = fmt.Sprintf("ubuntu-base-%s-base-%s.tar.gz",
|
||||
definition.Image.Release, definition.Image.MappedArchitecture)
|
||||
definition.Image.Release, definition.Image.ArchitectureMapped)
|
||||
} else {
|
||||
// if release is non-numerical, find the latest release
|
||||
s.fname = getLatestRelease(definition.Source.URL,
|
||||
definition.Image.Release, definition.Image.MappedArchitecture)
|
||||
definition.Image.Release, definition.Image.ArchitectureMapped)
|
||||
if s.fname == "" {
|
||||
return fmt.Errorf("Couldn't find latest release")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user