mirror of
https://github.com/mudler/luet.git
synced 2025-09-06 09:41:05 +00:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
764a09ce0c | ||
|
910f1ad3fe | ||
|
16e9d7b20c | ||
|
6088664887 |
6
Makefile
6
Makefile
@@ -74,10 +74,6 @@ build-small:
|
|||||||
image:
|
image:
|
||||||
docker build --rm -t luet/base .
|
docker build --rm -t luet/base .
|
||||||
|
|
||||||
.PHONY: gox-build
|
|
||||||
gox-build:
|
|
||||||
CGO_ENABLED=0 gox $(BUILD_PLATFORMS) -ldflags '$(LDFLAGS)' -output="release/$(NAME)-$(VERSION)-{{.OS}}-{{.Arch}}"
|
|
||||||
|
|
||||||
.PHONY: lint
|
.PHONY: lint
|
||||||
lint:
|
lint:
|
||||||
golint ./... | grep -v "be unexported"
|
golint ./... | grep -v "be unexported"
|
||||||
@@ -94,4 +90,4 @@ test-docker:
|
|||||||
|
|
||||||
.PHONY: multiarch-build
|
.PHONY: multiarch-build
|
||||||
multiarch-build:
|
multiarch-build:
|
||||||
gox $(BUILD_PLATFORMS) -ldflags '$(LDFLAGS)' -output="release/$(NAME)-$(VERSION)-{{.OS}}-{{.Arch}}"
|
CGO_ENABLED=0 gox $(BUILD_PLATFORMS) -ldflags '$(LDFLAGS)' -output="release/$(NAME)-$(VERSION)-{{.OS}}-{{.Arch}}"
|
||||||
|
@@ -38,7 +38,7 @@ var Verbose bool
|
|||||||
var LockedCommands = []string{"install", "uninstall", "upgrade"}
|
var LockedCommands = []string{"install", "uninstall", "upgrade"}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
LuetCLIVersion = "0.8.0"
|
LuetCLIVersion = "0.8.1"
|
||||||
LuetEnvPrefix = "LUET"
|
LuetEnvPrefix = "LUET"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -184,7 +184,7 @@ func validateWorker(i int,
|
|||||||
))
|
))
|
||||||
|
|
||||||
// Check if the solver is already been done for the deep
|
// Check if the solver is already been done for the deep
|
||||||
_, err := cacheDeps.Get(r.HashFingerprint())
|
_, err := cacheDeps.Get(r.HashFingerprint(""))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
Debug(" :direct_hit: Cache Hit for dep",
|
Debug(" :direct_hit: Cache Hit for dep",
|
||||||
fmt.Sprintf("%s/%s-%s", r.GetCategory(), r.GetName(), r.GetVersion()))
|
fmt.Sprintf("%s/%s-%s", r.GetCategory(), r.GetName(), r.GetVersion()))
|
||||||
@@ -218,7 +218,7 @@ func validateWorker(i int,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Register the key
|
// Register the key
|
||||||
cacheDeps.Set(r.HashFingerprint(), "1")
|
cacheDeps.Set(r.HashFingerprint(""), "1")
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -229,13 +229,30 @@ 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) {
|
func (cs *LuetCompiler) compileWithImage(image, buildertaggedImage, packageImage string, concurrency int, keepPermissions, keepImg bool, p CompilationSpec) (Artifact, error) {
|
||||||
fp := p.GetPackage().HashFingerprint()
|
|
||||||
|
pkgTag := ":package: " + p.GetPackage().GetName()
|
||||||
|
|
||||||
|
// Use packageImage as salt into the fp being used
|
||||||
|
// so the hash is unique also in cases where
|
||||||
|
// some package deps does have completely different
|
||||||
|
// depgraphs
|
||||||
|
// TODO: As the salt contains the packageImage ( in registry/organization/imagename:tag format)
|
||||||
|
// the images hashes are broken with registry mirrors.
|
||||||
|
// We should use the image tag, or pass by the package assertion hash which is unique
|
||||||
|
// and identifies the deptree of the package.
|
||||||
|
|
||||||
|
fp := p.GetPackage().HashFingerprint(packageImage)
|
||||||
|
|
||||||
if buildertaggedImage == "" {
|
if buildertaggedImage == "" {
|
||||||
buildertaggedImage = cs.ImageRepository + "-" + fp + "-builder"
|
buildertaggedImage = cs.ImageRepository + "-" + fp + "-builder"
|
||||||
|
Debug(pkgTag, "Creating intermediary image", buildertaggedImage, "from", image)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Cleanup, not actually hit
|
||||||
if packageImage == "" {
|
if packageImage == "" {
|
||||||
packageImage = cs.ImageRepository + "-" + fp
|
packageImage = cs.ImageRepository + "-" + fp
|
||||||
}
|
}
|
||||||
|
|
||||||
if !cs.Clean {
|
if !cs.Clean {
|
||||||
exists := cs.Backend.ImageExists(buildertaggedImage) && cs.Backend.ImageExists(packageImage)
|
exists := cs.Backend.ImageExists(buildertaggedImage) && cs.Backend.ImageExists(packageImage)
|
||||||
if art, err := LoadArtifactFromYaml(p); err == nil && exists {
|
if art, err := LoadArtifactFromYaml(p); err == nil && exists {
|
||||||
@@ -243,7 +260,6 @@ func (cs *LuetCompiler) compileWithImage(image, buildertaggedImage, packageImage
|
|||||||
return art, err
|
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,
|
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,
|
||||||
// and we build all the images first.
|
// and we build all the images first.
|
||||||
@@ -513,7 +529,6 @@ func (cs *LuetCompiler) ComputeDepTree(p CompilationSpec) (solver.PackagesAssert
|
|||||||
for _, assertion := range dependencies { //highly dependent on the order
|
for _, assertion := range dependencies { //highly dependent on the order
|
||||||
if assertion.Value {
|
if assertion.Value {
|
||||||
nthsolution := dependencies.Cut(assertion.Package)
|
nthsolution := dependencies.Cut(assertion.Package)
|
||||||
|
|
||||||
assertion.Hash = solver.PackageHash{
|
assertion.Hash = solver.PackageHash{
|
||||||
BuildHash: nthsolution.HashFrom(assertion.Package),
|
BuildHash: nthsolution.HashFrom(assertion.Package),
|
||||||
PackageHash: nthsolution.AssertionHash(),
|
PackageHash: nthsolution.AssertionHash(),
|
||||||
|
@@ -105,7 +105,7 @@ type Package interface {
|
|||||||
|
|
||||||
String() string
|
String() string
|
||||||
HumanReadableString() string
|
HumanReadableString() string
|
||||||
HashFingerprint() string
|
HashFingerprint(string) string
|
||||||
|
|
||||||
Clone() Package
|
Clone() Package
|
||||||
}
|
}
|
||||||
@@ -205,9 +205,9 @@ func (p *DefaultPackage) GetFingerPrint() string {
|
|||||||
return fmt.Sprintf("%s-%s-%s", p.Name, p.Category, p.Version)
|
return fmt.Sprintf("%s-%s-%s", p.Name, p.Category, p.Version)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *DefaultPackage) HashFingerprint() string {
|
func (p *DefaultPackage) HashFingerprint(salt string) string {
|
||||||
h := md5.New()
|
h := md5.New()
|
||||||
io.WriteString(h, p.GetFingerPrint())
|
io.WriteString(h, fmt.Sprintf("%s-%s",p.GetFingerPrint(),salt))
|
||||||
return fmt.Sprintf("%x", h.Sum(nil))
|
return fmt.Sprintf("%x", h.Sum(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -36,8 +36,8 @@ var _ = Describe("Package", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("Generates packages fingerprint's hashes", func() {
|
It("Generates packages fingerprint's hashes", func() {
|
||||||
Expect(a.HashFingerprint()).ToNot(Equal(a1.HashFingerprint()))
|
Expect(a.HashFingerprint("")).ToNot(Equal(a1.HashFingerprint("")))
|
||||||
Expect(a.HashFingerprint()).To(Equal("c64caa391b79adb598ad98e261aa79a0"))
|
Expect(a.HashFingerprint("")).To(Equal("76972ef6991ec6102f33b401105c1351"))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user