From e39b1ddffc80dfd695699797453aac321787f7e6 Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Wed, 29 Mar 2017 10:53:18 +0100 Subject: [PATCH] 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 --- src/cmd/moby/build.go | 12 ++++++++++++ src/cmd/moby/config.go | 3 +++ src/cmd/moby/output.go | 6 +++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/cmd/moby/build.go b/src/cmd/moby/build.go index 8b3711abc..7d7d6f61f 100644 --- a/src/cmd/moby/build.go +++ b/src/cmd/moby/build.go @@ -92,6 +92,7 @@ func build(name string, pull bool, args []string) { containers := []*bytes.Buffer{} if pull { + log.Infof("Pull kernel image: %s", m.Kernel.Image) err := dockerPull(m.Kernel.Image) if err != nil { 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 // TODO examine contents to see what names they might have + log.Infof("Extract kernel image: %s", m.Kernel.Image) const ( bzimageName = "bzImage" ktarName = "kernel.tar" @@ -116,11 +118,13 @@ func build(name string, pull bool, args []string) { // convert init image to tarball if pull { + log.Infof("Pull init: %s", m.Init) err := dockerPull(m.Init) if err != nil { log.Fatalf("Could not pull image %s: %v", m.Init, err) } } + log.Infof("Process init: %s", m.Init) init, err := ImageExtract(m.Init, "") if err != nil { 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) containers = append(containers, buffer) + log.Infof("Add system containers:") for i, image := range m.System { if pull { + log.Infof(" Pull: %s", image.Image) err := dockerPull(image.Image) if err != nil { log.Fatalf("Could not pull image %s: %v", image.Image, err) } } + log.Infof(" Create OCI config for %s", image.Image) config, err := ConfigToOCI(&image) if err != nil { 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) } + log.Infof("Add daemon containers:") for _, image := range m.Daemon { if pull { + log.Infof(" Pull: %s", image.Image) err := dockerPull(image.Image) if err != nil { log.Fatalf("Could not pull image %s: %v", image.Image, err) } } + log.Infof(" Create OCI config for %s", image.Image) config, err := ConfigToOCI(&image) if err != nil { 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) + log.Infof("Create initial ram disk") initrd, err := containersInitrd(containers) if err != nil { log.Fatalf("Failed to make initrd %v", err) } + log.Infof("Create outputs:") err = outputs(m, name, bzimage.Bytes(), initrd.Bytes()) if err != nil { log.Fatalf("Error writing outputs: %v", err) diff --git a/src/cmd/moby/config.go b/src/cmd/moby/config.go index 58fbbcfdd..0f19c0514 100644 --- a/src/cmd/moby/config.go +++ b/src/cmd/moby/config.go @@ -9,6 +9,7 @@ import ( "strconv" "strings" + log "github.com/Sirupsen/logrus" "gopkg.in/yaml.v2" ) @@ -119,7 +120,9 @@ func filesystem(m *Moby) (*bytes.Buffer, error) { tw := tar.NewWriter(buf) defer tw.Close() + log.Infof("Add files:") for _, f := range m.Files { + log.Infof(" %s", f.Path) if f.Path == "" { return buf, errors.New("Did not specify path for file") } diff --git a/src/cmd/moby/output.go b/src/cmd/moby/output.go index 909c6c1ee..609b1b311 100644 --- a/src/cmd/moby/output.go +++ b/src/cmd/moby/output.go @@ -133,6 +133,7 @@ func tarInitrdKernel(bzimage, initrd []byte) (*bytes.Buffer, error) { func outputImg(image, filename string, bzimage []byte, initrd []byte, args ...string) error { log.Debugf("output img: %s %s", image, filename) + log.Infof(" %s", filename) buf, err := tarInitrdKernel(bzimage, initrd) if err != nil { return err @@ -145,12 +146,12 @@ func outputImg(image, filename string, bzimage []byte, initrd []byte, args ...st if err != nil { return err } - fmt.Println(filename) return nil } func outputISO(image, filename string, bzimage []byte, initrd []byte, args ...string) error { log.Debugf("output iso: %s %s", image, filename) + log.Infof(" %s", filename) buf, err := tarInitrdKernel(bzimage, initrd) if err != nil { return err @@ -163,12 +164,12 @@ func outputISO(image, filename string, bzimage []byte, initrd []byte, args ...st if err != nil { return err } - fmt.Println(filename) return nil } func outputKernelInitrd(base string, bzimage []byte, initrd []byte, cmdline string) error { 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)) if err != nil { return err @@ -181,6 +182,5 @@ func outputKernelInitrd(base string, bzimage []byte, initrd []byte, cmdline stri if err != nil { return err } - fmt.Println(base + "-bzImage " + base + "-initrd.img " + base + "-cmdline") return nil }