From 451566d27f74d991bd0728da2c0c0a1b8bc7b2c9 Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Wed, 21 Feb 2024 18:16:51 +0000 Subject: [PATCH] fix: do not rebuild existing containers w/o files --- 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 +++++--- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/distro/centos/centos.go b/distro/centos/centos.go index bee6986..ca1041d 100644 --- a/distro/centos/centos.go +++ b/distro/centos/centos.go @@ -37,9 +37,12 @@ func (centos CentOS) Packages() (pkgs []string, err error) { return } - err = c.Build("centos:"+centos.release, centos.envs(), centos.runs()) - if err != nil { - return + if !c.Exist() { + 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 a7818c1..b139b67 100644 --- a/distro/debian/debian.go +++ b/distro/debian/debian.go @@ -54,9 +54,11 @@ func (d Debian) Packages() (packages []string, err error) { return } - err = c.Build(d.image(), d.envs(), d.runs()) - if err != nil { - return + if !c.Exist() { + 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 3660278..b785f3a 100644 --- a/distro/opensuse/opensuse.go +++ b/distro/opensuse/opensuse.go @@ -70,9 +70,11 @@ func (suse OpenSUSE) Packages() (pkgs []string, err error) { name = "opensuse/leap:" + suse.release } - err = c.Build(name, suse.envs(), suse.runs()) - if err != nil { - return + if !c.Exist() { + 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 0e400c8..05c97d6 100644 --- a/distro/oraclelinux/oraclelinux.go +++ b/distro/oraclelinux/oraclelinux.go @@ -38,9 +38,12 @@ func (ol OracleLinux) Packages() (pkgs []string, err error) { return } - err = c.Build("oraclelinux:"+ol.release, ol.envs(), ol.runs()) - if err != nil { - return + if !c.Exist() { + 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 5ca60d9..ccef937 100644 --- a/distro/ubuntu/ubuntu.go +++ b/distro/ubuntu/ubuntu.go @@ -42,9 +42,11 @@ func (u Ubuntu) Packages() (pkgs []string, err error) { return } - err = c.Build("ubuntu:"+u.release, u.envs(), u.runs()) - if err != nil { - return + if !c.Exist() { + err = c.Build("ubuntu:"+u.release, u.envs(), u.runs()) + if err != nil { + return + } } cmd := "apt-cache search " +