mirror of
https://github.com/Jguer/yay
synced 2024-10-06 08:09:11 +00:00
Only pass needed upgrades to deptree
To know what AUR packages need updating a rpc request is needed for all packages. The dep tree is designed to cache everything to minimize the amount of rpc requests. The downside of this is the dep tree ends up with all sorts of packages in cache that it doesn't need. Then the deptree tries to resolve deps for all of thoes packages. By spliting the sysupgrade from the dep tree this stops this from happening, it uses one more rpc request but also may lower the amount of total rpc requests needed lated on. This fixes a couple of tiny bugs such as triggering providers prompts and printing AUR out of date messages for packages that are not going to be installed. This also fixes another display bug where repo packages from -Su would not apear when printing the packages to be installed under [Repo].
This commit is contained in:
parent
bb9f7a6205
commit
a04dd94282
40
install.go
40
install.go
|
@ -22,9 +22,13 @@ func install(parser *arguments) error {
|
|||
var toClean []*rpc.Pkg
|
||||
var toEdit []*rpc.Pkg
|
||||
|
||||
var aurUp upSlice
|
||||
var repoUp upSlice
|
||||
|
||||
removeMake := false
|
||||
srcinfosStale := make(map[string]*gopkg.PKGBUILD)
|
||||
srcinfos := make(map[string]*gopkg.PKGBUILD)
|
||||
|
||||
//remotenames: names of all non repo packages on the system
|
||||
_, _, _, remoteNames, err := filterPackages()
|
||||
if err != nil {
|
||||
|
@ -35,9 +39,21 @@ func install(parser *arguments) error {
|
|||
//place
|
||||
remoteNamesCache := sliceToStringSet(remoteNames)
|
||||
|
||||
//if we are doing -u also request every non repo package on the system
|
||||
//if we are doing -u also request all packages needing update
|
||||
if parser.existsArg("u", "sysupgrade") {
|
||||
requestTargets = append(requestTargets, remoteNames...)
|
||||
aurUp, repoUp, err = upList()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, up := range aurUp {
|
||||
requestTargets = append(requestTargets, up.Name)
|
||||
}
|
||||
|
||||
for _, up := range repoUp {
|
||||
requestTargets = append(requestTargets, up.Name)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//if len(aurTargets) > 0 || parser.existsArg("u", "sysupgrade") && len(remoteNames) > 0 {
|
||||
|
@ -56,10 +72,7 @@ func install(parser *arguments) error {
|
|||
parser.targets.set(name)
|
||||
}
|
||||
|
||||
//only error if direct targets or deps are missing
|
||||
for missing := range dt.Missing {
|
||||
_, missingName := splitDbFromName(missing)
|
||||
if !remoteNamesCache.get(missingName) || parser.targets.get(missingName) {
|
||||
if len(dt.Missing) > 0 {
|
||||
str := bold(red(arrow+" Error: ")) + "Could not find all required packages:"
|
||||
|
||||
for name := range dt.Missing {
|
||||
|
@ -68,7 +81,6 @@ func install(parser *arguments) error {
|
|||
|
||||
return fmt.Errorf("%s", str)
|
||||
}
|
||||
}
|
||||
|
||||
//create the arguments to pass for the repo install
|
||||
arguments := parser.copy()
|
||||
|
@ -77,7 +89,7 @@ func install(parser *arguments) error {
|
|||
arguments.targets = make(stringSet)
|
||||
|
||||
if parser.existsArg("u", "sysupgrade") {
|
||||
ignore, aurUp, err := upgradePkgs(dt)
|
||||
ignore, aurUp, err := upgradePkgs(aurUp, repoUp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -88,16 +100,6 @@ func install(parser *arguments) error {
|
|||
for pkg := range aurUp {
|
||||
parser.addTarget(pkg)
|
||||
}
|
||||
|
||||
//discard stuff thats
|
||||
//not a target and
|
||||
//not an upgrade and
|
||||
//is installed
|
||||
for pkg := range dt.Aur {
|
||||
if !parser.targets.get(pkg) && remoteNamesCache.get(pkg) {
|
||||
delete(dt.Aur, pkg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hasAur := false
|
||||
|
@ -112,7 +114,7 @@ func install(parser *arguments) error {
|
|||
return fmt.Errorf(red(arrow + " Refusing to install AUR Packages as root, Aborting."))
|
||||
}
|
||||
|
||||
dc, err = getDepCatagories(parser.formatTargets(), dt)
|
||||
dc, err = getDepCatagories(requestTargets, dt)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
12
print.go
12
print.go
|
@ -288,9 +288,7 @@ func printNumberOfUpdates() error {
|
|||
//todo
|
||||
old := os.Stdout // keep backup of the real stdout
|
||||
os.Stdout = nil
|
||||
_, _, localNames, remoteNames, err := filterPackages()
|
||||
dt, _ := getDepTree(append(localNames, remoteNames...))
|
||||
aurUp, repoUp, err := upList(dt)
|
||||
aurUp, repoUp, err := upList()
|
||||
os.Stdout = old // restoring the real stdout
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -302,13 +300,11 @@ func printNumberOfUpdates() error {
|
|||
|
||||
//TODO: Make it less hacky
|
||||
func printUpdateList(parser *arguments) error {
|
||||
old := os.Stdout // Keep backup of the real stdout
|
||||
old := os.Stdout // keep backup of the real stdout
|
||||
os.Stdout = nil
|
||||
_, _, localNames, remoteNames, err := filterPackages()
|
||||
dt, _ := getDepTree(append(localNames, remoteNames...))
|
||||
aurUp, repoUp, err := upList(dt)
|
||||
|
||||
os.Stdout = old // Restoring the real stdout
|
||||
aurUp, repoUp, err := upList()
|
||||
os.Stdout = old // restoring the real stdout
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
31
upgrade.go
31
upgrade.go
|
@ -9,6 +9,7 @@ import (
|
|||
"sync"
|
||||
|
||||
alpm "github.com/jguer/go-alpm"
|
||||
rpc "github.com/mikkeloscar/aur"
|
||||
pkgb "github.com/mikkeloscar/gopkgbuild"
|
||||
)
|
||||
|
||||
|
@ -88,7 +89,7 @@ func getVersionDiff(oldVersion, newversion string) (left, right string) {
|
|||
}
|
||||
|
||||
// upList returns lists of packages to upgrade from each source.
|
||||
func upList(dt *depTree) (aurUp upSlice, repoUp upSlice, err error) {
|
||||
func upList() (aurUp upSlice, repoUp upSlice, err error) {
|
||||
local, remote, _, remoteNames, err := filterPackages()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
@ -111,7 +112,7 @@ func upList(dt *depTree) (aurUp upSlice, repoUp upSlice, err error) {
|
|||
fmt.Println(bold(cyan("::") + " Searching AUR for updates..."))
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
aurUp, aurErr = upAUR(remote, remoteNames, dt)
|
||||
aurUp, aurErr = upAUR(remote, remoteNames)
|
||||
wg.Done()
|
||||
}()
|
||||
|
||||
|
@ -205,9 +206,20 @@ func upDevel(remote []alpm.Package) (toUpgrade upSlice, err error) {
|
|||
|
||||
// upAUR gathers foreign packages and checks if they have new versions.
|
||||
// Output: Upgrade type package list.
|
||||
func upAUR(remote []alpm.Package, remoteNames []string, dt *depTree) (toUpgrade upSlice, err error) {
|
||||
func upAUR(remote []alpm.Package, remoteNames []string) (upSlice, error) {
|
||||
toUpgrade := make(upSlice, 0)
|
||||
_pkgdata, err := aurInfo(remoteNames)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pkgdata := make(map[string]*rpc.Pkg)
|
||||
for _, pkg := range _pkgdata {
|
||||
pkgdata[pkg.Name] = pkg
|
||||
}
|
||||
|
||||
for _, pkg := range remote {
|
||||
aurPkg, ok := dt.Aur[pkg.Name()]
|
||||
aurPkg, ok := pkgdata[pkg.Name()]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
@ -224,7 +236,7 @@ func upAUR(remote []alpm.Package, remoteNames []string, dt *depTree) (toUpgrade
|
|||
}
|
||||
}
|
||||
|
||||
return
|
||||
return toUpgrade, nil
|
||||
}
|
||||
|
||||
// upRepo gathers local packages and checks if they have new versions.
|
||||
|
@ -253,15 +265,12 @@ func upRepo(local []alpm.Package) (upSlice, error) {
|
|||
}
|
||||
|
||||
// upgradePkgs handles updating the cache and installing updates.
|
||||
func upgradePkgs(dt *depTree) (stringSet, stringSet, error) {
|
||||
func upgradePkgs(aurUp, repoUp upSlice) (stringSet, stringSet, error) {
|
||||
ignore := make(stringSet)
|
||||
aurNames := make(stringSet)
|
||||
|
||||
aurUp, repoUp, err := upList(dt)
|
||||
if err != nil {
|
||||
return ignore, aurNames, err
|
||||
} else if len(aurUp)+len(repoUp) == 0 {
|
||||
return ignore, aurNames, err
|
||||
if len(aurUp)+len(repoUp) == 0 {
|
||||
return ignore, aurNames, nil
|
||||
}
|
||||
|
||||
sort.Sort(repoUp)
|
||||
|
|
Loading…
Reference in a new issue