pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint pkgtools/pkglint: update to 20.3.2



details:   https://anonhg.NetBSD.org/pkgsrc/rev/a16c921e621c
branches:  trunk
changeset: 441127:a16c921e621c
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Mon Oct 26 22:13:23 2020 +0000

description:
pkgtools/pkglint: update to 20.3.2

Changes since 20.3.1:

The available Java versions are parsed from mk/java-vm.mk instead of
hard-coding them in pkglint.

diffstat:

 pkgtools/pkglint/Makefile         |   5 +--
 pkgtools/pkglint/files/vardefs.go |  48 ++++++++++++++++++++++++++++++++++++++-
 2 files changed, 49 insertions(+), 4 deletions(-)

diffs (85 lines):

diff -r 71b3d1b12cfa -r a16c921e621c pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Mon Oct 26 21:20:59 2020 +0000
+++ b/pkgtools/pkglint/Makefile Mon Oct 26 22:13:23 2020 +0000
@@ -1,7 +1,6 @@
-# $NetBSD: Makefile,v 1.672 2020/10/15 13:08:28 bsiegert Exp $
+# $NetBSD: Makefile,v 1.673 2020/10/26 22:13:23 rillig Exp $
 
-PKGNAME=       pkglint-20.3.1
-PKGREVISION=   1
+PKGNAME=       pkglint-20.3.2
 CATEGORIES=    pkgtools
 DISTNAME=      tools
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=golang/}
diff -r 71b3d1b12cfa -r a16c921e621c pkgtools/pkglint/files/vardefs.go
--- a/pkgtools/pkglint/files/vardefs.go Mon Oct 26 21:20:59 2020 +0000
+++ b/pkgtools/pkglint/files/vardefs.go Mon Oct 26 22:13:23 2020 +0000
@@ -370,6 +370,48 @@
        return enum(defval)
 }
 
+// enumFromVarnames parses the variable assignments from the given file and
+// extracts group 1 from each pattern. These groups form the allowed enum
+// values.
+func (reg *VarTypeRegistry) enumFromVarnames(
+       src *Pkgsrc, filename PkgsrcPath, defval string,
+       patterns ...regex.Pattern) *BasicType {
+
+       mklines := src.LoadMkExisting(filename)
+       if mklines == nil {
+               return enum(defval)
+       }
+
+       values := make(map[string]bool)
+       for _, mkline := range mklines.mklines {
+               if !mkline.IsVarassign() {
+                       continue
+               }
+
+               varname := mkline.Varname()
+               for _, pattern := range patterns {
+                       m, value := match1(varname, pattern)
+                       if m && !contains(value, "$") {
+                               values[intern(value)] = true
+                       }
+               }
+       }
+
+       if len(values) > 0 {
+               joined := keysJoined(values)
+               if trace.Tracing {
+                       trace.Stepf("Enum from %s with values: %s", filename, joined)
+               }
+               return enum(joined)
+       }
+
+       G.Logger.TechFatalf(
+               mklines.lines.Filename,
+               "Must contain at least 1 variable definition for %s.",
+               string(patterns[0]))
+       return nil // unreachable
+}
+
 // enumFromDirs reads the package directories from category, takes all
 // that have a single number in them (such as php72) and ranks them
 // from earliest to latest.
@@ -522,6 +564,10 @@
                "mk/java-vm.mk",
                "openjdk8 oracle-jdk8 openjdk7 sun-jdk7 jdk16 jdk15 kaffe",
                "_PKG_JVMS.*")
+       javaVersions := reg.enumFromVarnames(src,
+               "mk/java-vm.mk",
+               "yes 8 9",
+               `^_PKG_JVMS\.(.*)$`)
 
        operatingSystems := reg.enumFromFiles(src,
                "mk/platform",
@@ -1726,7 +1772,7 @@
        reg.pkgload("USE_GNU_ICONV", BtYes)
        reg.pkg("USE_IMAKE", BtYes)
        reg.pkg("USE_JAVA", enum("run yes build"))
-       reg.pkg("USE_JAVA2", enum("YES yes no 1.4 1.5 6 7 8"))
+       reg.pkg("USE_JAVA2", javaVersions)
        reg.pkglist("USE_LANGUAGES", reg.compilerLanguages(src))
        reg.pkg("USE_LIBTOOL", BtYes)
        reg.pkg("USE_MAKEINFO", BtYes)



Home | Main Index | Thread Index | Old Index