From 3dc5238bd25498d43b437c6d104a786fcbadf994 Mon Sep 17 00:00:00 2001 From: Jguer Date: Mon, 14 May 2018 22:22:47 +0100 Subject: [PATCH] Implement new gopkgbuild Newer method Signed-off-by: Jguer --- Gopkg.lock | 4 +-- install.go | 7 ++--- .../mikkeloscar/gopkgbuild/pkgbuild.go | 2 +- .../mikkeloscar/gopkgbuild/version.go | 27 +++++-------------- 4 files changed, 13 insertions(+), 27 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 158a2189..5d78eeac 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -5,7 +5,7 @@ branch = "master" name = "github.com/jguer/go-alpm" packages = ["."] - revision = "11d6aadda57c8fb4f93969333cb990677d28d4f9" + revision = "6150b61c07385c54c6dd8087b9be05cf8b064424" [[projects]] branch = "master" @@ -17,7 +17,7 @@ branch = "master" name = "github.com/mikkeloscar/gopkgbuild" packages = ["."] - revision = "32274fc52aa8f5eb28711da734179e9aea27b31f" + revision = "7b0e7c63b22efc73e1c10e6f3117fdc03cd21816" [solve-meta] analyzer-name = "dep" diff --git a/install.go b/install.go index e5225059..3806aada 100644 --- a/install.go +++ b/install.go @@ -546,9 +546,10 @@ func downloadPkgBuilds(pkgs []*rpc.Pkg, targets stringSet, bases map[string][]*r pkgbuild, err := gopkg.ParseSRCINFO(dir) if err == nil { - version, err := gopkg.NewCompleteVersion(pkg.Version) - if err == nil { - if !version.Newer(pkgbuild.Version()) { + versionRPC, errR := gopkg.NewCompleteVersion(pkg.Version) + versionPKG, errP := gopkg.NewCompleteVersion(pkgbuild.Version()) + if errP == nil && errR == nil { + if !versionRPC.Newer(versionPKG) { str := bold(cyan("::") + " PKGBUILD up to date, Skipping (%d/%d): %s\n") fmt.Printf(str, k+1, len(pkgs), cyan(formatPkgbase(pkg, bases))) continue 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 diff --git a/vendor/github.com/mikkeloscar/gopkgbuild/version.go b/vendor/github.com/mikkeloscar/gopkgbuild/version.go index cae63a87..1695377d 100644 --- a/vendor/github.com/mikkeloscar/gopkgbuild/version.go +++ b/vendor/github.com/mikkeloscar/gopkgbuild/version.go @@ -74,33 +74,18 @@ func NewCompleteVersion(s string) (*CompleteVersion, error) { return nil, fmt.Errorf("invalid version format: %s", s) } -// Older returns true if a is older than the argument version string -func (a *CompleteVersion) Older(v string) bool { - b, err := NewCompleteVersion(v) - if err != nil { - return false - } - +// Older returns true if a is older than the argument version +func (a *CompleteVersion) Older(b *CompleteVersion) bool { return a.cmp(b) == -1 } -// Newer returns true if a is newer than the argument version string -func (a *CompleteVersion) Newer(v string) bool { - b, err := NewCompleteVersion(v) - if err != nil { - return false - } - +// Newer returns true if a is newer than the argument version +func (a *CompleteVersion) Newer(b *CompleteVersion) bool { return a.cmp(b) == 1 } -// Equal returns true if a is equal to the argument version string -func (a *CompleteVersion) Equal(v string) bool { - b, err := NewCompleteVersion(v) - if err != nil { - return false - } - +// Equal returns true if a is equal to the argument version +func (a *CompleteVersion) Equal(b *CompleteVersion) bool { return a.cmp(b) == 0 }