mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-23 02:51:55 +00:00
output: Add ucode.cpio to the tar-kernel-initrd format
Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
parent
2b1a611bab
commit
1d24454438
@ -39,12 +39,11 @@ var outFuns = map[string]func(string, io.Reader, int) error{
|
|||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
"tar-kernel-initrd": func(base string, image io.Reader, size int) error {
|
"tar-kernel-initrd": func(base string, image io.Reader, size int) error {
|
||||||
kernel, initrd, cmdline, _, err := tarToInitrd(image)
|
kernel, initrd, cmdline, ucode, err := tarToInitrd(image)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error converting to initrd: %v", err)
|
return fmt.Errorf("Error converting to initrd: %v", err)
|
||||||
}
|
}
|
||||||
// TODO: Handle ucode
|
if err := outputKernelInitrdTarball(base, kernel, initrd, cmdline, ucode); err != nil {
|
||||||
if err := outputKernelInitrdTarball(base, kernel, initrd, cmdline); err != nil {
|
|
||||||
return fmt.Errorf("Error writing kernel+initrd tarball output: %v", err)
|
return fmt.Errorf("Error writing kernel+initrd tarball output: %v", err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -332,7 +331,7 @@ func outputKernelInitrd(base string, kernel []byte, initrd []byte, cmdline strin
|
|||||||
return ioutil.WriteFile(base+"-cmdline", []byte(cmdline), os.FileMode(0644))
|
return ioutil.WriteFile(base+"-cmdline", []byte(cmdline), os.FileMode(0644))
|
||||||
}
|
}
|
||||||
|
|
||||||
func outputKernelInitrdTarball(base string, kernel []byte, initrd []byte, cmdline string) error {
|
func outputKernelInitrdTarball(base string, kernel []byte, initrd []byte, cmdline string, ucode []byte) error {
|
||||||
log.Debugf("output kernel/initrd tarball: %s %s", base, cmdline)
|
log.Debugf("output kernel/initrd tarball: %s %s", base, cmdline)
|
||||||
log.Infof(" %s", base+"-initrd.tar")
|
log.Infof(" %s", base+"-initrd.tar")
|
||||||
f, err := os.Create(base + "-initrd.tar")
|
f, err := os.Create(base + "-initrd.tar")
|
||||||
@ -374,5 +373,18 @@ func outputKernelInitrdTarball(base string, kernel []byte, initrd []byte, cmdlin
|
|||||||
if _, err := tw.Write([]byte(cmdline)); err != nil {
|
if _, err := tw.Write([]byte(cmdline)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if len(ucode) != 0 {
|
||||||
|
hdr := &tar.Header{
|
||||||
|
Name: "ucode.cpio",
|
||||||
|
Mode: 0644,
|
||||||
|
Size: int64(len(ucode)),
|
||||||
|
}
|
||||||
|
if err := tw.WriteHeader(hdr); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if _, err := tw.Write(ucode); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
return tw.Close()
|
return tw.Close()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user