1
0
Fork 0

Revert "refactor: remove debian functions to common interface"

This reverts commit 412199966e.
timestamps
dump_stack() 2023-05-18 11:32:48 +00:00
parent 412199966e
commit 90f7e62888
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC
2 changed files with 12 additions and 13 deletions

View File

@ -111,7 +111,7 @@ func kernelRelease(deb string) (r Release, err error) {
return
}
func Match(km config.KernelMask) (pkgs []string, err error) {
func MatchImagePkg(km config.KernelMask) (pkgs []string, err error) {
kernels, err := GetKernels()
if err != nil {
log.Error().Err(err).Msg("get kernels")
@ -143,7 +143,7 @@ func Match(km config.KernelMask) (pkgs []string, err error) {
return
}
func Envs(km config.KernelMask) (envs []string) {
func ContainerEnvs(km config.KernelMask) (envs []string) {
envs = append(envs, "DEBIAN_FRONTEND=noninteractive")
return
}
@ -196,7 +196,7 @@ func repositories(release Release) (repos []string) {
return
}
func Runs(km config.KernelMask) (commands []string) {
func ContainerCommands(km config.KernelMask) (commands []string) {
release := releaseFromString(km.DistroRelease)
cmdf := func(f string, s ...interface{}) {
@ -307,7 +307,7 @@ func ContainerKernels(d container.Image, kcfg *config.KernelConfig) (err error)
return
}
func Volumes(km config.KernelMask, pkgname string) (volumes container.Volumes) {
func ContainerVolumes(km config.KernelMask, pkgname string) (volumes container.Volumes) {
pkgdir := filepath.Join("volumes", km.DockerName(), pkgname)
volumes.LibModules = config.Dir(pkgdir, "/lib/modules")
@ -317,7 +317,7 @@ func Volumes(km config.KernelMask, pkgname string) (volumes container.Volumes) {
return
}
func Install(km config.KernelMask, pkgname string, headers bool) (cmds []string, err error) {
func InstallCommands(km config.KernelMask, pkgname string, headers bool) (cmds []string, err error) {
dk, err := getCachedKernel(pkgname + ".deb")
if err != nil {
return
@ -353,7 +353,7 @@ func Install(km config.KernelMask, pkgname string, headers bool) (cmds []string,
return
}
func Cleanup(km config.KernelMask, pkgname string) {
func CleanupFailed(km config.KernelMask, pkgname string) {
pkgdir := config.Dir(filepath.Join("volumes", km.DockerName(), pkgname))
log.Debug().Msgf("cleanup %s", pkgdir)

View File

@ -31,14 +31,13 @@ import (
)
func MatchPackages(km config.KernelMask) (pkgs []string, err error) {
// TODO interface for kernels match
switch km.DistroType {
case config.Ubuntu:
pkgs, err = ubuntu.Match(km)
case config.OracleLinux, config.CentOS:
pkgs, err = oraclelinux.Match(km)
case config.Debian:
pkgs, err = debian.Match(km)
pkgs, err = debian.MatchImagePkg(km)
default:
err = fmt.Errorf("%s not yet supported", km.DistroType.String())
}
@ -137,10 +136,10 @@ func GenerateBaseDockerImage(registry string, commands []config.DockerCommand,
d += "RUN " + c + "\n"
}
case config.Debian:
for _, e := range debian.Envs(sk) {
for _, e := range debian.ContainerEnvs(sk) {
d += "ENV " + e + "\n"
}
for _, c := range debian.Runs(sk) {
for _, c := range debian.ContainerCommands(sk) {
d += "RUN " + c + "\n"
}
default:
@ -212,7 +211,7 @@ func installKernel(sk config.KernelMask, pkgname string, force, headers bool) (e
if sk.DistroType == config.Debian {
// Debian has different kernels (package version) by the
// same name (ABI), so we need to separate /boot
c.Volumes = debian.Volumes(sk, pkgname)
c.Volumes = debian.ContainerVolumes(sk, pkgname)
}
volumes := c.Volumes
@ -264,13 +263,13 @@ func installKernel(sk config.KernelMask, pkgname string, force, headers bool) (e
}
case config.Debian:
var commands []string
commands, err = debian.Install(sk, pkgname, headers)
commands, err = debian.InstallCommands(sk, pkgname, headers)
if err != nil {
return
}
defer func() {
if err != nil {
debian.Cleanup(sk, pkgname)
debian.CleanupFailed(sk, pkgname)
}
}()