fix: clean ubuntu modules package
This commit is contained in:
parent
a607ce62d1
commit
73b1edd1cb
48
distro/ubuntu/ubuntu.go
Normal file
48
distro/ubuntu/ubuntu.go
Normal file
@ -0,0 +1,48 @@
|
||||
package ubuntu
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"code.dumpstack.io/tools/out-of-tree/config"
|
||||
)
|
||||
|
||||
func Envs(km config.KernelMask) (envs []string) {
|
||||
envs = append(envs, "DEBIAN_FRONTEND=noninteractive")
|
||||
return
|
||||
}
|
||||
|
||||
func Runs(km config.KernelMask) (commands []string) {
|
||||
cmdf := func(f string, s ...interface{}) {
|
||||
commands = append(commands, fmt.Sprintf(f, s...))
|
||||
}
|
||||
|
||||
if km.DistroRelease < "14.04" {
|
||||
cmdf("sed -i 's/archive.ubuntu.com/old-releases.ubuntu.com/' " +
|
||||
"/etc/apt/sources.list")
|
||||
}
|
||||
|
||||
cmdf("apt-get update")
|
||||
cmdf("apt-get install -y build-essential libelf-dev")
|
||||
cmdf("apt-get install -y wget git")
|
||||
|
||||
if km.DistroRelease < "14.04" {
|
||||
return
|
||||
}
|
||||
|
||||
cmdf("apt-get install -y libseccomp-dev")
|
||||
|
||||
// Install and remove a single kernel and headers.
|
||||
// This ensures that all dependencies are cached.
|
||||
|
||||
cmdf("export TMP_HEADERS=$(apt-cache search " +
|
||||
"--names-only '^linux-headers-[0-9\\.\\-]*-generic' " +
|
||||
"| awk '{ print $1 }' | head -n 1)")
|
||||
|
||||
cmdf("export TMP_KERNEL=$(echo $TMP_HEADERS | sed 's/headers/image/')")
|
||||
cmdf("export TMP_MODULES=$(echo $TMP_HEADERS | sed 's/headers/modules/')")
|
||||
|
||||
cmdf("apt-get install -y $TMP_HEADERS $TMP_KERNEL $TMP_MODULES")
|
||||
cmdf("apt-get remove -y $TMP_HEADERS $TMP_KERNEL $TMP_MODULES")
|
||||
|
||||
return
|
||||
}
|
@ -25,6 +25,7 @@ import (
|
||||
"code.dumpstack.io/tools/out-of-tree/config"
|
||||
"code.dumpstack.io/tools/out-of-tree/container"
|
||||
"code.dumpstack.io/tools/out-of-tree/distro/debian"
|
||||
"code.dumpstack.io/tools/out-of-tree/distro/ubuntu"
|
||||
"code.dumpstack.io/tools/out-of-tree/fs"
|
||||
)
|
||||
|
||||
@ -179,21 +180,12 @@ func GenerateBaseDockerImage(registry string, commands []config.DockerCommand,
|
||||
|
||||
switch sk.DistroType {
|
||||
case config.Ubuntu:
|
||||
if sk.DistroRelease < "14.04" {
|
||||
d += "RUN sed -i 's/archive.ubuntu.com/old-releases.ubuntu.com/' /etc/apt/sources.list\n"
|
||||
for _, e := range ubuntu.Envs(sk) {
|
||||
d += "ENV " + e + "\n"
|
||||
}
|
||||
d += "ENV DEBIAN_FRONTEND=noninteractive\n"
|
||||
d += "RUN apt-get update\n"
|
||||
d += "RUN apt-get install -y build-essential libelf-dev\n"
|
||||
d += "RUN apt-get install -y wget git\n"
|
||||
// Install a single kernel and headers to ensure all dependencies are cached
|
||||
if sk.DistroRelease >= "14.04" {
|
||||
d += "RUN export PKGNAME=$(apt-cache search --names-only '^linux-headers-[0-9\\.\\-]*-generic' | awk '{ print $1 }' | head -n 1); " +
|
||||
"apt-get install -y $PKGNAME $(echo $PKGNAME | sed 's/headers/image/'); " +
|
||||
"apt-get remove -y $PKGNAME $(echo $PKGNAME | sed 's/headers/image/')\n"
|
||||
d += "RUN apt-get install -y libseccomp-dev\n"
|
||||
for _, c := range ubuntu.Runs(sk) {
|
||||
d += "RUN " + c + "\n"
|
||||
}
|
||||
d += "RUN mkdir -p /lib/modules\n"
|
||||
case config.CentOS:
|
||||
var repos []string
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user