Add IsSelector() to Package

It indicates if the package is a selector, by checking if versions
contains constraints signs (<>=)
This commit is contained in:
Ettore Di Giacinto
2019-12-17 18:00:27 +01:00
committed by Ettore Di Giacinto
parent 38cef9444c
commit 0627b03121

View File

@@ -21,6 +21,7 @@ import (
"fmt" "fmt"
"path/filepath" "path/filepath"
"sort" "sort"
"strings"
// . "github.com/mudler/luet/pkg/logger" // . "github.com/mudler/luet/pkg/logger"
@@ -77,6 +78,8 @@ type Package interface {
SetLicense(string) SetLicense(string)
GetLicense() string GetLicense() string
IsSelector() bool
} }
type Tree interface { type Tree interface {
@@ -179,6 +182,10 @@ func (p *DefaultPackage) SetPath(s string) {
p.Path = s p.Path = s
} }
func (p *DefaultPackage) IsSelector() bool {
return strings.ContainsAny(p.GetVersion(), "<>=")
}
// AddUse adds a use to a package // AddUse adds a use to a package
func (p *DefaultPackage) AddUse(use string) { func (p *DefaultPackage) AddUse(use string) {
for _, v := range p.UseFlags { for _, v := range p.UseFlags {