From 4b73ba37f3cc3278d9117a1a1408c9ab3c5e5819 Mon Sep 17 00:00:00 2001 From: morganamilo Date: Sun, 13 May 2018 18:56:09 +0100 Subject: [PATCH 1/2] Updated vendor dependencies --- Gopkg.lock | 2 +- vendor/github.com/mikkeloscar/gopkgbuild/pkgbuild.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 158a2189..c1ea255d 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -17,7 +17,7 @@ branch = "master" name = "github.com/mikkeloscar/gopkgbuild" packages = ["."] - revision = "32274fc52aa8f5eb28711da734179e9aea27b31f" + revision = "763d921490d8f4b23b1141c89ce8f9678ac025a7" [solve-meta] analyzer-name = "dep" diff --git a/vendor/github.com/mikkeloscar/gopkgbuild/pkgbuild.go b/vendor/github.com/mikkeloscar/gopkgbuild/pkgbuild.go index f1f02b12..ac267f7f 100644 --- a/vendor/github.com/mikkeloscar/gopkgbuild/pkgbuild.go +++ b/vendor/github.com/mikkeloscar/gopkgbuild/pkgbuild.go @@ -616,7 +616,7 @@ func isLowerAlpha(c rune) bool { // check if c is a valid pkgname char func isValidPkgnameChar(c rune) bool { - return isLowerAlpha(c) || isDigit(c) || c == '@' || c == '.' || c == '_' || c == '+' || c == '-' + return isAlphaNumeric(c) || c == '@' || c == '.' || c == '_' || c == '+' || c == '-' } // check if c is a valid pkgver char From d1602083f223a8ff1b891335f297a77fad621470 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Tue, 8 May 2018 09:51:49 +0300 Subject: [PATCH 2/2] Print warnings about newer local packages then remote versions Inspired by [`pakku`](https://github.com/kitsunyan/pakku) --- upgrade.go | 53 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/upgrade.go b/upgrade.go index ec78dce8..75b3e311 100644 --- a/upgrade.go +++ b/upgrade.go @@ -138,6 +138,8 @@ func upList(warnings *aurWarnings) (aurUp upSlice, repoUp upSlice, err error) { var aurErr error var develErr error + pkgdata := make(map[string]*rpc.Pkg) + fmt.Println(bold(cyan("::") + bold(" Searching databases for updates..."))) wg.Add(1) go func() { @@ -148,7 +150,7 @@ func upList(warnings *aurWarnings) (aurUp upSlice, repoUp upSlice, err error) { fmt.Println(bold(cyan("::") + bold(" Searching AUR for updates..."))) wg.Add(1) go func() { - aurUp, aurErr = upAUR(remote, remoteNames, warnings) + aurUp, aurErr = upAUR(remote, remoteNames, pkgdata, warnings) wg.Done() }() @@ -163,6 +165,8 @@ func upList(warnings *aurWarnings) (aurUp upSlice, repoUp upSlice, err error) { wg.Wait() + printLocalNewerThanAUR(remote, pkgdata) + errs := make([]string, 0) for _, e := range []error{repoErr, aurErr, develErr} { if e != nil { @@ -228,9 +232,7 @@ func upDevel(remote []alpm.Package) (toUpgrade upSlice, err error) { for _, pkg := range toUpdate { if pkg.ShouldIgnore() { - left, right := getVersionDiff(pkg.Version(), "latest-commit") - fmt.Print(yellow(bold(smallArrow))) - fmt.Printf(" Ignoring package upgrade %s (%s => %s)\n", cyan(pkg.Name()), left, right) + printIgnoringPackage(pkg, "latest-commit") } else { toUpgrade = append(toUpgrade, upgrade{pkg.Name(), "devel", pkg.Version(), "latest-commit"}) } @@ -242,14 +244,16 @@ 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, warnings *aurWarnings) (upSlice, error) { +func upAUR( + remote []alpm.Package, remoteNames []string, + pkgdata map[string]*rpc.Pkg, warnings *aurWarnings) (upSlice, error) { + toUpgrade := make(upSlice, 0) _pkgdata, err := aurInfo(remoteNames, warnings) if err != nil { return nil, err } - pkgdata := make(map[string]*rpc.Pkg) for _, pkg := range _pkgdata { pkgdata[pkg.Name] = pkg } @@ -263,9 +267,7 @@ func upAUR(remote []alpm.Package, remoteNames []string, warnings *aurWarnings) ( if (config.TimeUpdate && (int64(aurPkg.LastModified) > pkg.BuildDate().Unix())) || (alpm.VerCmp(pkg.Version(), aurPkg.Version) < 0) { if pkg.ShouldIgnore() { - left, right := getVersionDiff(pkg.Version(), aurPkg.Version) - fmt.Print(yellow(bold(smallArrow))) - fmt.Printf(" Ignoring package upgrade: %s (%s => %s)\n", cyan(pkg.Name()), left, right) + printIgnoringPackage(pkg, aurPkg.Version) } else { toUpgrade = append(toUpgrade, upgrade{aurPkg.Name, "aur", pkg.Version(), aurPkg.Version}) } @@ -275,6 +277,35 @@ func upAUR(remote []alpm.Package, remoteNames []string, warnings *aurWarnings) ( return toUpgrade, nil } +func printIgnoringPackage(pkg alpm.Package, newPkgVersion string) { + left, right := getVersionDiff(pkg.Version(), newPkgVersion) + + fmt.Println( + yellow(bold(smallArrow)) + fmt.Sprintf( + " Ignoring package upgrade: %s (%s -> %s)", + cyan(pkg.Name()), left, right)) +} + +func printLocalNewerThanAUR( + remote []alpm.Package, pkgdata map[string]*rpc.Pkg) { + for _, pkg := range remote { + aurPkg, ok := pkgdata[pkg.Name()] + if !ok { + continue + } + + left, right := getVersionDiff(pkg.Version(), aurPkg.Version) + + if !isDevelName(pkg.Name()) && + alpm.VerCmp(pkg.Version(), aurPkg.Version) > 0 { + fmt.Println( + yellow(bold(smallArrow)) + fmt.Sprintf( + " Local package is newer than AUR: %s (%s -> %s)", + cyan(pkg.Name()), left, right)) + } + } +} + // upRepo gathers local packages and checks if they have new versions. // Output: Upgrade type package list. func upRepo(local []alpm.Package) (upSlice, error) { @@ -289,9 +320,7 @@ func upRepo(local []alpm.Package) (upSlice, error) { newPkg := pkg.NewVersion(dbList) if newPkg != nil { if pkg.ShouldIgnore() { - left, right := getVersionDiff(pkg.Version(), newPkg.Version()) - fmt.Print(yellow(bold(smallArrow))) - fmt.Printf(" Ignoring package upgrade: %s (%s => %s)\n", cyan(pkg.Name()), left, right) + printIgnoringPackage(pkg, newPkg.Version()) } else { slice = append(slice, upgrade{pkg.Name(), newPkg.DB().Name(), pkg.Version(), newPkg.Version()}) }