mirror of
https://github.com/Jguer/yay.git
synced 2024-11-06 17:17:22 +01:00
extract upgrade target adder
This commit is contained in:
parent
849e8f7b60
commit
d3efb59da3
33
install.go
33
install.go
@ -125,18 +125,10 @@ func install(ctx context.Context, cmdArgs *parser.Arguments, dbExecutor db.Execu
|
||||
|
||||
// if we are doing -u also request all packages needing update
|
||||
if sysupgradeArg {
|
||||
ignore, targets, errUp := sysupgradeTargets(ctx, dbExecutor, cmdArgs.ExistsDouble("u", "sysupgrade"))
|
||||
if errUp != nil {
|
||||
return errUp
|
||||
}
|
||||
|
||||
for _, up := range targets {
|
||||
cmdArgs.AddTarget(up)
|
||||
requestTargets = append(requestTargets, up)
|
||||
}
|
||||
|
||||
if len(ignore) > 0 {
|
||||
arguments.CreateOrAppendOption("ignore", ignore.ToSlice()...)
|
||||
var errSysUp error
|
||||
requestTargets, errSysUp = addUpgradeTargetsToArgs(ctx, dbExecutor, cmdArgs, requestTargets, arguments)
|
||||
if errSysUp != nil {
|
||||
return errSysUp
|
||||
}
|
||||
}
|
||||
|
||||
@ -352,6 +344,23 @@ func install(ctx context.Context, cmdArgs *parser.Arguments, dbExecutor db.Execu
|
||||
return nil
|
||||
}
|
||||
|
||||
func addUpgradeTargetsToArgs(ctx context.Context, dbExecutor db.Executor, cmdArgs *parser.Arguments, requestTargets []string, arguments *parser.Arguments) ([]string, error) {
|
||||
ignore, targets, errUp := sysupgradeTargets(ctx, dbExecutor, cmdArgs.ExistsDouble("u", "sysupgrade"))
|
||||
if errUp != nil {
|
||||
return nil, errUp
|
||||
}
|
||||
|
||||
for _, up := range targets {
|
||||
cmdArgs.AddTarget(up)
|
||||
requestTargets = append(requestTargets, up)
|
||||
}
|
||||
|
||||
if len(ignore) > 0 {
|
||||
arguments.CreateOrAppendOption("ignore", ignore.ToSlice()...)
|
||||
}
|
||||
return requestTargets, nil
|
||||
}
|
||||
|
||||
func removeMake(ctx context.Context, cmdBuilder exe.ICmdBuilder, makeDeps []string) error {
|
||||
removeArguments := parser.MakeArguments()
|
||||
|
||||
|
@ -12,10 +12,12 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/leonelquinteros/gotext"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/Jguer/aur"
|
||||
"github.com/Jguer/votar/pkg/vote"
|
||||
|
||||
"github.com/Jguer/yay/v11/pkg/metadata"
|
||||
"github.com/Jguer/yay/v11/pkg/settings/exe"
|
||||
"github.com/Jguer/yay/v11/pkg/settings/parser"
|
||||
"github.com/Jguer/yay/v11/pkg/text"
|
||||
@ -285,8 +287,14 @@ func NewConfig(version string) (*Configuration, error) {
|
||||
QueryBuilder: nil,
|
||||
}
|
||||
|
||||
var errAUR error
|
||||
var errAURCache error
|
||||
|
||||
newConfig.Runtime.AURCache, errAURCache = metadata.NewAURCache(filepath.Join(newConfig.BuildDir, "aur.json"))
|
||||
if errAURCache != nil {
|
||||
return nil, errors.Wrap(errAURCache, gotext.Get("failed to retrieve aur Cache"))
|
||||
}
|
||||
|
||||
var errAUR error
|
||||
newConfig.Runtime.AURClient, errAUR = aur.NewClient(aur.WithHTTPClient(newConfig.Runtime.HTTPClient),
|
||||
aur.WithRequestEditorFn(func(ctx context.Context, req *http.Request) error {
|
||||
req.Header.Set("User-Agent", userAgent)
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"github.com/Jguer/aur"
|
||||
"github.com/Jguer/votar/pkg/vote"
|
||||
|
||||
"github.com/Jguer/yay/v11/pkg/metadata"
|
||||
"github.com/Jguer/yay/v11/pkg/query"
|
||||
"github.com/Jguer/yay/v11/pkg/settings/exe"
|
||||
"github.com/Jguer/yay/v11/pkg/settings/parser"
|
||||
@ -27,4 +28,5 @@ type Runtime struct {
|
||||
HTTPClient *http.Client
|
||||
AURClient *aur.Client
|
||||
VoteClient *vote.Client
|
||||
AURCache *metadata.AURCache
|
||||
}
|
||||
|
19
sync.go
19
sync.go
@ -3,25 +3,28 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/Jguer/yay/v11/pkg/db"
|
||||
"github.com/Jguer/yay/v11/pkg/dep"
|
||||
"github.com/Jguer/yay/v11/pkg/metadata"
|
||||
"github.com/Jguer/yay/v11/pkg/settings"
|
||||
"github.com/Jguer/yay/v11/pkg/settings/parser"
|
||||
"github.com/Jguer/yay/v11/pkg/text"
|
||||
"github.com/leonelquinteros/gotext"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func syncInstall(ctx context.Context,
|
||||
config *settings.Configuration,
|
||||
cmdArgs *parser.Arguments, dbExecutor db.Executor,
|
||||
cmdArgs *parser.Arguments,
|
||||
dbExecutor db.Executor,
|
||||
) error {
|
||||
aurCache, err := metadata.NewAURCache(filepath.Join(config.BuildDir, "aur.json"))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, gotext.Get("failed to retrieve aur Cache"))
|
||||
aurCache := config.Runtime.AURCache
|
||||
|
||||
if cmdArgs.ExistsArg("u", "sysupgrade") {
|
||||
var errSysUp error
|
||||
// All of the installs are done as explicit installs, this should be move to a grapher method
|
||||
_, errSysUp = addUpgradeTargetsToArgs(ctx, dbExecutor, cmdArgs, []string{}, cmdArgs)
|
||||
if errSysUp != nil {
|
||||
return errSysUp
|
||||
}
|
||||
}
|
||||
|
||||
grapher := dep.NewGrapher(dbExecutor, aurCache, false, settings.NoConfirm, os.Stdout)
|
||||
|
@ -171,7 +171,7 @@ func upgradePkgsMenu(aurUp, repoUp upgrade.UpSlice) (stringset.StringSet, []stri
|
||||
|
||||
if !config.UpgradeMenu {
|
||||
for _, pkg := range aurUp.Up {
|
||||
targets = append(targets, pkg.Name)
|
||||
targets = append(targets, pkg.Repository+"/"+pkg.Name)
|
||||
}
|
||||
|
||||
return ignore, targets, nil
|
||||
@ -204,12 +204,12 @@ func upgradePkgsMenu(aurUp, repoUp upgrade.UpSlice) (stringset.StringSet, []stri
|
||||
}
|
||||
|
||||
if isInclude && !include.Get(len(repoUp.Up)-i+len(aurUp.Up)) {
|
||||
targets = append(targets, pkg.Name)
|
||||
targets = append(targets, pkg.Repository+"/"+pkg.Name)
|
||||
continue
|
||||
}
|
||||
|
||||
if !isInclude && (exclude.Get(len(repoUp.Up)-i+len(aurUp.Up)) || otherExclude.Get(pkg.Repository)) {
|
||||
targets = append(targets, pkg.Name)
|
||||
targets = append(targets, pkg.Repository+"/"+pkg.Name)
|
||||
continue
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user