reroute dep->rpc dependency via query

This commit is contained in:
Jannis M. Hoffmann 2021-02-16 16:10:04 +01:00 committed by J Guerreiro
parent 34f7dbc7fc
commit 5d2c763fdb
5 changed files with 22 additions and 17 deletions

View file

@ -1,6 +1,6 @@
package dep
import rpc "github.com/mikkeloscar/aur"
import rpc "github.com/Jguer/yay/v10/pkg/query"
// Base is an AUR base package
type Base []*rpc.Pkg

View file

@ -4,9 +4,9 @@ import (
"strings"
alpm "github.com/Jguer/go-alpm/v2"
rpc "github.com/mikkeloscar/aur"
"github.com/Jguer/yay/v10/pkg/db"
rpc "github.com/Jguer/yay/v10/pkg/query"
"github.com/Jguer/yay/v10/pkg/text"
)

View file

@ -3,10 +3,9 @@ package dep
import (
"fmt"
rpc "github.com/mikkeloscar/aur"
alpm "github.com/Jguer/go-alpm/v2"
rpc "github.com/Jguer/yay/v10/pkg/query"
"github.com/Jguer/yay/v10/pkg/stringset"
"github.com/Jguer/yay/v10/pkg/text"
)

View file

@ -10,7 +10,6 @@ import (
"sync"
"github.com/leonelquinteros/gotext"
rpc "github.com/mikkeloscar/aur"
alpm "github.com/Jguer/go-alpm/v2"
@ -56,8 +55,8 @@ type Pool struct {
Targets []Target
Explicit stringset.StringSet
Repo map[string]alpm.IPackage
Aur map[string]*rpc.Pkg
AurCache map[string]*rpc.Pkg
Aur map[string]*query.Pkg
AurCache map[string]*query.Pkg
Groups []string
AlpmExecutor db.Executor
Warnings *query.AURWarnings
@ -68,8 +67,8 @@ func makePool(dbExecutor db.Executor) *Pool {
make([]Target, 0),
make(stringset.StringSet),
make(map[string]alpm.IPackage),
make(map[string]*rpc.Pkg),
make(map[string]*rpc.Pkg),
make(map[string]*query.Pkg),
make(map[string]*query.Pkg),
make([]string, 0),
dbExecutor,
nil,
@ -175,7 +174,7 @@ func (dp *Pool) findProvides(pkgs stringset.StringSet) error {
doSearch := func(pkg string) {
defer wg.Done()
var err error
var results []rpc.Pkg
var results []query.Pkg
// Hack for a bigger search result, if the user wants
// java-envronment we can search for just java instead and get
@ -184,7 +183,7 @@ func (dp *Pool) findProvides(pkgs stringset.StringSet) error {
words := strings.Split(pkg, "-")
for i := range words {
results, err = rpc.Search(strings.Join(words[:i+1], "-"))
results, err = query.Search(strings.Join(words[:i+1], "-"))
if err == nil {
break
}
@ -362,7 +361,7 @@ func GetPool(pkgs []string,
return dp, err
}
func (dp *Pool) findSatisfierAur(dep string) *rpc.Pkg {
func (dp *Pool) findSatisfierAur(dep string) *query.Pkg {
for _, pkg := range dp.Aur {
if satisfiesAur(dep, pkg) {
return pkg
@ -382,7 +381,7 @@ func (dp *Pool) findSatisfierAur(dep string) *rpc.Pkg {
// Using Pacman's ways trying to install foo would never give you
// a menu.
// TODO: maybe intermix repo providers in the menu
func (dp *Pool) findSatisfierAurCache(dep string, ignoreProviders, noConfirm, provides bool) *rpc.Pkg {
func (dp *Pool) findSatisfierAurCache(dep string, ignoreProviders, noConfirm, provides bool) *query.Pkg {
depName, _, _ := splitDep(dep)
seen := make(stringset.StringSet)
providerSlice := makeProviders(depName)
@ -477,7 +476,7 @@ func (dp *Pool) hasPackage(name string) bool {
return false
}
func providerMenu(dep string, providers providers, noConfirm bool) *rpc.Pkg {
func providerMenu(dep string, providers providers, noConfirm bool) *query.Pkg {
size := providers.Len()
str := text.Bold(gotext.Get("There are %d providers available for %s:\n", size, dep))

View file

@ -11,13 +11,20 @@ import (
"github.com/Jguer/yay/v10/pkg/text"
)
type Pkg = rpc.Pkg
// Search is a reexport of rpc.Search
func Search(query string) ([]Pkg, error) {
return rpc.Search(query)
}
// Queries the aur for information about specified packages.
// All packages should be queried in a single rpc request except when the number
// of packages exceeds the number set in config.RequestSplitN.
// If the number does exceed config.RequestSplitN multiple rpc requests will be
// performed concurrently.
func AURInfo(names []string, warnings *AURWarnings, splitN int) ([]*rpc.Pkg, error) {
info := make([]*rpc.Pkg, 0, len(names))
func AURInfo(names []string, warnings *AURWarnings, splitN int) ([]*Pkg, error) {
info := make([]*Pkg, 0, len(names))
seen := make(map[string]int)
var mux sync.Mutex
var wg sync.WaitGroup
@ -73,7 +80,7 @@ func AURInfo(names []string, warnings *AURWarnings, splitN int) ([]*rpc.Pkg, err
return info, nil
}
func AURInfoPrint(names []string, splitN int) ([]*rpc.Pkg, error) {
func AURInfoPrint(names []string, splitN int) ([]*Pkg, error) {
text.OperationInfoln(gotext.Get("Querying AUR..."))
warnings := &AURWarnings{}