mirror of
https://github.com/mudler/luet.git
synced 2025-09-08 10:39:19 +00:00
Add "hidden" field to packages
Also drop residual of IsSet which isn't actually used Related to #26
This commit is contained in:
@@ -32,6 +32,7 @@ type PackageResult struct {
|
|||||||
Category string `json:"category"`
|
Category string `json:"category"`
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
Repository string `json:"repository"`
|
Repository string `json:"repository"`
|
||||||
|
Hidden bool `json:"hidden"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Results struct {
|
type Results struct {
|
||||||
@@ -58,6 +59,9 @@ var searchCmd = &cobra.Command{
|
|||||||
if len(args) != 1 {
|
if len(args) != 1 {
|
||||||
Fatal("Wrong number of arguments (expected 1)")
|
Fatal("Wrong number of arguments (expected 1)")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hidden, _ := cmd.Flags().GetBool("hidden")
|
||||||
|
|
||||||
installed := LuetCfg.Viper.GetBool("installed")
|
installed := LuetCfg.Viper.GetBool("installed")
|
||||||
stype := LuetCfg.Viper.GetString("solver.type")
|
stype := LuetCfg.Viper.GetString("solver.type")
|
||||||
discount := LuetCfg.Viper.GetFloat64("solver.discount")
|
discount := LuetCfg.Viper.GetFloat64("solver.discount")
|
||||||
@@ -114,6 +118,7 @@ var searchCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
for _, m := range matches {
|
for _, m := range matches {
|
||||||
if !revdeps {
|
if !revdeps {
|
||||||
|
if !m.Package.IsHidden() || m.Package.IsHidden() && hidden {
|
||||||
Info(fmt.Sprintf(":file_folder:%s", m.Repo.GetName()), fmt.Sprintf(":package:%s", m.Package.HumanReadableString()))
|
Info(fmt.Sprintf(":file_folder:%s", m.Repo.GetName()), fmt.Sprintf(":package:%s", m.Package.HumanReadableString()))
|
||||||
results.Packages = append(results.Packages,
|
results.Packages = append(results.Packages,
|
||||||
PackageResult{
|
PackageResult{
|
||||||
@@ -121,10 +126,13 @@ var searchCmd = &cobra.Command{
|
|||||||
Version: m.Package.GetVersion(),
|
Version: m.Package.GetVersion(),
|
||||||
Category: m.Package.GetCategory(),
|
Category: m.Package.GetCategory(),
|
||||||
Repository: m.Repo.GetName(),
|
Repository: m.Repo.GetName(),
|
||||||
|
Hidden: m.Package.IsHidden(),
|
||||||
})
|
})
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
visited := make(map[string]interface{})
|
visited := make(map[string]interface{})
|
||||||
for _, revdep := range m.Package.ExpandedRevdeps(m.Repo.GetTree().GetDatabase(), visited) {
|
for _, revdep := range m.Package.ExpandedRevdeps(m.Repo.GetTree().GetDatabase(), visited) {
|
||||||
|
if !revdep.IsHidden() || revdep.IsHidden() && hidden {
|
||||||
Info(fmt.Sprintf(":file_folder:%s", m.Repo.GetName()), fmt.Sprintf(":package:%s", revdep.HumanReadableString()))
|
Info(fmt.Sprintf(":file_folder:%s", m.Repo.GetName()), fmt.Sprintf(":package:%s", revdep.HumanReadableString()))
|
||||||
results.Packages = append(results.Packages,
|
results.Packages = append(results.Packages,
|
||||||
PackageResult{
|
PackageResult{
|
||||||
@@ -132,10 +140,12 @@ var searchCmd = &cobra.Command{
|
|||||||
Version: revdep.GetVersion(),
|
Version: revdep.GetVersion(),
|
||||||
Category: revdep.GetCategory(),
|
Category: revdep.GetCategory(),
|
||||||
Repository: m.Repo.GetName(),
|
Repository: m.Repo.GetName(),
|
||||||
|
Hidden: revdep.IsHidden(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if LuetCfg.GetSystem().DatabaseEngine == "boltdb" {
|
if LuetCfg.GetSystem().DatabaseEngine == "boltdb" {
|
||||||
@@ -162,6 +172,7 @@ var searchCmd = &cobra.Command{
|
|||||||
|
|
||||||
for _, pack := range iMatches {
|
for _, pack := range iMatches {
|
||||||
if !revdeps {
|
if !revdeps {
|
||||||
|
if !pack.IsHidden() || pack.IsHidden() && hidden {
|
||||||
Info(fmt.Sprintf(":package:%s", pack.HumanReadableString()))
|
Info(fmt.Sprintf(":package:%s", pack.HumanReadableString()))
|
||||||
results.Packages = append(results.Packages,
|
results.Packages = append(results.Packages,
|
||||||
PackageResult{
|
PackageResult{
|
||||||
@@ -169,11 +180,14 @@ var searchCmd = &cobra.Command{
|
|||||||
Version: pack.GetVersion(),
|
Version: pack.GetVersion(),
|
||||||
Category: pack.GetCategory(),
|
Category: pack.GetCategory(),
|
||||||
Repository: "system",
|
Repository: "system",
|
||||||
|
Hidden: pack.IsHidden(),
|
||||||
})
|
})
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
visited := make(map[string]interface{})
|
visited := make(map[string]interface{})
|
||||||
|
|
||||||
for _, revdep := range pack.ExpandedRevdeps(system.Database, visited) {
|
for _, revdep := range pack.ExpandedRevdeps(system.Database, visited) {
|
||||||
|
if !revdep.IsHidden() || revdep.IsHidden() && hidden {
|
||||||
Info(fmt.Sprintf(":package:%s", pack.HumanReadableString()))
|
Info(fmt.Sprintf(":package:%s", pack.HumanReadableString()))
|
||||||
results.Packages = append(results.Packages,
|
results.Packages = append(results.Packages,
|
||||||
PackageResult{
|
PackageResult{
|
||||||
@@ -181,11 +195,13 @@ var searchCmd = &cobra.Command{
|
|||||||
Version: revdep.GetVersion(),
|
Version: revdep.GetVersion(),
|
||||||
Category: revdep.GetCategory(),
|
Category: revdep.GetCategory(),
|
||||||
Repository: "system",
|
Repository: "system",
|
||||||
|
Hidden: revdep.IsHidden(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
y, err := yaml.Marshal(results)
|
y, err := yaml.Marshal(results)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -223,5 +239,7 @@ func init() {
|
|||||||
searchCmd.Flags().Bool("by-label", false, "Search packages through label")
|
searchCmd.Flags().Bool("by-label", false, "Search packages through label")
|
||||||
searchCmd.Flags().Bool("by-label-regex", false, "Search packages through label regex")
|
searchCmd.Flags().Bool("by-label-regex", false, "Search packages through label regex")
|
||||||
searchCmd.Flags().Bool("revdeps", false, "Search package reverse dependencies")
|
searchCmd.Flags().Bool("revdeps", false, "Search package reverse dependencies")
|
||||||
|
searchCmd.Flags().Bool("hidden", false, "Include hidden packages")
|
||||||
|
|
||||||
RootCmd.AddCommand(searchCmd)
|
RootCmd.AddCommand(searchCmd)
|
||||||
}
|
}
|
||||||
|
@@ -42,8 +42,7 @@ type Package interface {
|
|||||||
Encode(PackageDatabase) (string, error)
|
Encode(PackageDatabase) (string, error)
|
||||||
|
|
||||||
BuildFormula(PackageDatabase, PackageDatabase) ([]bf.Formula, error)
|
BuildFormula(PackageDatabase, PackageDatabase) ([]bf.Formula, error)
|
||||||
IsFlagged(bool) Package
|
|
||||||
Flagged() bool
|
|
||||||
GetFingerPrint() string
|
GetFingerPrint() string
|
||||||
GetPackageName() string
|
GetPackageName() string
|
||||||
Requires([]*DefaultPackage) Package
|
Requires([]*DefaultPackage) Package
|
||||||
@@ -99,6 +98,7 @@ type Package interface {
|
|||||||
HasAnnotation(string) bool
|
HasAnnotation(string) bool
|
||||||
MatchAnnotation(*regexp.Regexp) bool
|
MatchAnnotation(*regexp.Regexp) bool
|
||||||
|
|
||||||
|
IsHidden() bool
|
||||||
IsSelector() bool
|
IsSelector() bool
|
||||||
VersionMatchSelector(string, version.Versioner) (bool, error)
|
VersionMatchSelector(string, version.Versioner) (bool, error)
|
||||||
SelectorMatchVersion(string, version.Versioner) (bool, error)
|
SelectorMatchVersion(string, version.Versioner) (bool, error)
|
||||||
@@ -164,8 +164,8 @@ type DefaultPackage struct {
|
|||||||
State State `json:"state,omitempty"`
|
State State `json:"state,omitempty"`
|
||||||
PackageRequires []*DefaultPackage `json:"requires"` // Affects YAML field names too.
|
PackageRequires []*DefaultPackage `json:"requires"` // Affects YAML field names too.
|
||||||
PackageConflicts []*DefaultPackage `json:"conflicts"` // Affects YAML field names too.
|
PackageConflicts []*DefaultPackage `json:"conflicts"` // Affects YAML field names too.
|
||||||
IsSet bool `json:"set,omitempty"` // Affects YAML field names too.
|
|
||||||
Provides []*DefaultPackage `json:"provides,omitempty"` // Affects YAML field names too.
|
Provides []*DefaultPackage `json:"provides,omitempty"` // Affects YAML field names too.
|
||||||
|
Hidden bool `json:"hidden,omitempty"` // Affects YAML field names too.
|
||||||
|
|
||||||
// Annotations are used for core features/options
|
// Annotations are used for core features/options
|
||||||
Annotations map[string]string `json:"annotations,omitempty"` // Affects YAML field names too
|
Annotations map[string]string `json:"annotations,omitempty"` // Affects YAML field names too
|
||||||
@@ -260,6 +260,10 @@ func (p *DefaultPackage) IsSelector() bool {
|
|||||||
return strings.ContainsAny(p.GetVersion(), "<>=")
|
return strings.ContainsAny(p.GetVersion(), "<>=")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *DefaultPackage) IsHidden() bool {
|
||||||
|
return p.Hidden
|
||||||
|
}
|
||||||
|
|
||||||
func (p *DefaultPackage) HasLabel(label string) bool {
|
func (p *DefaultPackage) HasLabel(label string) bool {
|
||||||
return helpers.MapHasKey(&p.Labels, label)
|
return helpers.MapHasKey(&p.Labels, label)
|
||||||
}
|
}
|
||||||
@@ -316,15 +320,6 @@ func (p *DefaultPackage) Yaml() ([]byte, error) {
|
|||||||
return y, nil
|
return y, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *DefaultPackage) IsFlagged(b bool) Package {
|
|
||||||
p.IsSet = b
|
|
||||||
return p
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *DefaultPackage) Flagged() bool {
|
|
||||||
return p.IsSet
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *DefaultPackage) GetName() string {
|
func (p *DefaultPackage) GetName() string {
|
||||||
return p.Name
|
return p.Name
|
||||||
}
|
}
|
||||||
@@ -763,7 +758,6 @@ func (p *DefaultPackage) Explain() {
|
|||||||
fmt.Println("Name: ", p.GetName())
|
fmt.Println("Name: ", p.GetName())
|
||||||
fmt.Println("Category: ", p.GetCategory())
|
fmt.Println("Category: ", p.GetCategory())
|
||||||
fmt.Println("Version: ", p.GetVersion())
|
fmt.Println("Version: ", p.GetVersion())
|
||||||
fmt.Println("Installed: ", p.IsSet)
|
|
||||||
|
|
||||||
for _, req := range p.GetRequires() {
|
for _, req := range p.GetRequires() {
|
||||||
fmt.Println("\t-> ", req)
|
fmt.Println("\t-> ", req)
|
||||||
|
@@ -532,7 +532,7 @@ func (s *Solver) Uninstall(c pkg.Package, checkconflicts, full bool) (pkg.Packag
|
|||||||
for _, a := range asserts {
|
for _, a := range asserts {
|
||||||
if a.Value {
|
if a.Value {
|
||||||
if !checkconflicts {
|
if !checkconflicts {
|
||||||
res = append(res, a.Package.IsFlagged(false))
|
res = append(res, a.Package)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -543,7 +543,7 @@ func (s *Solver) Uninstall(c pkg.Package, checkconflicts, full bool) (pkg.Packag
|
|||||||
|
|
||||||
// If doesn't conflict with installed we just consider it for removal and look for the next one
|
// If doesn't conflict with installed we just consider it for removal and look for the next one
|
||||||
if !c {
|
if !c {
|
||||||
res = append(res, a.Package.IsFlagged(false))
|
res = append(res, a.Package)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -553,7 +553,7 @@ func (s *Solver) Uninstall(c pkg.Package, checkconflicts, full bool) (pkg.Packag
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if !c {
|
if !c {
|
||||||
res = append(res, a.Package.IsFlagged(false))
|
res = append(res, a.Package)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -29,7 +29,6 @@ type DefaultPackageSanitized struct {
|
|||||||
UseFlags []string `json:"use_flags,omitempty" yaml:"use_flags,omitempty"`
|
UseFlags []string `json:"use_flags,omitempty" yaml:"use_flags,omitempty"`
|
||||||
PackageRequires []*DefaultPackageSanitized `json:"requires,omitempty" yaml:"requires,omitempty"`
|
PackageRequires []*DefaultPackageSanitized `json:"requires,omitempty" yaml:"requires,omitempty"`
|
||||||
PackageConflicts []*DefaultPackageSanitized `json:"conflicts,omitempty" yaml:"conflicts,omitempty"`
|
PackageConflicts []*DefaultPackageSanitized `json:"conflicts,omitempty" yaml:"conflicts,omitempty"`
|
||||||
IsSet bool `json:"set,omitempty" yaml:"set,omitempty"`
|
|
||||||
Provides []*DefaultPackageSanitized `json:"provides,omitempty" yaml:"provides,omitempty"`
|
Provides []*DefaultPackageSanitized `json:"provides,omitempty" yaml:"provides,omitempty"`
|
||||||
|
|
||||||
Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
|
Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"`
|
||||||
@@ -40,6 +39,7 @@ type DefaultPackageSanitized struct {
|
|||||||
Description string `json:"description,omitempty" yaml:"description,omitempty"`
|
Description string `json:"description,omitempty" yaml:"description,omitempty"`
|
||||||
Uri []string `json:"uri,omitempty" yaml:"uri,omitempty"`
|
Uri []string `json:"uri,omitempty" yaml:"uri,omitempty"`
|
||||||
License string `json:"license,omitempty" yaml:"license,omitempty"`
|
License string `json:"license,omitempty" yaml:"license,omitempty"`
|
||||||
|
Hidden bool `json:"hidden,omitempty" yaml:"hidden,omitempty"`
|
||||||
|
|
||||||
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
|
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ func NewDefaultPackageSanitized(p pkg.Package) *DefaultPackageSanitized {
|
|||||||
Version: p.GetVersion(),
|
Version: p.GetVersion(),
|
||||||
Category: p.GetCategory(),
|
Category: p.GetCategory(),
|
||||||
UseFlags: p.GetUses(),
|
UseFlags: p.GetUses(),
|
||||||
IsSet: p.Flagged(),
|
Hidden: p.IsHidden(),
|
||||||
Path: p.GetPath(),
|
Path: p.GetPath(),
|
||||||
Description: p.GetDescription(),
|
Description: p.GetDescription(),
|
||||||
Uri: p.GetURI(),
|
Uri: p.GetURI(),
|
||||||
@@ -68,6 +68,7 @@ func NewDefaultPackageSanitized(p pkg.Package) *DefaultPackageSanitized {
|
|||||||
Name: r.Name,
|
Name: r.Name,
|
||||||
Version: r.Version,
|
Version: r.Version,
|
||||||
Category: r.Category,
|
Category: r.Category,
|
||||||
|
Hidden: r.IsHidden(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -82,6 +83,7 @@ func NewDefaultPackageSanitized(p pkg.Package) *DefaultPackageSanitized {
|
|||||||
Name: c.Name,
|
Name: c.Name,
|
||||||
Version: c.Version,
|
Version: c.Version,
|
||||||
Category: c.Category,
|
Category: c.Category,
|
||||||
|
Hidden: c.IsHidden(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -96,6 +98,7 @@ func NewDefaultPackageSanitized(p pkg.Package) *DefaultPackageSanitized {
|
|||||||
Name: prov.Name,
|
Name: prov.Name,
|
||||||
Version: prov.Version,
|
Version: prov.Version,
|
||||||
Category: prov.Category,
|
Category: prov.Category,
|
||||||
|
Hidden: prov.IsHidden(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user