From ac5f83349cd9aede9440bd303598a8a95f26ffb4 Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Thu, 6 Apr 2023 19:28:03 +0000 Subject: [PATCH] Check that files exist before copy --- kernel.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/kernel.go b/kernel.go index 0105655..faa671c 100644 --- a/kernel.go +++ b/kernel.go @@ -466,10 +466,25 @@ func installKernel(sk config.KernelMask, pkgname string, force, headers bool) (e c.Args = append(c.Args, "-v", volumes.UsrSrc+":/target/usr/src") c.Args = append(c.Args, "-v", volumes.Boot+":/target/boot") - cmd := "cp -r /lib/modules/* /target/lib/modules/" + - " && cp -r /boot/* /target/boot/" + cmd := "true" - files, err := ioutil.ReadDir(c.Volumes.UsrSrc) + files, err := ioutil.ReadDir(c.Volumes.Boot) + if err != nil { + return + } + if len(files) != 0 { + cmd += " && cp -r /boot/* /target/boot/" + } + + files, err = ioutil.ReadDir(c.Volumes.LibModules) + if err != nil { + return + } + if len(files) != 0 { + cmd += " && cp -r /lib/modules/* /target/lib/modules/" + } + + files, err = ioutil.ReadDir(c.Volumes.UsrSrc) if err != nil { return }