From d733cde2ae96a22d7742ee0cf903b8f4809e7eda Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Wed, 21 Feb 2024 14:55:04 +0000 Subject: [PATCH] feat: prebuilt containers --- .github/workflows/e2e.yml | 2 +- cmd/kernel.go | 37 ++++++++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 6d8af79..5b2967f 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -132,7 +132,7 @@ jobs: echo 'Type=oneshot' >> test.service echo 'WorkingDirectory=/root/test' >> test.service echo 'TimeoutStopSec=1' >> test.service - echo 'ExecStart=/usr/local/bin/out-of-tree kernel autogen --threads=4 --max=256 --shuffle' >> test.service + echo 'ExecStart=/usr/local/bin/out-of-tree kernel --no-container-cache autogen --threads=4 --max=256 --shuffle' >> test.service echo 'ExecStart=/usr/local/bin/out-of-tree pew --qemu-timeout=10m --threads=4 --include-internal-errors' >> test.service scp test.service root@$IP:/etc/systemd/system/test.service diff --git a/cmd/kernel.go b/cmd/kernel.go index 5e2f1a5..86842ec 100644 --- a/cmd/kernel.go +++ b/cmd/kernel.go @@ -16,6 +16,7 @@ import ( "github.com/rs/zerolog/log" "code.dumpstack.io/tools/out-of-tree/artifact" + "code.dumpstack.io/tools/out-of-tree/cache" "code.dumpstack.io/tools/out-of-tree/config" "code.dumpstack.io/tools/out-of-tree/config/dotfiles" "code.dumpstack.io/tools/out-of-tree/container" @@ -24,17 +25,18 @@ import ( ) type KernelCmd struct { - NoDownload bool `help:"do not download qemu image while kernel generation"` - UseHost bool `help:"also use host kernels"` - Force bool `help:"force reinstall kernel"` - NoHeaders bool `help:"do not install kernel headers"` - Shuffle bool `help:"randomize kernels installation order"` - Retries int `help:"amount of tries for each kernel" default:"2"` - Threads int `help:"threads for parallel installation" default:"1"` - Update bool `help:"update container"` - Max int `help:"maximum kernels to download" default:"100500"` - NoPrune bool `help:"do not remove dangling or unused images from local storage after build"` - NoCfgRegen bool `help:"do not update kernels.toml"` + NoDownload bool `help:"do not download qemu image while kernel generation"` + UseHost bool `help:"also use host kernels"` + Force bool `help:"force reinstall kernel"` + NoHeaders bool `help:"do not install kernel headers"` + Shuffle bool `help:"randomize kernels installation order"` + Retries int `help:"amount of tries for each kernel" default:"2"` + Threads int `help:"threads for parallel installation" default:"1"` + Update bool `help:"update container"` + ContainerCache bool `help:"try prebuilt container images first" default:"true" negatable:""` + Max int `help:"maximum kernels to download" default:"100500"` + NoPrune bool `help:"do not remove dangling or unused images from local storage after build"` + NoCfgRegen bool `help:"do not update kernels.toml"` ContainerTimeout time.Duration `help:"container timeout"` @@ -199,6 +201,19 @@ func (cmd *KernelCmd) Generate(g *Globals, km artifact.Target) (err error) { return } + c, err := container.New(km.Distro) + if err != nil || cmd.shutdown { + return + } + + if cmd.ContainerCache { + path := cache.ContainerURL(c.Name()) + err = container.Import(path, c.Name()) + if err != nil || cmd.shutdown { + return + } + } + pkgs, err := kernel.MatchPackages(km) if err != nil || cmd.shutdown { return