mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-20 09:39:08 +00:00
Add initial support for specifying the output type
Currently only supports kernel+initrd output but will add the rest soon. Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
parent
355cbcab7c
commit
4cfd00832f
@ -19,6 +19,9 @@ type Moby struct {
|
||||
Path string
|
||||
Contents string
|
||||
}
|
||||
Outputs []struct {
|
||||
Format string
|
||||
}
|
||||
}
|
||||
|
||||
type MobyImage struct {
|
||||
|
40
moby/main.go
40
moby/main.go
@ -69,8 +69,8 @@ func containersInitrd(containers []*bytes.Buffer) (*bytes.Buffer, error) {
|
||||
return w, nil
|
||||
}
|
||||
|
||||
func build() {
|
||||
config, err := ioutil.ReadFile("moby.yaml")
|
||||
func build(configfile string) {
|
||||
config, err := ioutil.ReadFile(configfile)
|
||||
if err != nil {
|
||||
log.Fatalf("Cannot open config file: %v", err)
|
||||
}
|
||||
@ -143,17 +143,33 @@ func build() {
|
||||
log.Fatalf("Failed to make initrd %v", err)
|
||||
}
|
||||
|
||||
// TODO should we tar these up? Also output to other formats
|
||||
err = ioutil.WriteFile("initrd.img", initrd.Bytes(), os.FileMode(0644))
|
||||
if err != nil {
|
||||
log.Fatalf("could not write initrd: %v", err)
|
||||
}
|
||||
err = ioutil.WriteFile("bzImage", bzimage.Bytes(), os.FileMode(0644))
|
||||
if err != nil {
|
||||
log.Fatalf("could not write kernel: %v", err)
|
||||
for _, o := range m.Outputs {
|
||||
switch o.Format {
|
||||
case "kernel+initrd":
|
||||
err = OutputKernelInitrd(bzimage.Bytes(), initrd.Bytes())
|
||||
if err != nil {
|
||||
log.Fatalf("Error writing %s output: %v", o.Format, err)
|
||||
}
|
||||
case "":
|
||||
log.Fatalf("No format specified for output")
|
||||
default:
|
||||
log.Fatalf("Unknown output type %s", o.Format)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
build()
|
||||
func OutputKernelInitrd(bzimage []byte, initrd []byte) error {
|
||||
err := ioutil.WriteFile("initrd.img", initrd, os.FileMode(0644))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = ioutil.WriteFile("bzImage", bzimage, os.FileMode(0644))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
build("moby.yaml")
|
||||
}
|
||||
|
@ -23,3 +23,5 @@ system:
|
||||
files:
|
||||
- path: etc/docker/daemon.json
|
||||
contents: '{"debug": true}'
|
||||
outputs:
|
||||
- format: kernel+initrd
|
||||
|
Loading…
Reference in New Issue
Block a user