mirror of
https://github.com/mudler/luet.git
synced 2025-04-27 19:25:15 +00:00
Print all not-found packages (#304)
* Print all not-found packages When trying to install several packages that are not found luet will now print all packages that are not found, instead of only first one. * changes to some failing tests
This commit is contained in:
parent
843858e241
commit
556e46daeb
@ -23,11 +23,12 @@ import (
|
||||
"github.com/google/go-containerregistry/pkg/name"
|
||||
v1 "github.com/google/go-containerregistry/pkg/v1"
|
||||
daemon "github.com/google/go-containerregistry/pkg/v1/daemon"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/mudler/luet/pkg/api/core/context"
|
||||
. "github.com/mudler/luet/pkg/api/core/image"
|
||||
"github.com/mudler/luet/pkg/helpers/file"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("Extract", func() {
|
||||
@ -61,10 +62,10 @@ var _ = Describe("Extract", func() {
|
||||
ExtractFiles(ctx, "", []string{}, []string{}),
|
||||
)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
defer os.RemoveAll(tmpdir) // clean up
|
||||
// defer os.RemoveAll(tmpdir) // clean up
|
||||
|
||||
Expect(file.Exists(filepath.Join(tmpdir, "usr", "bin"))).To(BeTrue())
|
||||
Expect(file.Exists(filepath.Join(tmpdir, "bin", "sh"))).To(BeTrue())
|
||||
Expect(filepath.Join(tmpdir, "usr", "bin")).To(BeADirectory())
|
||||
Expect(filepath.Join(tmpdir, "bin", "busybox")).To(BeARegularFile())
|
||||
})
|
||||
|
||||
It("Extract specific dir", func() {
|
||||
@ -75,9 +76,9 @@ var _ = Describe("Extract", func() {
|
||||
)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
defer os.RemoveAll(tmpdir) // clean up
|
||||
Expect(file.Exists(filepath.Join(tmpdir, "usr", "sbin"))).To(BeTrue())
|
||||
Expect(file.Exists(filepath.Join(tmpdir, "usr", "bin"))).To(BeTrue())
|
||||
Expect(file.Exists(filepath.Join(tmpdir, "bin", "sh"))).To(BeFalse())
|
||||
Expect(filepath.Join(tmpdir, "usr", "sbin")).To(BeADirectory())
|
||||
Expect(filepath.Join(tmpdir, "usr", "bin")).To(BeADirectory())
|
||||
Expect(filepath.Join(tmpdir, "bin", "busybox")).ToNot(BeARegularFile())
|
||||
})
|
||||
|
||||
It("Extract a dir with includes/excludes", func() {
|
||||
@ -103,8 +104,8 @@ var _ = Describe("Extract", func() {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
defer os.RemoveAll(tmpdir) // clean up
|
||||
|
||||
Expect(file.Exists(filepath.Join(tmpdir, "usr", "bin"))).To(BeTrue())
|
||||
Expect(file.Exists(filepath.Join(tmpdir, "bin", "sh"))).To(BeFalse())
|
||||
Expect(filepath.Join(tmpdir, "usr", "bin")).To(BeADirectory())
|
||||
Expect(filepath.Join(tmpdir, "bin", "busybox")).ToNot(BeARegularFile())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -21,6 +21,7 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/mudler/luet/pkg/api/core/types"
|
||||
|
||||
"github.com/mudler/luet/pkg/compiler"
|
||||
|
||||
"github.com/mudler/luet/pkg/api/core/context"
|
||||
@ -91,7 +92,7 @@ ENV PACKAGE_CATEGORY=app-admin`))
|
||||
}
|
||||
Expect(b.BuildImage(opts)).ToNot(HaveOccurred())
|
||||
Expect(b.ExportImage(opts)).ToNot(HaveOccurred())
|
||||
Expect(fileHelper.Exists(filepath.Join(tmpdir2, "output1.tar"))).To(BeTrue())
|
||||
Expect(filepath.Join(tmpdir2, "output1.tar")).To(BeARegularFile())
|
||||
Expect(b.BuildImage(opts)).ToNot(HaveOccurred())
|
||||
|
||||
err = lspec.WriteStepImageDefinition(lspec.Image, filepath.Join(tmpdir, "LuetDockerfile"))
|
||||
|
@ -25,18 +25,20 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/hashicorp/go-multierror"
|
||||
|
||||
"github.com/mudler/luet/pkg/api/core/config"
|
||||
"github.com/mudler/luet/pkg/api/core/logger"
|
||||
"github.com/mudler/luet/pkg/helpers"
|
||||
"github.com/mudler/luet/pkg/tree"
|
||||
|
||||
"github.com/pterm/pterm"
|
||||
|
||||
"github.com/mudler/luet/pkg/api/core/bus"
|
||||
"github.com/mudler/luet/pkg/api/core/types"
|
||||
artifact "github.com/mudler/luet/pkg/api/core/types/artifact"
|
||||
pkg "github.com/mudler/luet/pkg/database"
|
||||
fileHelper "github.com/mudler/luet/pkg/helpers/file"
|
||||
"github.com/mudler/luet/pkg/solver"
|
||||
"github.com/pterm/pterm"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
@ -556,6 +558,8 @@ func (l *LuetInstaller) Install(cp types.Packages, s *System) error {
|
||||
|
||||
// Resolvers might decide to remove some packages from being installed
|
||||
if !solver.IsRelaxedResolver(l.Options.SolverOptions) {
|
||||
var packagesNotFound []string
|
||||
|
||||
for _, p := range cp {
|
||||
found := false
|
||||
|
||||
@ -577,18 +581,29 @@ func (l *LuetInstaller) Install(cp types.Packages, s *System) error {
|
||||
for _, m := range match {
|
||||
if m.Package.GetName() == p.GetName() {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
for _, pack := range m.Package.GetProvides() {
|
||||
if pack.GetName() == p.GetName() {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
return fmt.Errorf("package '%s' not found", p.HumanReadableString())
|
||||
packagesNotFound = append(packagesNotFound, p.HumanReadableString())
|
||||
}
|
||||
}
|
||||
|
||||
if len(packagesNotFound) > 0 {
|
||||
prefix := "package"
|
||||
if len(packagesNotFound) > 1 {
|
||||
prefix = "packages"
|
||||
}
|
||||
|
||||
return fmt.Errorf("%s '%s' not found", prefix, strings.Join(packagesNotFound, "', '"))
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we have to process something, or return to the user an error
|
||||
|
Loading…
Reference in New Issue
Block a user