refactor: move oracle linux install/cleanup to module
This commit is contained in:
parent
99c9346995
commit
407c1a7975
@ -75,3 +75,44 @@ 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 {
|
||||||
|
if strings.Contains(pkgname, "uek") {
|
||||||
|
headerspkg = strings.Replace(pkgname,
|
||||||
|
"kernel-uek", "kernel-uek-devel", -1)
|
||||||
|
} else {
|
||||||
|
headerspkg = strings.Replace(pkgname,
|
||||||
|
"kernel", "kernel-devel", -1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cmdf := func(f string, s ...interface{}) {
|
||||||
|
commands = append(commands, fmt.Sprintf(f, s...))
|
||||||
|
}
|
||||||
|
|
||||||
|
cmdf("yum -y install %s %s", pkgname, headerspkg)
|
||||||
|
|
||||||
|
var version string
|
||||||
|
if strings.Contains(pkgname, "uek") {
|
||||||
|
version = strings.Replace(pkgname, "kernel-uek-", "", -1)
|
||||||
|
} else {
|
||||||
|
version = strings.Replace(pkgname, "kernel-", "", -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if km.DistroRelease <= "7" {
|
||||||
|
cmdf("dracut -v --add-drivers 'e1000 ext4' -f "+
|
||||||
|
"/boot/initramfs-%s.img %s", version, version)
|
||||||
|
} else {
|
||||||
|
cmdf("dracut -v --add-drivers 'ata_piix libata' "+
|
||||||
|
"--force-drivers 'e1000 ext4 sd_mod' -f "+
|
||||||
|
"/boot/initramfs-%s.img %s", version, version)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Cleanup(km config.KernelMask, pkgname string) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -226,6 +226,7 @@ func installKernel(sk config.KernelMask, pkgname string, force, headers bool) (e
|
|||||||
// TODO use list of commands instead of appending to string
|
// TODO use list of commands instead of appending to string
|
||||||
cmd := "true"
|
cmd := "true"
|
||||||
|
|
||||||
|
// TODO install/cleanup kernel interface
|
||||||
switch sk.DistroType {
|
switch sk.DistroType {
|
||||||
case config.Ubuntu:
|
case config.Ubuntu:
|
||||||
var headerspkg string
|
var headerspkg string
|
||||||
@ -235,32 +236,19 @@ func installKernel(sk config.KernelMask, pkgname string, force, headers bool) (e
|
|||||||
|
|
||||||
cmd += fmt.Sprintf(" && apt-get install -y %s %s", pkgname, headerspkg)
|
cmd += fmt.Sprintf(" && apt-get install -y %s %s", pkgname, headerspkg)
|
||||||
case config.OracleLinux, config.CentOS:
|
case config.OracleLinux, config.CentOS:
|
||||||
var headerspkg string
|
var commands []string
|
||||||
if headers {
|
commands, err = oraclelinux.Install(sk, pkgname, headers)
|
||||||
if strings.Contains(pkgname, "uek") {
|
if err != nil {
|
||||||
headerspkg = strings.Replace(pkgname,
|
return
|
||||||
"kernel-uek", "kernel-uek-devel", -1)
|
|
||||||
} else {
|
|
||||||
headerspkg = strings.Replace(pkgname,
|
|
||||||
"kernel", "kernel-devel", -1)
|
|
||||||
}
|
}
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
oraclelinux.Cleanup(sk, pkgname)
|
||||||
}
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
cmd += fmt.Sprintf(" && yum -y install %s %s", pkgname, headerspkg)
|
for _, command := range commands {
|
||||||
|
cmd += fmt.Sprintf(" && %s", command)
|
||||||
var version string
|
|
||||||
if strings.Contains(pkgname, "uek") {
|
|
||||||
version = strings.Replace(pkgname, "kernel-uek-", "", -1)
|
|
||||||
} else {
|
|
||||||
version = strings.Replace(pkgname, "kernel-", "", -1)
|
|
||||||
}
|
|
||||||
|
|
||||||
if sk.DistroRelease <= "7" {
|
|
||||||
cmd += fmt.Sprintf(" && dracut -v --add-drivers 'e1000 ext4' -f "+
|
|
||||||
"/boot/initramfs-%s.img %s", version, version)
|
|
||||||
} else {
|
|
||||||
cmd += fmt.Sprintf(" && dracut -v --add-drivers 'ata_piix libata' --force-drivers 'e1000 ext4 sd_mod' -f "+
|
|
||||||
"/boot/initramfs-%s.img %s", version, version)
|
|
||||||
}
|
}
|
||||||
case config.Debian:
|
case config.Debian:
|
||||||
var commands []string
|
var commands []string
|
||||||
|
Loading…
Reference in New Issue
Block a user