mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-20 17:49:10 +00:00
pass target architecture explicitly
Signed-off-by: Avi Deitcher <avi@deitcher.net>
This commit is contained in:
parent
b5bf29c0f6
commit
84e3b80863
@ -180,7 +180,6 @@ func build(args []string) {
|
||||
if err != nil {
|
||||
log.Fatalf("Invalid config: %v", err)
|
||||
}
|
||||
c.Architecture = *buildArch
|
||||
m, err = moby.AppendConfig(m, c)
|
||||
if err != nil {
|
||||
log.Fatalf("Cannot append config files: %v", err)
|
||||
@ -205,7 +204,7 @@ func build(args []string) {
|
||||
if moby.Streamable(buildFormats[0]) {
|
||||
tp = buildFormats[0]
|
||||
}
|
||||
err = moby.Build(m, w, *buildPull, tp, *buildDecompressKernel, cacheDir, *buildDocker)
|
||||
err = moby.Build(m, w, *buildPull, tp, *buildDecompressKernel, cacheDir, *buildDocker, *buildArch)
|
||||
if err != nil {
|
||||
log.Fatalf("%v", err)
|
||||
}
|
||||
|
@ -83,14 +83,14 @@ func OutputTypes() []string {
|
||||
return ts
|
||||
}
|
||||
|
||||
func outputImage(image *Image, section string, prefix string, m Moby, idMap map[string]uint32, dupMap map[string]string, pull bool, iw *tar.Writer, cacheDir string, dockerCache bool) error {
|
||||
func outputImage(image *Image, section string, prefix string, m Moby, idMap map[string]uint32, dupMap map[string]string, pull bool, iw *tar.Writer, cacheDir string, dockerCache bool, arch string) error {
|
||||
log.Infof(" Create OCI config for %s", image.Image)
|
||||
imageName := util.ReferenceExpand(image.Image)
|
||||
ref, err := reference.Parse(imageName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not resolve references for image %s: %v", image.Image, err)
|
||||
}
|
||||
src, err := imagePull(&ref, pull, cacheDir, dockerCache, m.Architecture)
|
||||
src, err := imagePull(&ref, pull, cacheDir, dockerCache, arch)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Could not pull image %s: %v", image.Image, err)
|
||||
}
|
||||
@ -108,7 +108,7 @@ func outputImage(image *Image, section string, prefix string, m Moby, idMap map[
|
||||
}
|
||||
path := path.Join("containers", section, prefix+image.Name)
|
||||
readonly := oci.Root.Readonly
|
||||
err = ImageBundle(path, image.ref, config, runtime, iw, pull, readonly, dupMap, cacheDir, dockerCache, m.Architecture)
|
||||
err = ImageBundle(path, image.ref, config, runtime, iw, pull, readonly, dupMap, cacheDir, dockerCache, arch)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to extract root filesystem for %s: %v", image.Image, err)
|
||||
}
|
||||
@ -116,7 +116,7 @@ func outputImage(image *Image, section string, prefix string, m Moby, idMap map[
|
||||
}
|
||||
|
||||
// Build performs the actual build process
|
||||
func Build(m Moby, w io.Writer, pull bool, tp string, decompressKernel bool, cacheDir string, dockerCache bool) error {
|
||||
func Build(m Moby, w io.Writer, pull bool, tp string, decompressKernel bool, cacheDir string, dockerCache bool, arch string) error {
|
||||
if MobyDir == "" {
|
||||
MobyDir = defaultMobyConfigDir()
|
||||
}
|
||||
@ -154,7 +154,7 @@ func Build(m Moby, w io.Writer, pull bool, tp string, decompressKernel bool, cac
|
||||
// get kernel and initrd tarball and ucode cpio archive from container
|
||||
log.Infof("Extract kernel image: %s", m.Kernel.ref)
|
||||
kf := newKernelFilter(iw, m.Kernel.Cmdline, m.Kernel.Binary, m.Kernel.Tar, m.Kernel.UCode, decompressKernel)
|
||||
err := ImageTar(m.Kernel.ref, "", kf, pull, "", cacheDir, dockerCache, m.Architecture)
|
||||
err := ImageTar(m.Kernel.ref, "", kf, pull, "", cacheDir, dockerCache, arch)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to extract kernel image and tarball: %v", err)
|
||||
}
|
||||
@ -170,7 +170,7 @@ func Build(m Moby, w io.Writer, pull bool, tp string, decompressKernel bool, cac
|
||||
}
|
||||
for _, ii := range m.initRefs {
|
||||
log.Infof("Process init image: %s", ii)
|
||||
err := ImageTar(ii, "", iw, pull, resolvconfSymlink, cacheDir, dockerCache, m.Architecture)
|
||||
err := ImageTar(ii, "", iw, pull, resolvconfSymlink, cacheDir, dockerCache, arch)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to build init tarball from %s: %v", ii, err)
|
||||
}
|
||||
@ -181,7 +181,7 @@ func Build(m Moby, w io.Writer, pull bool, tp string, decompressKernel bool, cac
|
||||
}
|
||||
for i, image := range m.Onboot {
|
||||
so := fmt.Sprintf("%03d", i)
|
||||
if err := outputImage(image, "onboot", so+"-", m, idMap, dupMap, pull, iw, cacheDir, dockerCache); err != nil {
|
||||
if err := outputImage(image, "onboot", so+"-", m, idMap, dupMap, pull, iw, cacheDir, dockerCache, arch); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -191,7 +191,7 @@ func Build(m Moby, w io.Writer, pull bool, tp string, decompressKernel bool, cac
|
||||
}
|
||||
for i, image := range m.Onshutdown {
|
||||
so := fmt.Sprintf("%03d", i)
|
||||
if err := outputImage(image, "onshutdown", so+"-", m, idMap, dupMap, pull, iw, cacheDir, dockerCache); err != nil {
|
||||
if err := outputImage(image, "onshutdown", so+"-", m, idMap, dupMap, pull, iw, cacheDir, dockerCache, arch); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -200,7 +200,7 @@ func Build(m Moby, w io.Writer, pull bool, tp string, decompressKernel bool, cac
|
||||
log.Infof("Add service containers:")
|
||||
}
|
||||
for _, image := range m.Services {
|
||||
if err := outputImage(image, "services", "", m, idMap, dupMap, pull, iw, cacheDir, dockerCache); err != nil {
|
||||
if err := outputImage(image, "services", "", m, idMap, dupMap, pull, iw, cacheDir, dockerCache, arch); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -18,13 +18,12 @@ import (
|
||||
|
||||
// Moby is the type of a Moby config file
|
||||
type Moby struct {
|
||||
Kernel KernelConfig `kernel:"cmdline,omitempty" json:"kernel,omitempty"`
|
||||
Init []string `init:"cmdline" json:"init"`
|
||||
Onboot []*Image `yaml:"onboot" json:"onboot"`
|
||||
Onshutdown []*Image `yaml:"onshutdown" json:"onshutdown"`
|
||||
Services []*Image `yaml:"services" json:"services"`
|
||||
Files []File `yaml:"files" json:"files"`
|
||||
Architecture string
|
||||
Kernel KernelConfig `kernel:"cmdline,omitempty" json:"kernel,omitempty"`
|
||||
Init []string `init:"cmdline" json:"init"`
|
||||
Onboot []*Image `yaml:"onboot" json:"onboot"`
|
||||
Onshutdown []*Image `yaml:"onshutdown" json:"onshutdown"`
|
||||
Services []*Image `yaml:"services" json:"services"`
|
||||
Files []File `yaml:"files" json:"files"`
|
||||
|
||||
initRefs []*reference.Spec
|
||||
}
|
||||
@ -311,7 +310,6 @@ func AppendConfig(m0, m1 Moby) (Moby, error) {
|
||||
moby.Services = append(moby.Services, m1.Services...)
|
||||
moby.Files = append(moby.Files, m1.Files...)
|
||||
moby.initRefs = append(moby.initRefs, m1.initRefs...)
|
||||
moby.Architecture = m1.Architecture
|
||||
|
||||
return moby, uniqueServices(moby)
|
||||
}
|
||||
|
@ -50,14 +50,14 @@ func ensureLinuxkitImage(name, cache string) error {
|
||||
}
|
||||
// This is just a local utility used for conversion, so it does not matter what architecture we use.
|
||||
// Might as well just use our local one.
|
||||
m.Architecture = runtime.GOARCH
|
||||
arch := runtime.GOARCH
|
||||
// TODO pass through --pull to here
|
||||
tf, err := ioutil.TempFile("", "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer os.Remove(tf.Name())
|
||||
if err := Build(m, tf, false, "", false, cache, true); err != nil {
|
||||
if err := Build(m, tf, false, "", false, cache, true, arch); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := tf.Close(); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user