1
0

refactor: move oracle linux runs/envs to module

This commit is contained in:
dump_stack() 2023-05-18 11:08:23 +00:00
parent 4eed03ec2a
commit 71c2b2001c
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC
2 changed files with 43 additions and 11 deletions

View File

@ -0,0 +1,37 @@
package oraclelinux
import (
"fmt"
"github.com/rs/zerolog/log"
"code.dumpstack.io/tools/out-of-tree/config"
)
func Envs(km config.KernelMask) (envs []string) {
return
}
func Runs(km config.KernelMask) (commands []string) {
cmdf := func(f string, s ...interface{}) {
commands = append(commands, fmt.Sprintf(f, s...))
}
if sk.DistroRelease < "6" {
log.Fatal().Msgf("no support for pre-EL6")
}
cmdf("sed -i 's/enabled=0/enabled=1/' /etc/yum.repos.d/*")
cmdf("sed -i 's;installonly_limit=;installonly_limit=100500;' /etc/yum.conf /etc/dnf/dnf.conf || true")
cmdf("yum -y update")
cmdf("yum -y groupinstall 'Development Tools'")
packages := "linux-firmware grubby"
if sk.DistroRelease <= "7" {
packages += " libdtrace-ctf"
}
cmdf("yum -y install %s", packages)
return
}

View File

@ -26,6 +26,7 @@ import (
"code.dumpstack.io/tools/out-of-tree/container"
"code.dumpstack.io/tools/out-of-tree/distro/centos"
"code.dumpstack.io/tools/out-of-tree/distro/debian"
"code.dumpstack.io/tools/out-of-tree/distro/oraclelinux"
"code.dumpstack.io/tools/out-of-tree/distro/ubuntu"
"code.dumpstack.io/tools/out-of-tree/fs"
)
@ -179,6 +180,7 @@ func GenerateBaseDockerImage(registry string, commands []config.DockerCommand,
d += "RUN " + c.Command + "\n"
}
// TODO container runs/envs interface
switch sk.DistroType {
case config.Ubuntu:
for _, e := range ubuntu.Envs(sk) {
@ -195,19 +197,12 @@ func GenerateBaseDockerImage(registry string, commands []config.DockerCommand,
d += "RUN " + c + "\n"
}
case config.OracleLinux:
if sk.DistroRelease < "6" {
err = fmt.Errorf("no support for pre-EL6")
return
for _, e := range oraclelinux.Envs(sk) {
d += "ENV " + e + "\n"
}
d += "RUN sed -i 's/enabled=0/enabled=1/' /etc/yum.repos.d/*\n"
d += "RUN sed -i 's;installonly_limit=;installonly_limit=100500;' /etc/yum.conf /etc/dnf/dnf.conf || true\n"
d += "RUN yum -y update\n"
d += "RUN yum -y groupinstall 'Development Tools'\n"
packages := "linux-firmware grubby"
if sk.DistroRelease <= "7" {
packages += " libdtrace-ctf"
for _, c := range oraclelinux.Runs(sk) {
d += "RUN " + c + "\n"
}
d += fmt.Sprintf("RUN yum -y install %s\n", packages)
case config.Debian:
for _, e := range debian.ContainerEnvs(sk) {
d += "ENV " + e + "\n"