Resolvers might omit packages

This commit is contained in:
Ettore Di Giacinto 2020-12-03 18:53:57 +01:00
parent d668d8344b
commit cf80e5fc09
2 changed files with 20 additions and 9 deletions

View File

@ -71,6 +71,15 @@ type LuetSolverOptions struct {
Implementation solver.SolverType `mapstructure:"implementation"` Implementation solver.SolverType `mapstructure:"implementation"`
} }
func (opts LuetSolverOptions) ResolverIsSet() bool {
switch opts.Type {
case solver.QLearningResolverType:
return true
default:
return false
}
}
func (opts LuetSolverOptions) Resolver() solver.PackageResolver { func (opts LuetSolverOptions) Resolver() solver.PackageResolver {
switch opts.Type { switch opts.Type {
case solver.QLearningResolverType: case solver.QLearningResolverType:

View File

@ -288,16 +288,18 @@ func (l *LuetInstaller) Install(cp pkg.Packages, s *System) error {
Info("No packages to install") Info("No packages to install")
return nil return nil
} }
// Resolvers might decide to remove some packages from being installed
for _, p := range cp { if !l.Options.SolverOptions.ResolverIsSet() {
found := false for _, p := range cp {
for _, m := range match { found := false
if m.Package.GetName() == p.GetName() { for _, m := range match {
found = true if m.Package.GetName() == p.GetName() {
found = true
}
}
if !found {
return fmt.Errorf("Package '%s' not found", p.HumanReadableString())
} }
}
if !found {
return fmt.Errorf("Package '%s' not found", p.HumanReadableString())
} }
} }