From 2104f9adcb51724d24734d0d21b13f5723c0984a Mon Sep 17 00:00:00 2001 From: Clayton Craft Date: Thu, 16 Sep 2021 15:15:43 -0700 Subject: [PATCH] bootDeploy: ignore suffixes added by boot-deploy when copying kernel (MR 11) The glob might result in a vmlinuz-* filename that causes mkinitfs to copy a modified kernel file to the boot-deploy working directory. This excludes files that boot-deploy has touched from being copied/used by boot-deploy (cherry picked from commit 0925cbd8acc33362d758fd1af8257feb02730ed9) --- main.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 8c4de9f..90d395f 100644 --- a/main.go +++ b/main.go @@ -86,18 +86,29 @@ func bootDeploy(workDir string, outDir string) error { if len(kernels) == 0 { return errors.New("Unable to find any kernels at " + filepath.Join(outDir, "vmlinuz*")) } - kernFile, err := os.Open(kernels[0]) + + // Pick a kernel that does not have suffixes added by boot-deploy + var kernFile string + for _, f := range kernels { + if strings.HasSuffix(f, "-dtb") || strings.HasSuffix(f, "-mtk") { + continue + } + kernFile = f + break + } + + kernFd, err := os.Open(kernFile) if err != nil { return err } - defer kernFile.Close() + defer kernFd.Close() kernFileCopy, err := os.Create(filepath.Join(workDir, "vmlinuz")) if err != nil { return err } - if _, err = io.Copy(kernFileCopy, kernFile); err != nil { + if _, err = io.Copy(kernFileCopy, kernFd); err != nil { return err } kernFileCopy.Close()