1
0

feat: use old debian containers from snapshots

This commit is contained in:
dump_stack() 2023-05-14 09:53:59 +00:00
parent bb676fa491
commit f7f8a27dfa
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC
2 changed files with 59 additions and 28 deletions

View File

@ -210,47 +210,74 @@ func ContainerEnvs(km config.KernelMask) (envs []string) {
return return
} }
func ContainerCommands(km config.KernelMask) (commands []string) { func ContainerImage(km config.KernelMask) (image string) {
release := releaseFromString(km.DistroRelease) image += "debian:"
var snapshot string switch releaseFromString(km.DistroRelease) {
switch release {
case Wheezy: case Wheezy:
snapshot = "20160605T173546Z" image += "wheezy-20190228"
case Jessie: case Jessie:
snapshot = "20190212T020859Z" image += "jessie-20210326"
case Stretch: case Stretch:
snapshot = "20200719T110630Z" image += "stretch-20220622"
case Buster:
snapshot = "20220911T180237Z"
case Bullseye:
snapshot = "20221218T103830Z"
default: default:
log.Fatal().Msgf("%s not supported", release) image += km.DistroType.String()
}
return return
} }
params := "[check-valid-until=no trusted=yes]" func repositories(release Release) (repos []string) {
mirror := "http://snapshot.debian.org" var snapshot string
repourl := fmt.Sprintf("%s/archive/debian/%s/", mirror, snapshot)
switch release {
// Latest snapshots that include release
case Wheezy:
// doesn't include snapshot repos in /etc/apt/source.list
snapshot = "20190321T212815Z"
// case Jessie:
// snapshot = "20230322T152120Z"
// case Stretch:
// snapshot = "20230423T032533Z"
default:
return
}
repo := func(archive, s string) {
format := "deb [check-valid-until=no trusted=yes] " +
"http://snapshot.debian.org/archive/%s/%s " +
"%s%s main"
r := fmt.Sprintf(format, archive, snapshot, release, s)
repos = append(repos, r)
}
repo("debian", "")
repo("debian", "-updates")
repo("debian-security", "/updates")
return
}
func ContainerCommands(km config.KernelMask) (commands []string) {
release := releaseFromString(km.DistroRelease)
cmdf := func(f string, s ...interface{}) { cmdf := func(f string, s ...interface{}) {
commands = append(commands, fmt.Sprintf(f, s...)) commands = append(commands, fmt.Sprintf(f, s...))
} }
repo := fmt.Sprintf("deb %s %s %s main contrib", repos := repositories(release)
params, repourl, release)
cmdf("echo '%s' > /etc/apt/sources.list", repo)
repo = fmt.Sprintf("deb %s %s %s-updates main contrib",
params, repourl, release)
if len(repos) != 0 {
cmdf("rm /etc/apt/sources.list")
for _, repo := range repos {
cmdf("echo '%s' >> /etc/apt/sources.list", repo) cmdf("echo '%s' >> /etc/apt/sources.list", repo)
}
} else {
cmdf("sed -e '/snapshot/!d' -e 's/# deb/deb [check-valid-until=no trusted=yes]/' /etc/apt/sources.list")
}
cmdf("apt-get update") cmdf("apt-get update")
cmdf("apt-get install -y wget") cmdf("apt-get install -y wget build-essential libelf-dev git")
cmdf("mkdir -p /lib/modules") cmdf("mkdir -p /lib/modules")
return return

View File

@ -164,10 +164,14 @@ func GenerateBaseDockerImage(registry string, commands []config.DockerCommand,
d += registry + "/" d += registry + "/"
} }
switch sk.DistroType {
case config.Debian:
d += debian.ContainerImage(sk) + "\n"
default:
d += fmt.Sprintf("%s:%s\n", d += fmt.Sprintf("%s:%s\n",
strings.ToLower(sk.DistroType.String()), strings.ToLower(sk.DistroType.String()),
sk.DistroRelease, sk.DistroRelease)
) }
for _, c := range commands { for _, c := range commands {
d += "RUN " + c.Command + "\n" d += "RUN " + c.Command + "\n"