mirror of
https://github.com/Jguer/yay.git
synced 2024-11-06 17:17:22 +01:00
Merge pull request #302 from Morganamilo/fix#287
Only pass needed upgrades to deptree
This commit is contained in:
commit
5b7daa129a
50
install.go
50
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,18 +72,14 @@ 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) {
|
||||
str := bold(red(arrow+" Error: ")) + "Could not find all required packages:"
|
||||
if len(dt.Missing) > 0 {
|
||||
str := bold(red(arrow+" Error: ")) + "Could not find all required packages:"
|
||||
|
||||
for name := range dt.Missing {
|
||||
str += "\n\t" + name
|
||||
}
|
||||
|
||||
return fmt.Errorf("%s", str)
|
||||
for name := range dt.Missing {
|
||||
str += "\n\t" + name
|
||||
}
|
||||
|
||||
return fmt.Errorf("%s", str)
|
||||
}
|
||||
|
||||
//create the arguments to pass for the repo install
|
||||
@ -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 New Issue
Block a user