From d3a575e5e36e0c6cce3824451f99753483b019a2 Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Thu, 6 Jun 2024 12:59:04 +0000 Subject: [PATCH] fix: containers update --- cmd/kernel.go | 2 +- container/container.go | 4 ++++ distro/centos/centos.go | 9 +++------ distro/debian/debian.go | 8 +++----- distro/opensuse/opensuse.go | 8 +++----- distro/oraclelinux/oraclelinux.go | 9 +++------ distro/ubuntu/ubuntu.go | 8 +++----- 7 files changed, 20 insertions(+), 28 deletions(-) diff --git a/cmd/kernel.go b/cmd/kernel.go index 02f1e19..5c06f96 100644 --- a/cmd/kernel.go +++ b/cmd/kernel.go @@ -172,7 +172,7 @@ func (cmd *KernelCmd) fetchContainerCache(c container.Container) { if !cmd.ContainerCache { return } - if c.Exist() { + if c.Exist() && container.UseCache { return } diff --git a/container/container.go b/container/container.go index d496096..e1affc8 100644 --- a/container/container.go +++ b/container/container.go @@ -241,6 +241,10 @@ func (c Container) Exist() (yes bool) { } func (c Container) Build(image string, envs, runs []string) (err error) { + if c.Exist() && UseCache { + return + } + cdir := dotfiles.Dir("containers", c.name) cfile := filepath.Join(cdir, "Dockerfile") diff --git a/distro/centos/centos.go b/distro/centos/centos.go index ca1041d..bee6986 100644 --- a/distro/centos/centos.go +++ b/distro/centos/centos.go @@ -37,12 +37,9 @@ func (centos CentOS) Packages() (pkgs []string, err error) { return } - if !c.Exist() { - err = c.Build("centos:"+centos.release, - centos.envs(), centos.runs()) - if err != nil { - return - } + err = c.Build("centos:"+centos.release, centos.envs(), centos.runs()) + if err != nil { + return } cmd := "yum search kernel --showduplicates 2>/dev/null " + diff --git a/distro/debian/debian.go b/distro/debian/debian.go index b139b67..a7818c1 100644 --- a/distro/debian/debian.go +++ b/distro/debian/debian.go @@ -54,11 +54,9 @@ func (d Debian) Packages() (packages []string, err error) { return } - if !c.Exist() { - err = c.Build(d.image(), d.envs(), d.runs()) - if err != nil { - return - } + err = c.Build(d.image(), d.envs(), d.runs()) + if err != nil { + return } kernels, err := GetKernels() diff --git a/distro/opensuse/opensuse.go b/distro/opensuse/opensuse.go index b785f3a..3660278 100644 --- a/distro/opensuse/opensuse.go +++ b/distro/opensuse/opensuse.go @@ -70,11 +70,9 @@ func (suse OpenSUSE) Packages() (pkgs []string, err error) { name = "opensuse/leap:" + suse.release } - if !c.Exist() { - err = c.Build(name, suse.envs(), suse.runs()) - if err != nil { - return - } + err = c.Build(name, suse.envs(), suse.runs()) + if err != nil { + return } cmd := "zypper search -s --match-exact kernel-default | grep x86_64 " + diff --git a/distro/oraclelinux/oraclelinux.go b/distro/oraclelinux/oraclelinux.go index 05c97d6..0e400c8 100644 --- a/distro/oraclelinux/oraclelinux.go +++ b/distro/oraclelinux/oraclelinux.go @@ -38,12 +38,9 @@ func (ol OracleLinux) Packages() (pkgs []string, err error) { return } - if !c.Exist() { - err = c.Build("oraclelinux:"+ol.release, - ol.envs(), ol.runs()) - if err != nil { - return - } + err = c.Build("oraclelinux:"+ol.release, ol.envs(), ol.runs()) + if err != nil { + return } if ol.release == "8" { diff --git a/distro/ubuntu/ubuntu.go b/distro/ubuntu/ubuntu.go index 590d7ac..1ea0462 100644 --- a/distro/ubuntu/ubuntu.go +++ b/distro/ubuntu/ubuntu.go @@ -43,11 +43,9 @@ func (u Ubuntu) Packages() (pkgs []string, err error) { return } - if !c.Exist() { - err = c.Build("ubuntu:"+u.release, u.envs(), u.runs()) - if err != nil { - return - } + err = c.Build("ubuntu:"+u.release, u.envs(), u.runs()) + if err != nil { + return } cmd := "apt-cache search " +