refactor: move ubutu install/cleanup to module
This commit is contained in:
parent
407c1a7975
commit
6a338fc6ad
@ -82,3 +82,23 @@ func Match(km config.KernelMask) (pkgs []string, err error) {
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Install(km config.KernelMask, pkgname string, headers bool) (commands []string, err error) {
|
||||||
|
|
||||||
|
var headerspkg string
|
||||||
|
if headers {
|
||||||
|
headerspkg = strings.Replace(pkgname, "image", "headers", -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmdf := func(f string, s ...interface{}) {
|
||||||
|
commands = append(commands, fmt.Sprintf(f, s...))
|
||||||
|
}
|
||||||
|
|
||||||
|
cmdf("apt-get install -y %s %s", pkgname, headerspkg)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Cleanup(km config.KernelMask, pkgname string) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -229,12 +229,20 @@ func installKernel(sk config.KernelMask, pkgname string, force, headers bool) (e
|
|||||||
// TODO install/cleanup kernel interface
|
// TODO install/cleanup kernel interface
|
||||||
switch sk.DistroType {
|
switch sk.DistroType {
|
||||||
case config.Ubuntu:
|
case config.Ubuntu:
|
||||||
var headerspkg string
|
var commands []string
|
||||||
if headers {
|
commands, err = oraclelinux.Install(sk, pkgname, headers)
|
||||||
headerspkg = strings.Replace(pkgname, "image", "headers", -1)
|
if err != nil {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
oraclelinux.Cleanup(sk, pkgname)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
cmd += fmt.Sprintf(" && apt-get install -y %s %s", pkgname, headerspkg)
|
for _, command := range commands {
|
||||||
|
cmd += fmt.Sprintf(" && %s", command)
|
||||||
|
}
|
||||||
case config.OracleLinux, config.CentOS:
|
case config.OracleLinux, config.CentOS:
|
||||||
var commands []string
|
var commands []string
|
||||||
commands, err = oraclelinux.Install(sk, pkgname, headers)
|
commands, err = oraclelinux.Install(sk, pkgname, headers)
|
||||||
|
Loading…
Reference in New Issue
Block a user