mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-30 05:51:26 +00:00
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:
parent
c4c7c1e8d8
commit
4da9303b17
11
main.go
11
main.go
@ -223,13 +223,11 @@ func build(m *Moby, name string) {
|
||||
}
|
||||
|
||||
var (
|
||||
conf string
|
||||
cmdline bool
|
||||
name string
|
||||
conf string
|
||||
name string
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.BoolVar(&cmdline, "cmdline", false, "Print the kernel command line and exit")
|
||||
flag.StringVar(&name, "name", "", "Name to use for output files")
|
||||
flag.Parse()
|
||||
|
||||
@ -256,10 +254,5 @@ func main() {
|
||||
log.Fatalf("Invalid config: %v", err)
|
||||
}
|
||||
|
||||
if cmdline {
|
||||
fmt.Printf("%s\n", m.Kernel.Cmdline)
|
||||
return
|
||||
}
|
||||
|
||||
build(m, name)
|
||||
}
|
||||
|
10
output.go
10
output.go
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user