aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/build/linux_linux.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/build/linux_linux.go')
-rw-r--r--pkg/build/linux_linux.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/pkg/build/linux_linux.go b/pkg/build/linux_linux.go
index 0a59f3fd7..b46356db3 100644
--- a/pkg/build/linux_linux.go
+++ b/pkg/build/linux_linux.go
@@ -51,7 +51,7 @@ func embedLinuxKernel(params Params, kernelPath string) error {
return fmt.Errorf("mount(%vp1, %v) failed: %v", loopFile, mountDir, err)
}
defer unix.Unmount(mountDir, 0)
- if err := osutil.CopyFile(kernelPath, filepath.Join(mountDir, "vmlinuz")); err != nil {
+ if err := copyKernel(mountDir, kernelPath); err != nil {
return err
}
if params.SysctlFile != "" {
@@ -65,6 +65,18 @@ func embedLinuxKernel(params Params, kernelPath string) error {
return osutil.CopyFile(imageFile, filepath.Join(params.OutputDir, "image"))
}
+func copyKernel(mountDir, kernelPath string) error {
+ // Try several common locations where the kernel can be.
+ for _, targetPath := range []string{"boot/vmlinuz", "boot/bzImage", "vmlinuz", "bzImage"} {
+ fullPath := filepath.Join(mountDir, filepath.FromSlash(targetPath))
+ if !osutil.IsExist(fullPath) {
+ continue
+ }
+ return osutil.CopyFile(kernelPath, fullPath)
+ }
+ return fmt.Errorf("did not find kernel in the template image")
+}
+
func linuxSetupLoop(imageFile string) (int, string, error) {
image, err := unix.Open(imageFile, unix.O_RDWR, 0)
if err != nil {