1
0

refactor: use the same name as in config

This commit is contained in:
2023-05-18 18:27:51 +00:00
parent 6385ce92e3
commit d551cc8fc4
15 changed files with 46 additions and 46 deletions

View File

@@ -8,11 +8,11 @@ import (
"code.dumpstack.io/tools/out-of-tree/config"
)
func Envs(km config.KernelMask) (envs []string) {
func Envs(km config.Target) (envs []string) {
return
}
func Runs(km config.KernelMask) (commands []string) {
func Runs(km config.Target) (commands []string) {
cmdf := func(f string, s ...interface{}) {
commands = append(commands, fmt.Sprintf(f, s...))
}

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 Match(km config.Target) (pkgs []string, err error) {
kernels, err := GetKernels()
if err != nil {
log.Error().Err(err).Msg("get kernels")
@@ -143,12 +143,12 @@ func Match(km config.KernelMask) (pkgs []string, err error) {
return
}
func Envs(km config.KernelMask) (envs []string) {
func Envs(km config.Target) (envs []string) {
envs = append(envs, "DEBIAN_FRONTEND=noninteractive")
return
}
func ContainerImage(km config.KernelMask) (image string) {
func ContainerImage(km config.Target) (image string) {
image += "debian:"
switch releaseFromString(km.Distro.Release) {
@@ -196,7 +196,7 @@ func repositories(release Release) (repos []string) {
return
}
func Runs(km config.KernelMask) (commands []string) {
func Runs(km config.Target) (commands []string) {
release := releaseFromString(km.Distro.Release)
cmdf := func(f string, s ...interface{}) {
@@ -306,7 +306,7 @@ func ContainerKernels(d container.Image, kcfg *config.KernelConfig) (err error)
return
}
func Volumes(km config.KernelMask, pkgname string) (volumes container.Volumes) {
func Volumes(km config.Target, pkgname string) (volumes container.Volumes) {
pkgdir := filepath.Join("volumes", km.DockerName(), pkgname)
volumes.LibModules = config.Dir(pkgdir, "/lib/modules")
@@ -316,7 +316,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 Install(km config.Target, pkgname string, headers bool) (cmds []string, err error) {
dk, err := getCachedKernel(pkgname + ".deb")
if err != nil {
return
@@ -352,7 +352,7 @@ func Install(km config.KernelMask, pkgname string, headers bool) (cmds []string,
return
}
func Cleanup(km config.KernelMask, pkgname string) {
func Cleanup(km config.Target, pkgname string) {
pkgdir := config.Dir(filepath.Join("volumes", km.DockerName(), pkgname))
log.Debug().Msgf("cleanup %s", pkgdir)

View File

@@ -24,7 +24,7 @@ func TestMatch(t *testing.T) {
config.Directory = tmp
km := config.KernelMask{
km := config.Target{
ReleaseMask: "3.2.0-4",
Distro: distro.Distro{Release: "7"},
}

View File

@@ -12,11 +12,11 @@ import (
"code.dumpstack.io/tools/out-of-tree/container"
)
func Envs(km config.KernelMask) (envs []string) {
func Envs(km config.Target) (envs []string) {
return
}
func Runs(km config.KernelMask) (commands []string) {
func Runs(km config.Target) (commands []string) {
cmdf := func(f string, s ...interface{}) {
commands = append(commands, fmt.Sprintf(f, s...))
}
@@ -40,7 +40,7 @@ func Runs(km config.KernelMask) (commands []string) {
return
}
func Match(km config.KernelMask) (pkgs []string, err error) {
func Match(km config.Target) (pkgs []string, err error) {
// FIXME timeout should be in global out-of-tree config
c, err := container.New(km.DockerName(), time.Hour)
if err != nil {
@@ -76,7 +76,7 @@ func Match(km config.KernelMask) (pkgs []string, err error) {
return
}
func Install(km config.KernelMask, pkgname string, headers bool) (commands []string, err error) {
func Install(km config.Target, pkgname string, headers bool) (commands []string, err error) {
var headerspkg string
if headers {
if strings.Contains(pkgname, "uek") {
@@ -113,6 +113,6 @@ func Install(km config.KernelMask, pkgname string, headers bool) (commands []str
return
}
func Cleanup(km config.KernelMask, pkgname string) {
func Cleanup(km config.Target, pkgname string) {
return
}

View File

@@ -10,12 +10,12 @@ import (
"code.dumpstack.io/tools/out-of-tree/container"
)
func Envs(km config.KernelMask) (envs []string) {
func Envs(km config.Target) (envs []string) {
envs = append(envs, "DEBIAN_FRONTEND=noninteractive")
return
}
func Runs(km config.KernelMask) (commands []string) {
func Runs(km config.Target) (commands []string) {
cmdf := func(f string, s ...interface{}) {
commands = append(commands, fmt.Sprintf(f, s...))
}
@@ -53,7 +53,7 @@ func Runs(km config.KernelMask) (commands []string) {
return
}
func Match(km config.KernelMask) (pkgs []string, err error) {
func Match(km config.Target) (pkgs []string, err error) {
// FIXME timeout should be in global out-of-tree config
c, err := container.New(km.DockerName(), time.Hour)
if err != nil {
@@ -83,7 +83,7 @@ func Match(km config.KernelMask) (pkgs []string, err error) {
return
}
func Install(km config.KernelMask, pkgname string, headers bool) (commands []string, err error) {
func Install(km config.Target, pkgname string, headers bool) (commands []string, err error) {
var headerspkg string
if headers {
@@ -99,6 +99,6 @@ func Install(km config.KernelMask, pkgname string, headers bool) (commands []str
return
}
func Cleanup(km config.KernelMask, pkgname string) {
func Cleanup(km config.Target, pkgname string) {
return
}