mirror of
https://github.com/Jguer/yay.git
synced 2025-10-08 00:04:37 -04:00
Allow use of rpc client as an alternative to the metadata client (#1918)
* use updated aur client * add logger to rpc client * update go.mod
This commit is contained in:
parent
2f5fd5cb1c
commit
f1d086df1d
9
go.mod
9
go.mod
@ -1,7 +1,7 @@
|
|||||||
module github.com/Jguer/yay/v11
|
module github.com/Jguer/yay/v11
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Jguer/aur v1.1.3
|
github.com/Jguer/aur v1.2.0
|
||||||
github.com/Jguer/go-alpm/v2 v2.1.2
|
github.com/Jguer/go-alpm/v2 v2.1.2
|
||||||
github.com/Jguer/votar v1.0.0
|
github.com/Jguer/votar v1.0.0
|
||||||
github.com/Morganamilo/go-pacmanconf v0.0.0-20210502114700-cff030e927a5
|
github.com/Morganamilo/go-pacmanconf v0.0.0-20210502114700-cff030e927a5
|
||||||
@ -28,7 +28,12 @@ require (
|
|||||||
github.com/deckarep/golang-set/v2 v2.1.0
|
github.com/deckarep/golang-set/v2 v2.1.0
|
||||||
github.com/itchyny/gojq v0.12.11 // indirect
|
github.com/itchyny/gojq v0.12.11 // indirect
|
||||||
github.com/itchyny/timefmt-go v0.1.5 // indirect
|
github.com/itchyny/timefmt-go v0.1.5 // indirect
|
||||||
github.com/ohler55/ojg v1.17.4 // indirect
|
github.com/ohler55/ojg v1.17.5 // indirect
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||||
|
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
go 1.19
|
go 1.19
|
||||||
|
21
go.sum
21
go.sum
@ -1,5 +1,5 @@
|
|||||||
github.com/Jguer/aur v1.1.3 h1:wuqz67ZqUnyqS56WjNSwKqrZCJFeDuG+ljWnmmPKg04=
|
github.com/Jguer/aur v1.2.0 h1:hWg0JcGQ9WkPlnElr3tZ6dW+GfD/wZTr9kym5GFY3OE=
|
||||||
github.com/Jguer/aur v1.1.3/go.mod h1:YWXsL0qywB3kY8gduwAJwklN38opQYRm6+pYMJgtCd0=
|
github.com/Jguer/aur v1.2.0/go.mod h1:x4iPZX1qZoQtPiYgFepVO/6kbz7zwFkep8gz5tzga64=
|
||||||
github.com/Jguer/go-alpm/v2 v2.1.2 h1:CGTIxzuEpT9Q3a7IBrx0E6acoYoaHX2Z93UOApPDhgU=
|
github.com/Jguer/go-alpm/v2 v2.1.2 h1:CGTIxzuEpT9Q3a7IBrx0E6acoYoaHX2Z93UOApPDhgU=
|
||||||
github.com/Jguer/go-alpm/v2 v2.1.2/go.mod h1:uLQcTMNM904dRiGU+/JDtDdd7Nd8mVbEVaHjhmziT7w=
|
github.com/Jguer/go-alpm/v2 v2.1.2/go.mod h1:uLQcTMNM904dRiGU+/JDtDdd7Nd8mVbEVaHjhmziT7w=
|
||||||
github.com/Jguer/votar v1.0.0 h1:drPYpV5Py5BeAQS8xezmT6uCEfLzotNjLf5yfmlHKTg=
|
github.com/Jguer/votar v1.0.0 h1:drPYpV5Py5BeAQS8xezmT6uCEfLzotNjLf5yfmlHKTg=
|
||||||
@ -21,6 +21,11 @@ github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6
|
|||||||
github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4=
|
github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4=
|
||||||
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw=
|
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw=
|
||||||
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI=
|
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI=
|
||||||
|
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||||
|
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
|
||||||
|
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||||
|
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
|
||||||
|
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
|
||||||
github.com/itchyny/gojq v0.12.11 h1:YhLueoHhHiN4mkfM+3AyJV6EPcCxKZsOnYf+aVSwaQw=
|
github.com/itchyny/gojq v0.12.11 h1:YhLueoHhHiN4mkfM+3AyJV6EPcCxKZsOnYf+aVSwaQw=
|
||||||
github.com/itchyny/gojq v0.12.11/go.mod h1:o3FT8Gkbg/geT4pLI0tF3hvip5F3Y/uskjRz9OYa38g=
|
github.com/itchyny/gojq v0.12.11/go.mod h1:o3FT8Gkbg/geT4pLI0tF3hvip5F3Y/uskjRz9OYa38g=
|
||||||
github.com/itchyny/timefmt-go v0.1.5 h1:G0INE2la8S6ru/ZI5JecgyzbbJNs5lG1RcBqa7Jm6GE=
|
github.com/itchyny/timefmt-go v0.1.5 h1:G0INE2la8S6ru/ZI5JecgyzbbJNs5lG1RcBqa7Jm6GE=
|
||||||
@ -29,10 +34,8 @@ github.com/leonelquinteros/gotext v1.5.1 h1:vmddRn3gHp67YFjZLZE2AZsgYMT4IBTJhua4
|
|||||||
github.com/leonelquinteros/gotext v1.5.1/go.mod h1:/A4Y7BvIsf5JHO60E43ZQDVkV3qO+7eP8HjeqD6ChIA=
|
github.com/leonelquinteros/gotext v1.5.1/go.mod h1:/A4Y7BvIsf5JHO60E43ZQDVkV3qO+7eP8HjeqD6ChIA=
|
||||||
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4=
|
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4=
|
||||||
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms=
|
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms=
|
||||||
github.com/ohler55/ojg v1.15.0 h1:Z95FvBiMsMOOGP9Nzv5OVV4ND2KnEMxk0GOS8Kvcahg=
|
github.com/ohler55/ojg v1.17.5 h1:SY6/cdhVzsLinNFIBRNSWhJgihvEWco5Y0TJe46XJ1Y=
|
||||||
github.com/ohler55/ojg v1.15.0/go.mod h1:7Ghirupn8NC8hSSDpI0gcjorPxj+vSVIONDWfliHR1k=
|
github.com/ohler55/ojg v1.17.5/go.mod h1:7Ghirupn8NC8hSSDpI0gcjorPxj+vSVIONDWfliHR1k=
|
||||||
github.com/ohler55/ojg v1.17.4 h1:6Ss87DyAZHU0ODZu6Cmuahj5UiVaRD1n8C4KNm0qMYg=
|
|
||||||
github.com/ohler55/ojg v1.17.4/go.mod h1:7Ghirupn8NC8hSSDpI0gcjorPxj+vSVIONDWfliHR1k=
|
|
||||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
@ -62,21 +65,15 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
|
|
||||||
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
|
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
|
||||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.3.0 h1:qoo4akIqOcDME5bhc/NgxUdovd6BSS2uMsVjB56q1xI=
|
|
||||||
golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA=
|
|
||||||
golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY=
|
golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY=
|
||||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM=
|
|
||||||
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
|
||||||
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
|
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
|
||||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
aur "github.com/Jguer/aur"
|
aur "github.com/Jguer/aur"
|
||||||
"github.com/Jguer/aur/metadata"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
@ -141,7 +140,7 @@ func TestIntegrationLocalInstall(t *testing.T) {
|
|||||||
CmdBuilder: cmdBuilder,
|
CmdBuilder: cmdBuilder,
|
||||||
VCSStore: &vcs.Mock{},
|
VCSStore: &vcs.Mock{},
|
||||||
AURCache: &mockaur.MockAUR{
|
AURCache: &mockaur.MockAUR{
|
||||||
GetFn: func(ctx context.Context, query *metadata.AURQuery) ([]aur.Pkg, error) {
|
GetFn: func(ctx context.Context, query *aur.Query) ([]aur.Pkg, error) {
|
||||||
return []aur.Pkg{}, nil
|
return []aur.Pkg{}, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -259,7 +258,7 @@ func TestIntegrationLocalInstallMissingDep(t *testing.T) {
|
|||||||
CmdBuilder: cmdBuilder,
|
CmdBuilder: cmdBuilder,
|
||||||
VCSStore: &vcs.Mock{},
|
VCSStore: &vcs.Mock{},
|
||||||
AURCache: &mockaur.MockAUR{
|
AURCache: &mockaur.MockAUR{
|
||||||
GetFn: func(ctx context.Context, query *metadata.AURQuery) ([]aur.Pkg, error) {
|
GetFn: func(ctx context.Context, query *aur.Query) ([]aur.Pkg, error) {
|
||||||
return []aur.Pkg{}, nil
|
return []aur.Pkg{}, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/Jguer/aur"
|
"github.com/Jguer/aur"
|
||||||
|
"github.com/Jguer/aur/rpc"
|
||||||
alpm "github.com/Jguer/go-alpm/v2"
|
alpm "github.com/Jguer/go-alpm/v2"
|
||||||
"github.com/leonelquinteros/gotext"
|
"github.com/leonelquinteros/gotext"
|
||||||
|
|
||||||
@ -29,10 +30,10 @@ type Pool struct {
|
|||||||
Groups []string
|
Groups []string
|
||||||
AlpmExecutor db.Executor
|
AlpmExecutor db.Executor
|
||||||
Warnings *query.AURWarnings
|
Warnings *query.AURWarnings
|
||||||
aurClient aur.ClientInterface
|
aurClient rpc.ClientInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPool(dbExecutor db.Executor, aurClient aur.ClientInterface) *Pool {
|
func newPool(dbExecutor db.Executor, aurClient rpc.ClientInterface) *Pool {
|
||||||
dp := &Pool{
|
dp := &Pool{
|
||||||
Targets: []Target{},
|
Targets: []Target{},
|
||||||
Explicit: map[string]struct{}{},
|
Explicit: map[string]struct{}{},
|
||||||
@ -348,7 +349,7 @@ func (dp *Pool) ResolveRepoDependency(pkg db.IPackage, noDeps bool) {
|
|||||||
func GetPool(ctx context.Context, pkgs []string,
|
func GetPool(ctx context.Context, pkgs []string,
|
||||||
warnings *query.AURWarnings,
|
warnings *query.AURWarnings,
|
||||||
dbExecutor db.Executor,
|
dbExecutor db.Executor,
|
||||||
aurClient aur.ClientInterface,
|
aurClient rpc.ClientInterface,
|
||||||
mode parser.TargetMode,
|
mode parser.TargetMode,
|
||||||
ignoreProviders, noConfirm, provides bool,
|
ignoreProviders, noConfirm, provides bool,
|
||||||
rebuild string, splitN int, noDeps bool, noCheckDeps bool, assumeInstalled []string,
|
rebuild string, splitN int, noDeps bool, noCheckDeps bool, assumeInstalled []string,
|
||||||
|
@ -14,7 +14,6 @@ import (
|
|||||||
"github.com/Jguer/yay/v11/pkg/topo"
|
"github.com/Jguer/yay/v11/pkg/topo"
|
||||||
|
|
||||||
aurc "github.com/Jguer/aur"
|
aurc "github.com/Jguer/aur"
|
||||||
"github.com/Jguer/aur/metadata"
|
|
||||||
alpm "github.com/Jguer/go-alpm/v2"
|
alpm "github.com/Jguer/go-alpm/v2"
|
||||||
gosrc "github.com/Morganamilo/go-srcinfo"
|
gosrc "github.com/Morganamilo/go-srcinfo"
|
||||||
"github.com/leonelquinteros/gotext"
|
"github.com/leonelquinteros/gotext"
|
||||||
@ -94,13 +93,9 @@ var colorMap = map[Reason]string{
|
|||||||
CheckDep: "forestgreen",
|
CheckDep: "forestgreen",
|
||||||
}
|
}
|
||||||
|
|
||||||
type AURCache interface {
|
|
||||||
Get(ctx context.Context, query *metadata.AURQuery) ([]aurc.Pkg, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Grapher struct {
|
type Grapher struct {
|
||||||
dbExecutor db.Executor
|
dbExecutor db.Executor
|
||||||
aurCache AURCache
|
aurCache aurc.QueryClient
|
||||||
fullGraph bool // If true, the graph will include all dependencies including already installed ones or repo
|
fullGraph bool // If true, the graph will include all dependencies including already installed ones or repo
|
||||||
noConfirm bool
|
noConfirm bool
|
||||||
noDeps bool // If true, the graph will not include dependencies
|
noDeps bool // If true, the graph will not include dependencies
|
||||||
@ -110,7 +105,7 @@ type Grapher struct {
|
|||||||
providerCache map[string]*aur.Pkg
|
providerCache map[string]*aur.Pkg
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGrapher(dbExecutor db.Executor, aurCache AURCache,
|
func NewGrapher(dbExecutor db.Executor, aurCache aurc.QueryClient,
|
||||||
fullGraph, noConfirm bool, output io.Writer, noDeps bool, noCheckDeps bool,
|
fullGraph, noConfirm bool, output io.Writer, noDeps bool, noCheckDeps bool,
|
||||||
) *Grapher {
|
) *Grapher {
|
||||||
return &Grapher{
|
return &Grapher{
|
||||||
@ -342,7 +337,7 @@ func (g *Grapher) GraphFromAURCache(ctx context.Context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, target := range targets {
|
for _, target := range targets {
|
||||||
aurPkgs, _ := g.aurCache.Get(ctx, &metadata.AURQuery{By: aurc.Name, Needles: []string{target}})
|
aurPkgs, _ := g.aurCache.Get(ctx, &aurc.Query{By: aurc.Name, Needles: []string{target}})
|
||||||
if len(aurPkgs) == 0 {
|
if len(aurPkgs) == 0 {
|
||||||
text.Errorln("No AUR package found for", target)
|
text.Errorln("No AUR package found for", target)
|
||||||
|
|
||||||
@ -447,7 +442,7 @@ func (g *Grapher) addNodes(
|
|||||||
} else {
|
} else {
|
||||||
var errMeta error
|
var errMeta error
|
||||||
aurPkgs, errMeta = g.aurCache.Get(ctx,
|
aurPkgs, errMeta = g.aurCache.Get(ctx,
|
||||||
&metadata.AURQuery{
|
&aurc.Query{
|
||||||
Needles: []string{depName},
|
Needles: []string{depName},
|
||||||
By: aurc.None,
|
By: aurc.None,
|
||||||
Contains: false,
|
Contains: false,
|
||||||
|
@ -7,13 +7,13 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
aurc "github.com/Jguer/aur"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/Jguer/yay/v11/pkg/db"
|
"github.com/Jguer/yay/v11/pkg/db"
|
||||||
"github.com/Jguer/yay/v11/pkg/db/mock"
|
"github.com/Jguer/yay/v11/pkg/db/mock"
|
||||||
mockaur "github.com/Jguer/yay/v11/pkg/dep/mock"
|
mockaur "github.com/Jguer/yay/v11/pkg/dep/mock"
|
||||||
aur "github.com/Jguer/yay/v11/pkg/query"
|
aur "github.com/Jguer/yay/v11/pkg/query"
|
||||||
|
|
||||||
"github.com/Jguer/aur/metadata"
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func ptrString(s string) *string {
|
func ptrString(s string) *string {
|
||||||
@ -31,7 +31,7 @@ func getFromFile(t *testing.T, filePath string) mockaur.GetFunc {
|
|||||||
err = json.Unmarshal(fBytes, &pkgs)
|
err = json.Unmarshal(fBytes, &pkgs)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
return func(ctx context.Context, query *metadata.AURQuery) ([]aur.Pkg, error) {
|
return func(ctx context.Context, query *aurc.Query) ([]aur.Pkg, error) {
|
||||||
return pkgs, nil
|
return pkgs, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ func TestGrapher_GraphFromTargets_jellyfin(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
mockAUR := &mockaur.MockAUR{GetFn: func(ctx context.Context, query *metadata.AURQuery) ([]aur.Pkg, error) {
|
mockAUR := &mockaur.MockAUR{GetFn: func(ctx context.Context, query *aurc.Query) ([]aur.Pkg, error) {
|
||||||
if query.Needles[0] == "jellyfin" {
|
if query.Needles[0] == "jellyfin" {
|
||||||
jfinFn := getFromFile(t, "testdata/jellyfin.json")
|
jfinFn := getFromFile(t, "testdata/jellyfin.json")
|
||||||
return jfinFn(ctx, query)
|
return jfinFn(ctx, query)
|
||||||
@ -93,7 +93,7 @@ func TestGrapher_GraphFromTargets_jellyfin(t *testing.T) {
|
|||||||
|
|
||||||
type fields struct {
|
type fields struct {
|
||||||
dbExecutor db.Executor
|
dbExecutor db.Executor
|
||||||
aurCache AURCache
|
aurCache aurc.QueryClient
|
||||||
noDeps bool
|
noDeps bool
|
||||||
noCheckDeps bool
|
noCheckDeps bool
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,15 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/Jguer/aur"
|
"github.com/Jguer/aur"
|
||||||
"github.com/Jguer/aur/metadata"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetFunc func(ctx context.Context, query *metadata.AURQuery) ([]aur.Pkg, error)
|
type GetFunc func(ctx context.Context, query *aur.Query) ([]aur.Pkg, error)
|
||||||
|
|
||||||
type MockAUR struct {
|
type MockAUR struct {
|
||||||
GetFn GetFunc
|
GetFn GetFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MockAUR) Get(ctx context.Context, query *metadata.AURQuery) ([]aur.Pkg, error) {
|
func (m *MockAUR) Get(ctx context.Context, query *aur.Query) ([]aur.Pkg, error) {
|
||||||
if m.GetFn != nil {
|
if m.GetFn != nil {
|
||||||
return m.GetFn(ctx, query)
|
return m.GetFn(ctx, query)
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/Jguer/aur"
|
"github.com/Jguer/aur"
|
||||||
|
"github.com/Jguer/aur/rpc"
|
||||||
"github.com/leonelquinteros/gotext"
|
"github.com/leonelquinteros/gotext"
|
||||||
|
|
||||||
"github.com/Jguer/yay/v11/pkg/intrange"
|
"github.com/Jguer/yay/v11/pkg/intrange"
|
||||||
@ -19,7 +20,7 @@ type Pkg = aur.Pkg
|
|||||||
// of packages exceeds the number set in config.RequestSplitN.
|
// of packages exceeds the number set in config.RequestSplitN.
|
||||||
// If the number does exceed config.RequestSplitN multiple aur requests will be
|
// If the number does exceed config.RequestSplitN multiple aur requests will be
|
||||||
// performed concurrently.
|
// performed concurrently.
|
||||||
func AURInfo(ctx context.Context, aurClient aur.ClientInterface, names []string, warnings *AURWarnings, splitN int) ([]Pkg, error) {
|
func AURInfo(ctx context.Context, aurClient rpc.ClientInterface, names []string, warnings *AURWarnings, splitN int) ([]Pkg, error) {
|
||||||
info := make([]Pkg, 0, len(names))
|
info := make([]Pkg, 0, len(names))
|
||||||
seen := make(map[string]int)
|
seen := make(map[string]int)
|
||||||
|
|
||||||
@ -84,7 +85,7 @@ func AURInfo(ctx context.Context, aurClient aur.ClientInterface, names []string,
|
|||||||
return info, nil
|
return info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AURInfoPrint(ctx context.Context, aurClient aur.ClientInterface, names []string, splitN int) ([]Pkg, error) {
|
func AURInfoPrint(ctx context.Context, aurClient rpc.ClientInterface, names []string, splitN int) ([]Pkg, error) {
|
||||||
text.OperationInfoln(gotext.Get("Querying AUR..."))
|
text.OperationInfoln(gotext.Get("Querying AUR..."))
|
||||||
|
|
||||||
warnings := &AURWarnings{}
|
warnings := &AURWarnings{}
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Jguer/aur"
|
"github.com/Jguer/aur"
|
||||||
|
"github.com/Jguer/aur/rpc"
|
||||||
"github.com/Jguer/go-alpm/v2"
|
"github.com/Jguer/go-alpm/v2"
|
||||||
"github.com/adrg/strutil"
|
"github.com/adrg/strutil"
|
||||||
"github.com/adrg/strutil/metrics"
|
"github.com/adrg/strutil/metrics"
|
||||||
@ -39,11 +40,11 @@ type MixedSourceQueryBuilder struct {
|
|||||||
bottomUp bool
|
bottomUp bool
|
||||||
singleLineResults bool
|
singleLineResults bool
|
||||||
|
|
||||||
aurClient aur.ClientInterface
|
aurClient rpc.ClientInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMixedSourceQueryBuilder(
|
func NewMixedSourceQueryBuilder(
|
||||||
aurClient aur.ClientInterface,
|
aurClient rpc.ClientInterface,
|
||||||
sortBy string,
|
sortBy string,
|
||||||
targetMode parser.TargetMode,
|
targetMode parser.TargetMode,
|
||||||
searchBy string,
|
searchBy string,
|
||||||
|
@ -5,9 +5,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/Jguer/aur/rpc"
|
||||||
|
|
||||||
"github.com/Jguer/yay/v11/pkg/settings/parser"
|
"github.com/Jguer/yay/v11/pkg/settings/parser"
|
||||||
|
|
||||||
"github.com/Jguer/aur"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
@ -30,7 +31,7 @@ func TestMixedSourceQueryBuilder(t *testing.T) {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.desc, func(t *testing.T) {
|
t.Run(tc.desc, func(t *testing.T) {
|
||||||
client, err := aur.NewClient(aur.WithHTTPClient(&mockDoer{}))
|
client, err := rpc.NewClient(rpc.WithHTTPClient(&mockDoer{}))
|
||||||
queryBuilder := NewMixedSourceQueryBuilder(client, "votes", parser.ModeAny, "", tc.bottomUp, false)
|
queryBuilder := NewMixedSourceQueryBuilder(client, "votes", parser.ModeAny, "", tc.bottomUp, false)
|
||||||
search := []string{"linux"}
|
search := []string{"linux"}
|
||||||
mockStore := &mockDB{}
|
mockStore := &mockDB{}
|
||||||
|
@ -16,7 +16,7 @@ import (
|
|||||||
"github.com/Jguer/yay/v11/pkg/stringset"
|
"github.com/Jguer/yay/v11/pkg/stringset"
|
||||||
"github.com/Jguer/yay/v11/pkg/text"
|
"github.com/Jguer/yay/v11/pkg/text"
|
||||||
|
|
||||||
"github.com/Jguer/aur/metadata"
|
"github.com/Jguer/aur/rpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SearchVerbosity int
|
type SearchVerbosity int
|
||||||
@ -28,10 +28,6 @@ const (
|
|||||||
Minimal
|
Minimal
|
||||||
)
|
)
|
||||||
|
|
||||||
type AURCache interface {
|
|
||||||
Get(ctx context.Context, query *metadata.AURQuery) ([]aur.Pkg, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type SourceQueryBuilder struct {
|
type SourceQueryBuilder struct {
|
||||||
repoQuery
|
repoQuery
|
||||||
aurQuery
|
aurQuery
|
||||||
@ -43,13 +39,13 @@ type SourceQueryBuilder struct {
|
|||||||
bottomUp bool
|
bottomUp bool
|
||||||
singleLineResults bool
|
singleLineResults bool
|
||||||
|
|
||||||
aurClient aur.ClientInterface
|
aurClient rpc.ClientInterface
|
||||||
aurCache AURCache
|
aurCache aur.QueryClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSourceQueryBuilder(
|
func NewSourceQueryBuilder(
|
||||||
aurClient aur.ClientInterface,
|
aurClient rpc.ClientInterface,
|
||||||
aurCache AURCache,
|
aurCache aur.QueryClient,
|
||||||
sortBy string,
|
sortBy string,
|
||||||
targetMode parser.TargetMode,
|
targetMode parser.TargetMode,
|
||||||
searchBy string,
|
searchBy string,
|
||||||
@ -197,7 +193,7 @@ func filterAURResults(pkgS []string, results []aur.Pkg) []aur.Pkg {
|
|||||||
|
|
||||||
// queryAUR searches AUR and narrows based on subarguments.
|
// queryAUR searches AUR and narrows based on subarguments.
|
||||||
func queryAUR(ctx context.Context,
|
func queryAUR(ctx context.Context,
|
||||||
aurClient aur.ClientInterface, aurMetadata AURCache,
|
aurClient rpc.ClientInterface, aurMetadata aur.QueryClient,
|
||||||
pkgS []string, searchBy string, newEngine bool,
|
pkgS []string, searchBy string, newEngine bool,
|
||||||
) ([]aur.Pkg, error) {
|
) ([]aur.Pkg, error) {
|
||||||
var (
|
var (
|
||||||
@ -209,7 +205,7 @@ func queryAUR(ctx context.Context,
|
|||||||
var r []aur.Pkg
|
var r []aur.Pkg
|
||||||
|
|
||||||
if aurMetadata != nil && newEngine {
|
if aurMetadata != nil && newEngine {
|
||||||
q, errM := aurMetadata.Get(ctx, &metadata.AURQuery{
|
q, errM := aurMetadata.Get(ctx, &aur.Query{
|
||||||
Needles: []string{word},
|
Needles: []string{word},
|
||||||
By: by,
|
By: by,
|
||||||
Contains: true,
|
Contains: true,
|
||||||
|
@ -8,11 +8,12 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/Jguer/aur/rpc"
|
||||||
|
|
||||||
"github.com/Jguer/yay/v11/pkg/db"
|
"github.com/Jguer/yay/v11/pkg/db"
|
||||||
"github.com/Jguer/yay/v11/pkg/db/mock"
|
"github.com/Jguer/yay/v11/pkg/db/mock"
|
||||||
"github.com/Jguer/yay/v11/pkg/settings/parser"
|
"github.com/Jguer/yay/v11/pkg/settings/parser"
|
||||||
|
|
||||||
"github.com/Jguer/aur"
|
|
||||||
"github.com/Jguer/go-alpm/v2"
|
"github.com/Jguer/go-alpm/v2"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@ -105,7 +106,7 @@ func TestSourceQueryBuilder(t *testing.T) {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.desc, func(t *testing.T) {
|
t.Run(tc.desc, func(t *testing.T) {
|
||||||
client, err := aur.NewClient(aur.WithHTTPClient(&mockDoer{}))
|
client, err := rpc.NewClient(rpc.WithHTTPClient(&mockDoer{}))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
queryBuilder := NewSourceQueryBuilder(client, nil, "votes", parser.ModeAny, "", tc.bottomUp, false, false)
|
queryBuilder := NewSourceQueryBuilder(client, nil, "votes", parser.ModeAny, "", tc.bottomUp, false, false)
|
||||||
|
@ -16,11 +16,10 @@ import (
|
|||||||
"github.com/Jguer/yay/v11/pkg/text"
|
"github.com/Jguer/yay/v11/pkg/text"
|
||||||
"github.com/Jguer/yay/v11/pkg/vcs"
|
"github.com/Jguer/yay/v11/pkg/vcs"
|
||||||
|
|
||||||
"github.com/Jguer/aur"
|
|
||||||
"github.com/Jguer/aur/metadata"
|
"github.com/Jguer/aur/metadata"
|
||||||
|
"github.com/Jguer/aur/rpc"
|
||||||
"github.com/Jguer/votar/pkg/vote"
|
"github.com/Jguer/votar/pkg/vote"
|
||||||
"github.com/leonelquinteros/gotext"
|
"github.com/leonelquinteros/gotext"
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// HideMenus indicates if pacman's provider menus must be hidden.
|
// HideMenus indicates if pacman's provider menus must be hidden.
|
||||||
@ -79,6 +78,7 @@ type Configuration struct {
|
|||||||
SeparateSources bool `json:"separatesources"`
|
SeparateSources bool `json:"separatesources"`
|
||||||
NewInstallEngine bool `json:"newinstallengine"`
|
NewInstallEngine bool `json:"newinstallengine"`
|
||||||
Debug bool `json:"debug"`
|
Debug bool `json:"debug"`
|
||||||
|
UseRPC bool `json:"rpc"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SaveConfig writes yay config to file.
|
// SaveConfig writes yay config to file.
|
||||||
@ -238,6 +238,7 @@ func DefaultConfig(version string) *Configuration {
|
|||||||
NewInstallEngine: false,
|
NewInstallEngine: false,
|
||||||
Version: version,
|
Version: version,
|
||||||
Debug: false,
|
Debug: false,
|
||||||
|
UseRPC: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,21 +311,25 @@ func NewConfig(version string) (*Configuration, error) {
|
|||||||
metadata.WithCacheFilePath(filepath.Join(newConfig.BuildDir, "aur.json")),
|
metadata.WithCacheFilePath(filepath.Join(newConfig.BuildDir, "aur.json")),
|
||||||
metadata.WithRequestEditorFn(userAgentFn),
|
metadata.WithRequestEditorFn(userAgentFn),
|
||||||
metadata.WithBaseURL(newConfig.AURURL),
|
metadata.WithBaseURL(newConfig.AURURL),
|
||||||
metadata.WithDebugLogger(text.Debugln),
|
metadata.WithDebugLogger(newConfig.Runtime.Logger.Child("aur").Debugln),
|
||||||
)
|
)
|
||||||
if errAURCache != nil {
|
if errAURCache != nil {
|
||||||
return nil, errors.Wrap(errAURCache, gotext.Get("failed to retrieve aur Cache"))
|
return nil, fmt.Errorf(gotext.Get("failed to retrieve aur Cache")+": %w", errAURCache)
|
||||||
}
|
}
|
||||||
|
|
||||||
var errAUR error
|
var errAUR error
|
||||||
newConfig.Runtime.AURClient, errAUR = aur.NewClient(
|
newConfig.Runtime.AURClient, errAUR = rpc.NewClient(
|
||||||
aur.WithHTTPClient(newConfig.Runtime.HTTPClient),
|
rpc.WithHTTPClient(newConfig.Runtime.HTTPClient),
|
||||||
aur.WithRequestEditorFn(userAgentFn))
|
rpc.WithRequestEditorFn(userAgentFn),
|
||||||
|
rpc.WithLogFn(newConfig.Runtime.Logger.Child("rpc").Debugln))
|
||||||
if errAUR != nil {
|
if errAUR != nil {
|
||||||
return nil, errAUR
|
return nil, errAUR
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if newConfig.UseRPC {
|
||||||
|
newConfig.Runtime.AURCache = newConfig.Runtime.AURClient
|
||||||
|
}
|
||||||
|
|
||||||
newConfig.Runtime.VCSStore = vcs.NewInfoStore(
|
newConfig.Runtime.VCSStore = vcs.NewInfoStore(
|
||||||
filepath.Join(cacheHome, vcsFileName), newConfig.Runtime.CmdBuilder)
|
filepath.Join(cacheHome, vcsFileName), newConfig.Runtime.CmdBuilder)
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package settings
|
package settings
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/Jguer/yay/v11/pkg/db"
|
"github.com/Jguer/yay/v11/pkg/db"
|
||||||
@ -12,15 +11,11 @@ import (
|
|||||||
"github.com/Jguer/yay/v11/pkg/vcs"
|
"github.com/Jguer/yay/v11/pkg/vcs"
|
||||||
|
|
||||||
"github.com/Jguer/aur"
|
"github.com/Jguer/aur"
|
||||||
"github.com/Jguer/aur/metadata"
|
"github.com/Jguer/aur/rpc"
|
||||||
"github.com/Jguer/votar/pkg/vote"
|
"github.com/Jguer/votar/pkg/vote"
|
||||||
"github.com/Morganamilo/go-pacmanconf"
|
"github.com/Morganamilo/go-pacmanconf"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AURCache interface {
|
|
||||||
Get(ctx context.Context, query *metadata.AURQuery) ([]aur.Pkg, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Runtime struct {
|
type Runtime struct {
|
||||||
Mode parser.TargetMode
|
Mode parser.TargetMode
|
||||||
QueryBuilder query.Builder
|
QueryBuilder query.Builder
|
||||||
@ -32,9 +27,9 @@ type Runtime struct {
|
|||||||
VCSStore vcs.Store
|
VCSStore vcs.Store
|
||||||
CmdBuilder exe.ICmdBuilder
|
CmdBuilder exe.ICmdBuilder
|
||||||
HTTPClient *http.Client
|
HTTPClient *http.Client
|
||||||
AURClient *aur.Client
|
AURClient *rpc.Client
|
||||||
VoteClient *vote.Client
|
VoteClient *vote.Client
|
||||||
AURCache AURCache
|
AURCache aur.QueryClient
|
||||||
DBExecutor db.Executor
|
DBExecutor db.Executor
|
||||||
Logger *text.Logger
|
Logger *text.Logger
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/Jguer/aur"
|
"github.com/Jguer/aur"
|
||||||
"github.com/Jguer/aur/metadata"
|
|
||||||
"github.com/Jguer/go-alpm/v2"
|
"github.com/Jguer/go-alpm/v2"
|
||||||
mapset "github.com/deckarep/golang-set/v2"
|
mapset "github.com/deckarep/golang-set/v2"
|
||||||
"github.com/leonelquinteros/gotext"
|
"github.com/leonelquinteros/gotext"
|
||||||
@ -14,7 +13,6 @@ import (
|
|||||||
"github.com/Jguer/yay/v11/pkg/dep"
|
"github.com/Jguer/yay/v11/pkg/dep"
|
||||||
"github.com/Jguer/yay/v11/pkg/intrange"
|
"github.com/Jguer/yay/v11/pkg/intrange"
|
||||||
"github.com/Jguer/yay/v11/pkg/multierror"
|
"github.com/Jguer/yay/v11/pkg/multierror"
|
||||||
"github.com/Jguer/yay/v11/pkg/query"
|
|
||||||
"github.com/Jguer/yay/v11/pkg/settings"
|
"github.com/Jguer/yay/v11/pkg/settings"
|
||||||
"github.com/Jguer/yay/v11/pkg/text"
|
"github.com/Jguer/yay/v11/pkg/text"
|
||||||
"github.com/Jguer/yay/v11/pkg/topo"
|
"github.com/Jguer/yay/v11/pkg/topo"
|
||||||
@ -23,8 +21,7 @@ import (
|
|||||||
|
|
||||||
type UpgradeService struct {
|
type UpgradeService struct {
|
||||||
grapher *dep.Grapher
|
grapher *dep.Grapher
|
||||||
aurCache settings.AURCache
|
aurCache aur.QueryClient
|
||||||
aurClient aur.ClientInterface
|
|
||||||
dbExecutor db.Executor
|
dbExecutor db.Executor
|
||||||
vcsStore vcs.Store
|
vcsStore vcs.Store
|
||||||
runtime *settings.Runtime
|
runtime *settings.Runtime
|
||||||
@ -33,15 +30,13 @@ type UpgradeService struct {
|
|||||||
noConfirm bool
|
noConfirm bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUpgradeService(grapher *dep.Grapher, aurCache settings.AURCache,
|
func NewUpgradeService(grapher *dep.Grapher, aurCache aur.QueryClient,
|
||||||
aurClient aur.ClientInterface, dbExecutor db.Executor,
|
dbExecutor db.Executor, vcsStore vcs.Store, runtime *settings.Runtime,
|
||||||
vcsStore vcs.Store, runtime *settings.Runtime, cfg *settings.Configuration,
|
cfg *settings.Configuration, noConfirm bool, logger *text.Logger,
|
||||||
noConfirm bool, logger *text.Logger,
|
|
||||||
) *UpgradeService {
|
) *UpgradeService {
|
||||||
return &UpgradeService{
|
return &UpgradeService{
|
||||||
grapher: grapher,
|
grapher: grapher,
|
||||||
aurCache: aurCache,
|
aurCache: aurCache,
|
||||||
aurClient: aurClient,
|
|
||||||
dbExecutor: dbExecutor,
|
dbExecutor: dbExecutor,
|
||||||
vcsStore: vcsStore,
|
vcsStore: vcsStore,
|
||||||
runtime: runtime,
|
runtime: runtime,
|
||||||
@ -53,7 +48,7 @@ func NewUpgradeService(grapher *dep.Grapher, aurCache settings.AURCache,
|
|||||||
|
|
||||||
// upGraph adds packages to upgrade to the graph.
|
// upGraph adds packages to upgrade to the graph.
|
||||||
func (u *UpgradeService) upGraph(ctx context.Context, graph *topo.Graph[string, *dep.InstallInfo],
|
func (u *UpgradeService) upGraph(ctx context.Context, graph *topo.Graph[string, *dep.InstallInfo],
|
||||||
warnings *query.AURWarnings, enableDowngrade bool,
|
enableDowngrade bool,
|
||||||
filter Filter,
|
filter Filter,
|
||||||
) (err error) {
|
) (err error) {
|
||||||
var (
|
var (
|
||||||
@ -69,12 +64,7 @@ func (u *UpgradeService) upGraph(ctx context.Context, graph *topo.Graph[string,
|
|||||||
if u.runtime.Mode.AtLeastAUR() {
|
if u.runtime.Mode.AtLeastAUR() {
|
||||||
u.log.OperationInfoln(gotext.Get("Searching AUR for updates..."))
|
u.log.OperationInfoln(gotext.Get("Searching AUR for updates..."))
|
||||||
|
|
||||||
var _aurdata []aur.Pkg
|
_aurdata, err := u.aurCache.Get(ctx, &aur.Query{Needles: remoteNames, By: aur.Name})
|
||||||
if u.aurCache != nil {
|
|
||||||
_aurdata, err = u.aurCache.Get(ctx, &metadata.AURQuery{Needles: remoteNames, By: aur.Name})
|
|
||||||
} else {
|
|
||||||
_aurdata, err = query.AURInfo(ctx, u.aurClient, remoteNames, warnings, u.cfg.RequestSplitN)
|
|
||||||
}
|
|
||||||
|
|
||||||
errs.Add(err)
|
errs.Add(err)
|
||||||
|
|
||||||
@ -235,16 +225,12 @@ func (u *UpgradeService) GraphUpgrades(ctx context.Context,
|
|||||||
graph = topo.New[string, *dep.InstallInfo]()
|
graph = topo.New[string, *dep.InstallInfo]()
|
||||||
}
|
}
|
||||||
|
|
||||||
warnings := query.NewWarnings()
|
err := u.upGraph(ctx, graph, enableDowngrade,
|
||||||
|
|
||||||
err := u.upGraph(ctx, graph, warnings, enableDowngrade,
|
|
||||||
func(*Upgrade) bool { return true })
|
func(*Upgrade) bool { return true })
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return graph, err
|
return graph, err
|
||||||
}
|
}
|
||||||
|
|
||||||
warnings.Print()
|
|
||||||
|
|
||||||
if graph.Len() == 0 {
|
if graph.Len() == 0 {
|
||||||
return graph, nil
|
return graph, nil
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/Jguer/aur"
|
"github.com/Jguer/aur"
|
||||||
"github.com/Jguer/aur/metadata"
|
|
||||||
"github.com/Jguer/go-alpm/v2"
|
"github.com/Jguer/go-alpm/v2"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
@ -115,7 +114,7 @@ func TestUpgradeService_GraphUpgrades(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mockAUR := &mockaur.MockAUR{
|
mockAUR := &mockaur.MockAUR{
|
||||||
GetFn: func(ctx context.Context, query *metadata.AURQuery) ([]aur.Pkg, error) {
|
GetFn: func(ctx context.Context, query *aur.Query) ([]aur.Pkg, error) {
|
||||||
return []aur.Pkg{
|
return []aur.Pkg{
|
||||||
{Name: "yay", Version: "10.2.4", PackageBase: "yay"},
|
{Name: "yay", Version: "10.2.4", PackageBase: "yay"},
|
||||||
{Name: "example-git", Version: "2.2.1.r69.g8a10460-1", PackageBase: "example"},
|
{Name: "example-git", Version: "2.2.1.r69.g8a10460-1", PackageBase: "example"},
|
||||||
|
4
sync.go
4
sync.go
@ -56,8 +56,8 @@ func syncInstall(ctx context.Context,
|
|||||||
var errSysUp error
|
var errSysUp error
|
||||||
|
|
||||||
upService := upgrade.NewUpgradeService(
|
upService := upgrade.NewUpgradeService(
|
||||||
grapher, aurCache, config.Runtime.AURClient,
|
grapher, aurCache, dbExecutor, config.Runtime.VCSStore,
|
||||||
dbExecutor, config.Runtime.VCSStore, config.Runtime, config, settings.NoConfirm, config.Runtime.Logger.Child("upgrade"))
|
config.Runtime, config, settings.NoConfirm, config.Runtime.Logger.Child("upgrade"))
|
||||||
|
|
||||||
graph, errSysUp = upService.GraphUpgrades(ctx, graph, cmdArgs.ExistsDouble("u", "sysupgrade"))
|
graph, errSysUp = upService.GraphUpgrades(ctx, graph, cmdArgs.ExistsDouble("u", "sysupgrade"))
|
||||||
if errSysUp != nil {
|
if errSysUp != nil {
|
||||||
|
4
vote.go
4
vote.go
@ -5,7 +5,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/Jguer/aur"
|
"github.com/Jguer/aur/rpc"
|
||||||
"github.com/Jguer/votar/pkg/vote"
|
"github.com/Jguer/votar/pkg/vote"
|
||||||
"github.com/leonelquinteros/gotext"
|
"github.com/leonelquinteros/gotext"
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ func (e *ErrAURVote) Error() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func handlePackageVote(ctx context.Context,
|
func handlePackageVote(ctx context.Context,
|
||||||
targets []string, aurClient aur.ClientInterface,
|
targets []string, aurClient rpc.ClientInterface,
|
||||||
voteClient *vote.Client, splitN int, upvote bool,
|
voteClient *vote.Client, splitN int, upvote bool,
|
||||||
) error {
|
) error {
|
||||||
infos, err := query.AURInfoPrint(ctx, aurClient, targets, splitN)
|
infos, err := query.AURInfoPrint(ctx, aurClient, targets, splitN)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user