Install kernels to tmp directory first
This commit is contained in:
parent
604d21e4a2
commit
29af467bee
45
kernel.go
45
kernel.go
@ -382,11 +382,32 @@ func generateBaseDockerImage(registry string, commands []config.DockerCommand,
|
||||
return
|
||||
}
|
||||
|
||||
func copyDirContent(source, target string) (err error) {
|
||||
files, err := ioutil.ReadDir(source)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if len(files) != 0 {
|
||||
_, err = sh(source, "cp -r * "+target+"/")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func installKernel(sk config.KernelMask, pkgname string, force, headers bool) (err error) {
|
||||
tmpdir, err := os.MkdirTemp("", "out-of-tree-"+pkgname+"-")
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("make tmp directory")
|
||||
}
|
||||
defer os.RemoveAll(tmpdir)
|
||||
|
||||
slog := log.With().
|
||||
Str("distro_type", sk.DistroType.String()).
|
||||
Str("distro_release", sk.DistroRelease).
|
||||
Str("pkg", pkgname).
|
||||
Str("tmpdir", tmpdir).
|
||||
Logger()
|
||||
|
||||
c, err := NewContainer(sk.DockerName(), time.Hour) // TODO conf
|
||||
@ -410,6 +431,17 @@ func installKernel(sk config.KernelMask, pkgname string, force, headers bool) (e
|
||||
}
|
||||
}
|
||||
|
||||
volumes := c.Volumes
|
||||
|
||||
c.Volumes.LibModules = fmt.Sprintf("%s/libmodules", tmpdir)
|
||||
os.MkdirAll(c.Volumes.LibModules, 0777)
|
||||
|
||||
c.Volumes.UsrSrc = fmt.Sprintf("%s/usrsrc", tmpdir)
|
||||
os.MkdirAll(c.Volumes.UsrSrc, 0777)
|
||||
|
||||
c.Volumes.Boot = fmt.Sprintf("%s/boot", tmpdir)
|
||||
os.MkdirAll(c.Volumes.Boot, 0777)
|
||||
|
||||
slog.Debug().Msgf("Installing kernel")
|
||||
|
||||
switch sk.DistroType {
|
||||
@ -451,6 +483,19 @@ func installKernel(sk config.KernelMask, pkgname string, force, headers bool) (e
|
||||
return
|
||||
}
|
||||
|
||||
err = copyDirContent(c.Volumes.LibModules, volumes.LibModules)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = copyDirContent(c.Volumes.UsrSrc, volumes.UsrSrc)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = copyDirContent(c.Volumes.Boot, volumes.Boot)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
slog.Debug().Msgf("Success")
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user