hoist kernel cmdline into moby.yaml

Signed-off-by: Tycho Andersen <tycho@docker.com>
This commit is contained in:
Tycho Andersen
2017-03-08 11:09:31 -08:00
parent 8a3ae66f64
commit a383e6bb46
12 changed files with 60 additions and 41 deletions

47
main.go
View File

@@ -4,11 +4,11 @@ import (
"archive/tar"
"bytes"
"errors"
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"os/exec"
"path/filepath"
@@ -129,17 +129,7 @@ func containersInitrd(containers []*bytes.Buffer) (*bytes.Buffer, error) {
return w, nil
}
func build(configfile string) {
config, err := ioutil.ReadFile(configfile)
if err != nil {
log.Fatalf("Cannot open config file: %v", err)
}
m, err := NewConfig(config)
if err != nil {
log.Fatalf("Invalid config: %v", err)
}
func build(m *Moby) {
containers := []*bytes.Buffer{}
// get kernel bzImage and initrd tarball from container
@@ -148,7 +138,7 @@ func build(configfile string) {
bzimageName = "bzImage"
ktarName = "kernel.tar"
)
out, err := dockerRun(m.Kernel, "tar", "cf", "-", bzimageName, ktarName)
out, err := dockerRun(m.Kernel.Image, "tar", "cf", "-", bzimageName, ktarName)
if err != nil {
log.Fatalf("Failed to extract kernel image and tarball: %v", err)
}
@@ -211,11 +201,34 @@ func build(configfile string) {
}
}
var conf = "moby.yaml"
var (
conf string
cmdline bool
)
func main() {
if len(os.Args) >= 2 {
conf = os.Args[1]
flag.BoolVar(&cmdline, "cmdline", false, "Print the kernel command line and exit")
flag.Parse()
conf = "moby.yaml"
if len(flag.Args()) > 0 {
conf = flag.Args()[0]
}
build(conf)
config, err := ioutil.ReadFile(conf)
if err != nil {
log.Fatalf("Cannot open config file: %v", err)
}
m, err := NewConfig(config)
if err != nil {
log.Fatalf("Invalid config: %v", err)
}
if cmdline {
fmt.Printf("%s\n", m.Kernel.Cmdline)
return
}
build(m)
}