mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 10:09:07 +00:00
moby: Add informational output to build
This adds log.Info() to the main steps of the "moby build" process. By default the Info() output is shown to the user so it provides some idea of progress and what is happening. Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
parent
37545913a6
commit
e39b1ddffc
@ -92,6 +92,7 @@ func build(name string, pull bool, args []string) {
|
|||||||
containers := []*bytes.Buffer{}
|
containers := []*bytes.Buffer{}
|
||||||
|
|
||||||
if pull {
|
if pull {
|
||||||
|
log.Infof("Pull kernel image: %s", m.Kernel.Image)
|
||||||
err := dockerPull(m.Kernel.Image)
|
err := dockerPull(m.Kernel.Image)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Could not pull image %s: %v", m.Kernel.Image, err)
|
log.Fatalf("Could not pull image %s: %v", m.Kernel.Image, err)
|
||||||
@ -99,6 +100,7 @@ func build(name string, pull bool, args []string) {
|
|||||||
}
|
}
|
||||||
// get kernel bzImage and initrd tarball from container
|
// get kernel bzImage and initrd tarball from container
|
||||||
// TODO examine contents to see what names they might have
|
// TODO examine contents to see what names they might have
|
||||||
|
log.Infof("Extract kernel image: %s", m.Kernel.Image)
|
||||||
const (
|
const (
|
||||||
bzimageName = "bzImage"
|
bzimageName = "bzImage"
|
||||||
ktarName = "kernel.tar"
|
ktarName = "kernel.tar"
|
||||||
@ -116,11 +118,13 @@ func build(name string, pull bool, args []string) {
|
|||||||
|
|
||||||
// convert init image to tarball
|
// convert init image to tarball
|
||||||
if pull {
|
if pull {
|
||||||
|
log.Infof("Pull init: %s", m.Init)
|
||||||
err := dockerPull(m.Init)
|
err := dockerPull(m.Init)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Could not pull image %s: %v", m.Init, err)
|
log.Fatalf("Could not pull image %s: %v", m.Init, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.Infof("Process init: %s", m.Init)
|
||||||
init, err := ImageExtract(m.Init, "")
|
init, err := ImageExtract(m.Init, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to build init tarball: %v", err)
|
log.Fatalf("Failed to build init tarball: %v", err)
|
||||||
@ -128,13 +132,16 @@ func build(name string, pull bool, args []string) {
|
|||||||
buffer := bytes.NewBuffer(init)
|
buffer := bytes.NewBuffer(init)
|
||||||
containers = append(containers, buffer)
|
containers = append(containers, buffer)
|
||||||
|
|
||||||
|
log.Infof("Add system containers:")
|
||||||
for i, image := range m.System {
|
for i, image := range m.System {
|
||||||
if pull {
|
if pull {
|
||||||
|
log.Infof(" Pull: %s", image.Image)
|
||||||
err := dockerPull(image.Image)
|
err := dockerPull(image.Image)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Could not pull image %s: %v", image.Image, err)
|
log.Fatalf("Could not pull image %s: %v", image.Image, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.Infof(" Create OCI config for %s", image.Image)
|
||||||
config, err := ConfigToOCI(&image)
|
config, err := ConfigToOCI(&image)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to run riddler to get config.json for %s: %v", image.Image, err)
|
log.Fatalf("Failed to run riddler to get config.json for %s: %v", image.Image, err)
|
||||||
@ -149,13 +156,16 @@ func build(name string, pull bool, args []string) {
|
|||||||
containers = append(containers, buffer)
|
containers = append(containers, buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Infof("Add daemon containers:")
|
||||||
for _, image := range m.Daemon {
|
for _, image := range m.Daemon {
|
||||||
if pull {
|
if pull {
|
||||||
|
log.Infof(" Pull: %s", image.Image)
|
||||||
err := dockerPull(image.Image)
|
err := dockerPull(image.Image)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Could not pull image %s: %v", image.Image, err)
|
log.Fatalf("Could not pull image %s: %v", image.Image, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.Infof(" Create OCI config for %s", image.Image)
|
||||||
config, err := ConfigToOCI(&image)
|
config, err := ConfigToOCI(&image)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to run riddler to get config.json for %s: %v", image.Image, err)
|
log.Fatalf("Failed to run riddler to get config.json for %s: %v", image.Image, err)
|
||||||
@ -176,11 +186,13 @@ func build(name string, pull bool, args []string) {
|
|||||||
}
|
}
|
||||||
containers = append(containers, buffer)
|
containers = append(containers, buffer)
|
||||||
|
|
||||||
|
log.Infof("Create initial ram disk")
|
||||||
initrd, err := containersInitrd(containers)
|
initrd, err := containersInitrd(containers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to make initrd %v", err)
|
log.Fatalf("Failed to make initrd %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Infof("Create outputs:")
|
||||||
err = outputs(m, name, bzimage.Bytes(), initrd.Bytes())
|
err = outputs(m, name, bzimage.Bytes(), initrd.Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error writing outputs: %v", err)
|
log.Fatalf("Error writing outputs: %v", err)
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
log "github.com/Sirupsen/logrus"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -119,7 +120,9 @@ func filesystem(m *Moby) (*bytes.Buffer, error) {
|
|||||||
tw := tar.NewWriter(buf)
|
tw := tar.NewWriter(buf)
|
||||||
defer tw.Close()
|
defer tw.Close()
|
||||||
|
|
||||||
|
log.Infof("Add files:")
|
||||||
for _, f := range m.Files {
|
for _, f := range m.Files {
|
||||||
|
log.Infof(" %s", f.Path)
|
||||||
if f.Path == "" {
|
if f.Path == "" {
|
||||||
return buf, errors.New("Did not specify path for file")
|
return buf, errors.New("Did not specify path for file")
|
||||||
}
|
}
|
||||||
|
@ -133,6 +133,7 @@ func tarInitrdKernel(bzimage, initrd []byte) (*bytes.Buffer, error) {
|
|||||||
|
|
||||||
func outputImg(image, filename string, bzimage []byte, initrd []byte, args ...string) error {
|
func outputImg(image, filename string, bzimage []byte, initrd []byte, args ...string) error {
|
||||||
log.Debugf("output img: %s %s", image, filename)
|
log.Debugf("output img: %s %s", image, filename)
|
||||||
|
log.Infof(" %s", filename)
|
||||||
buf, err := tarInitrdKernel(bzimage, initrd)
|
buf, err := tarInitrdKernel(bzimage, initrd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -145,12 +146,12 @@ func outputImg(image, filename string, bzimage []byte, initrd []byte, args ...st
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Println(filename)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func outputISO(image, filename string, bzimage []byte, initrd []byte, args ...string) error {
|
func outputISO(image, filename string, bzimage []byte, initrd []byte, args ...string) error {
|
||||||
log.Debugf("output iso: %s %s", image, filename)
|
log.Debugf("output iso: %s %s", image, filename)
|
||||||
|
log.Infof(" %s", filename)
|
||||||
buf, err := tarInitrdKernel(bzimage, initrd)
|
buf, err := tarInitrdKernel(bzimage, initrd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -163,12 +164,12 @@ func outputISO(image, filename string, bzimage []byte, initrd []byte, args ...st
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Println(filename)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func outputKernelInitrd(base string, bzimage []byte, initrd []byte, cmdline string) error {
|
func outputKernelInitrd(base string, bzimage []byte, initrd []byte, cmdline string) error {
|
||||||
log.Debugf("output kernel/initrd: %s %s", base, cmdline)
|
log.Debugf("output kernel/initrd: %s %s", base, cmdline)
|
||||||
|
log.Infof(" %s %s %s", base+"-bzImage", base+"-initrd.img", base+"-cmdline")
|
||||||
err := ioutil.WriteFile(base+"-initrd.img", initrd, os.FileMode(0644))
|
err := ioutil.WriteFile(base+"-initrd.img", initrd, os.FileMode(0644))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -181,6 +182,5 @@ func outputKernelInitrd(base string, bzimage []byte, initrd []byte, cmdline stri
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Println(base + "-bzImage " + base + "-initrd.img " + base + "-cmdline")
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user