mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 01:59:07 +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
|
Path string
|
||||||
Contents string
|
Contents string
|
||||||
}
|
}
|
||||||
|
Outputs []struct {
|
||||||
|
Format string
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type MobyImage struct {
|
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
|
return w, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func build() {
|
func build(configfile string) {
|
||||||
config, err := ioutil.ReadFile("moby.yaml")
|
config, err := ioutil.ReadFile(configfile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Cannot open config file: %v", err)
|
log.Fatalf("Cannot open config file: %v", err)
|
||||||
}
|
}
|
||||||
@ -143,17 +143,33 @@ func build() {
|
|||||||
log.Fatalf("Failed to make initrd %v", err)
|
log.Fatalf("Failed to make initrd %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO should we tar these up? Also output to other formats
|
for _, o := range m.Outputs {
|
||||||
err = ioutil.WriteFile("initrd.img", initrd.Bytes(), os.FileMode(0644))
|
switch o.Format {
|
||||||
if err != nil {
|
case "kernel+initrd":
|
||||||
log.Fatalf("could not write initrd: %v", err)
|
err = OutputKernelInitrd(bzimage.Bytes(), initrd.Bytes())
|
||||||
}
|
if err != nil {
|
||||||
err = ioutil.WriteFile("bzImage", bzimage.Bytes(), os.FileMode(0644))
|
log.Fatalf("Error writing %s output: %v", o.Format, err)
|
||||||
if err != nil {
|
}
|
||||||
log.Fatalf("could not write kernel: %v", err)
|
case "":
|
||||||
|
log.Fatalf("No format specified for output")
|
||||||
|
default:
|
||||||
|
log.Fatalf("Unknown output type %s", o.Format)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func OutputKernelInitrd(bzimage []byte, initrd []byte) error {
|
||||||
build()
|
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:
|
files:
|
||||||
- path: etc/docker/daemon.json
|
- path: etc/docker/daemon.json
|
||||||
contents: '{"debug": true}'
|
contents: '{"debug": true}'
|
||||||
|
outputs:
|
||||||
|
- format: kernel+initrd
|
||||||
|
Loading…
Reference in New Issue
Block a user