From 906748ebdec4b2b243fb57c91c03e3b05bfe77cc Mon Sep 17 00:00:00 2001 From: morganamilo Date: Wed, 11 Apr 2018 04:53:33 +0100 Subject: [PATCH] Don't mark repo upgrades as deps during sysupgrade Before `yay -Syu` called `pacman -Sy ` We then later switched to it calling `pacman -Syu` this lead to yay seeing no targets to when it was upgrading a bunch of packages it assumed they must be deps. Correct this by adding repo packages to the targets list. Also ensure we dont mark packages as dependencies if they are already installed. For example we install `foo` which requires `bar>5` but we only have `bar=4` installed. In this case installing `foo` will pull bar in as a dependency but it should not be marked as such because it already exists. --- config.go | 2 +- install.go | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/config.go b/config.go index e5c88e20..d113064d 100644 --- a/config.go +++ b/config.go @@ -187,7 +187,7 @@ func editor() (string, []string) { fallthrough default: fmt.Println() - fmt.Println(bold(red(arrow) + " Warning:"), cyan("$EDITOR"), "is not set") + fmt.Println(bold(red(arrow)+" Warning:"), cyan("$EDITOR"), "is not set") fmt.Println(bold(arrow) + " Please add " + cyan("$EDITOR") + " or " + cyan("$VISUAL") + " to your environment variables.") for { diff --git a/install.go b/install.go index fc478797..6814aee2 100644 --- a/install.go +++ b/install.go @@ -29,7 +29,7 @@ func install(parser *arguments) error { srcinfos := make(map[string]*gopkg.PKGBUILD) //remotenames: names of all non repo packages on the system - _, _, _, remoteNames, err := filterPackages() + _, _, localNames, remoteNames, err := filterPackages() if err != nil { return err } @@ -37,6 +37,7 @@ func install(parser *arguments) error { //cache as a stringset. maybe make it return a string set in the first //place remoteNamesCache := sliceToStringSet(remoteNames) + localNamesCache := sliceToStringSet(localNames) //if we are doing -u also request all packages needing update if parser.existsArg("u", "sysupgrade") { @@ -103,6 +104,7 @@ func install(parser *arguments) error { for _, up := range repoUp { if !ignore.get(up.Name) { requestTargets = append(requestTargets, up.Name) + parser.addTarget(up.Name) } } @@ -209,7 +211,7 @@ func install(parser *arguments) error { depArguments.addArg("D", "asdeps") for _, pkg := range dc.Repo { - if !parser.targets.get(pkg.Name()) { + if !parser.targets.get(pkg.Name()) && !localNamesCache.get(pkg.Name()) && !remoteNamesCache.get(pkg.Name()) { depArguments.addTarget(pkg.Name()) } } @@ -650,6 +652,17 @@ func buildInstallPkgBuilds(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD, depArguments := makeArguments() depArguments.addArg("D", "asdeps") + //remotenames: names of all non repo packages on the system + _, _, localNames, remoteNames, err := filterPackages() + if err != nil { + return err + } + + //cache as a stringset. maybe make it return a string set in the first + //place + remoteNamesCache := sliceToStringSet(remoteNames) + localNamesCache := sliceToStringSet(localNames) + for _, split := range bases[pkg.PackageBase] { file, err := completeFileName(dir, split.Name+"-"+version.String()+"-"+arch+".pkg") if err != nil { @@ -668,14 +681,15 @@ func buildInstallPkgBuilds(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD, } arguments.addTarget(file) - if !targets.get(split.Name) { + //if !targets.get(split.Name) { + if !targets.get(split.Name) && !localNamesCache.get(split.Name) && !remoteNamesCache.get(split.Name) { depArguments.addTarget(split.Name) } } oldConfirm := config.NoConfirm config.NoConfirm = true - err := passToPacman(arguments) + err = passToPacman(arguments) if err != nil { return err }