From abcf2c10135304db891c1792c63c0d0e673893c9 Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Wed, 24 May 2023 16:43:25 +0000 Subject: [PATCH] fix: support updating containers --- container/container.go | 11 +++++++++++ kernel.go | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/container/container.go b/container/container.go index 42f718e..df3a513 100644 --- a/container/container.go +++ b/container/container.go @@ -33,6 +33,10 @@ var Timeout = time.Hour var Commands []config.DockerCommand +// Not thread-safe, but for our case there is no cmdline parameters +// to update separate containers anyway +var Update = false + type Image struct { Name string Distro distro.Distro @@ -152,6 +156,10 @@ func (c Container) Name() string { } func (c Container) Exist() (yes bool) { + if Update { + return false + } + cmd := exec.Command(Runtime, "images", "-q", c.name) c.Log.Debug().Msgf("run %v", cmd) @@ -231,6 +239,9 @@ func (c Container) Build(image string, envs, runs []string) (err error) { func (c Container) build(imagePath string) (output string, err error) { args := []string{"build"} + if Update { + args = append(args, "--pull", "--no-cache") + } args = append(args, "-t", c.name, imagePath) cmd := exec.Command(Runtime, args...) diff --git a/kernel.go b/kernel.go index fd28e0f..aa64771 100644 --- a/kernel.go +++ b/kernel.go @@ -128,7 +128,9 @@ func (cmd *KernelCmd) GenKernel(km config.Target, pkg string, max *int) { } func (cmd *KernelCmd) Generate(g *Globals, km config.Target, max int) (err error) { - // TODO cmd.Update + if cmd.Update { + container.Update = true + } cmd.kcfg, err = config.ReadKernelConfig(g.Config.Kernels) if err != nil {