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:"
switch releaseFromString(km.DistroRelease) {
case Wheezy:
image += "wheezy-20190228"
case Jessie:
image += "jessie-20210326"
case Stretch:
image += "stretch-20220622"
default:
image += km.DistroType.String()
}
return
}
func repositories(release Release) (repos []string) {
var snapshot string var snapshot string
switch release { switch release {
// Latest snapshots that include release
case Wheezy: case Wheezy:
snapshot = "20160605T173546Z" // doesn't include snapshot repos in /etc/apt/source.list
case Jessie: snapshot = "20190321T212815Z"
snapshot = "20190212T020859Z" // case Jessie:
case Stretch: // snapshot = "20230322T152120Z"
snapshot = "20200719T110630Z" // case Stretch:
case Buster: // snapshot = "20230423T032533Z"
snapshot = "20220911T180237Z"
case Bullseye:
snapshot = "20221218T103830Z"
default: default:
log.Fatal().Msgf("%s not supported", release)
return return
} }
params := "[check-valid-until=no trusted=yes]" repo := func(archive, s string) {
mirror := "http://snapshot.debian.org" format := "deb [check-valid-until=no trusted=yes] " +
repourl := fmt.Sprintf("%s/archive/debian/%s/", mirror, snapshot) "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) if len(repos) != 0 {
cmdf("rm /etc/apt/sources.list")
repo = fmt.Sprintf("deb %s %s %s-updates main contrib", for _, repo := range repos {
params, repourl, release) 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 + "/"
} }
d += fmt.Sprintf("%s:%s\n", switch sk.DistroType {
strings.ToLower(sk.DistroType.String()), case config.Debian:
sk.DistroRelease, d += debian.ContainerImage(sk) + "\n"
) default:
d += fmt.Sprintf("%s:%s\n",
strings.ToLower(sk.DistroType.String()),
sk.DistroRelease)
}
for _, c := range commands { for _, c := range commands {
d += "RUN " + c.Command + "\n" d += "RUN " + c.Command + "\n"