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
This commit is contained in:
17
main.go
17
main.go
@@ -86,18 +86,29 @@ func bootDeploy(workDir string, outDir string) error {
|
|||||||
if len(kernels) == 0 {
|
if len(kernels) == 0 {
|
||||||
return errors.New("Unable to find any kernels at " + filepath.Join(outDir, "vmlinuz*"))
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer kernFile.Close()
|
defer kernFd.Close()
|
||||||
|
|
||||||
kernFileCopy, err := os.Create(filepath.Join(workDir, "vmlinuz"))
|
kernFileCopy, err := os.Create(filepath.Join(workDir, "vmlinuz"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err = io.Copy(kernFileCopy, kernFile); err != nil {
|
if _, err = io.Copy(kernFileCopy, kernFd); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
kernFileCopy.Close()
|
kernFileCopy.Close()
|
||||||
|
Reference in New Issue
Block a user