Output kernel command line to a file in the kernel+initrd output case

Trying to find the relevant yaml file was an issue as we now support
`--name` and it might be in a different directory, so although it is
a bit verbose outputing a whole file at least it is more consistent.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
Justin Cormack
2017-03-20 12:16:34 +00:00
parent b8aff953f0
commit 9208496d82
7 changed files with 24 additions and 20 deletions

View File

@@ -20,7 +20,7 @@ func outputs(m *Moby, base string, bzimage []byte, initrd []byte) error {
for _, o := range m.Outputs {
switch o.Format {
case "kernel+initrd":
err := outputKernelInitrd(base, bzimage, initrd)
err := outputKernelInitrd(base, bzimage, initrd, m.Kernel.Cmdline)
if err != nil {
return fmt.Errorf("Error writing %s output: %v", o.Format, err)
}
@@ -156,7 +156,7 @@ func outputISO(image, filename string, bzimage []byte, initrd []byte, args ...st
return nil
}
func outputKernelInitrd(base string, bzimage []byte, initrd []byte) error {
func outputKernelInitrd(base string, bzimage []byte, initrd []byte, cmdline string) error {
err := ioutil.WriteFile(base+"-initrd.img", initrd, os.FileMode(0644))
if err != nil {
return err
@@ -165,6 +165,10 @@ func outputKernelInitrd(base string, bzimage []byte, initrd []byte) error {
if err != nil {
return err
}
fmt.Println(base + "-bzImage " + base + "-initrd.img")
err = ioutil.WriteFile(base+"-cmdline", []byte(cmdline), os.FileMode(0644))
if err != nil {
return err
}
fmt.Println(base + "-bzImage " + base + "-initrd.img " + base + "-cmdline")
return nil
}