diff --git a/pkg/compiler/artifact.go b/pkg/compiler/artifact.go index c28a8b0c..7ce08ef1 100644 --- a/pkg/compiler/artifact.go +++ b/pkg/compiler/artifact.go @@ -92,6 +92,17 @@ func NewPackageArtifactFromYaml(data []byte) (Artifact, error) { return p, err } +func LoadArtifactFromYaml(spec CompilationSpec) (Artifact, error) { + + metaFile := spec.GetPackage().GetFingerPrint() + ".metadata.yaml" + dat, err := ioutil.ReadFile(spec.Rel(metaFile)) + if err != nil { + return nil, errors.Wrap(err, "Error reading file "+metaFile) + } + + return NewPackageArtifactFromYaml(dat) +} + func (a *PackageArtifact) SetCompressionType(t CompressionImplementation) { a.CompressionType = t } diff --git a/pkg/compiler/compiler.go b/pkg/compiler/compiler.go index 7ad2baad..caef184d 100644 --- a/pkg/compiler/compiler.go +++ b/pkg/compiler/compiler.go @@ -227,6 +227,11 @@ func (cs *LuetCompiler) stripIncludesFromRootfs(includes []string, rootfs string } func (cs *LuetCompiler) compileWithImage(image, buildertaggedImage, packageImage string, concurrency int, keepPermissions, keepImg bool, p CompilationSpec) (Artifact, error) { + if !cs.Clean { + if art, err := LoadArtifactFromYaml(p); err == nil { + return art, err + } + } pkgTag := ":package: " + p.GetPackage().GetName() p.SetSeedImage(image) // In this case, we ignore the build deps as we suppose that the image has them - otherwise we recompose the tree with a solver, @@ -382,6 +387,11 @@ func (cs *LuetCompiler) compileWithImage(image, buildertaggedImage, packageImage } func (cs *LuetCompiler) packageFromImage(p CompilationSpec, tag string, keepPermissions, keepImg bool, concurrency int) (Artifact, error) { + if !cs.Clean { + if art, err := LoadArtifactFromYaml(p); err == nil { + return art, err + } + } pkgTag := ":package: " + p.GetPackage().GetName() Info(pkgTag, " 🍩 Build starts 🔨 🔨 🔨 ")