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: remove duplicate files



details:   https://anonhg.NetBSD.org/pkgsrc/rev/59249a060467
branches:  trunk
changeset: 377965:59249a060467
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sun Mar 25 07:37:39 2018 +0000

description:
pkgtools/pkglint: remove duplicate files

The definitions from globaldata.go had been moved to pkgsrc.go. Having
these definitions twice led to compile errors.

While here, the file package_test.go doesn't need to be patched anymore
since it gets its @VERSION@ from the constants defined in pkglint.go.

diffstat:

 pkgtools/pkglint/Makefile                 |    4 +-
 pkgtools/pkglint/files/globaldata.go      |  647 ------------------------------
 pkgtools/pkglint/files/globaldata_test.go |  142 ------
 3 files changed, 2 insertions(+), 791 deletions(-)

diffs (truncated from 815 to 300 lines):

diff -r 58be7780dda8 -r 59249a060467 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sun Mar 25 07:32:19 2018 +0000
+++ b/pkgtools/pkglint/Makefile Sun Mar 25 07:37:39 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.532 2018/03/24 14:32:49 rillig Exp $
+# $NetBSD: Makefile,v 1.533 2018/03/25 07:37:39 rillig Exp $
 
 PKGNAME=       pkglint-5.5.7
 DISTFILES=     # none
@@ -21,7 +21,7 @@
 
 SUBST_CLASSES+=                pkglint
 SUBST_STAGE.pkglint=   post-configure
-SUBST_FILES.pkglint+=  pkglint.go package_test.go
+SUBST_FILES.pkglint+=  pkglint.go
 SUBST_SED.pkglint+=    -e s\|@VERSION@\|${PKGNAME:S/pkglint-//}\|g
 SUBST_SED.pkglint+=    -e s\|@BMAKE@\|${MAKE:Q}\|g
 
diff -r 58be7780dda8 -r 59249a060467 pkgtools/pkglint/files/globaldata.go
--- a/pkgtools/pkglint/files/globaldata.go      Sun Mar 25 07:32:19 2018 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,647 +0,0 @@
-package main
-
-import (
-       "io/ioutil"
-       "netbsd.org/pkglint/regex"
-       "netbsd.org/pkglint/trace"
-       "path"
-       "sort"
-       "strings"
-)
-
-// GlobalData contains data describing pkgsrc as a whole.
-type GlobalData struct {
-       Pkgsrcdir           string              // Relative to the current working directory.
-       MasterSiteURLToVar  map[string]string   // "https://github.com/"; => "MASTER_SITE_GITHUB"
-       MasterSiteVarToURL  map[string]string   // "MASTER_SITE_GITHUB" => "https://github.com/";
-       PkgOptions          map[string]string   // "x11" => "Provides X11 support"
-       Tools               ToolRegistry        //
-       SystemBuildDefs     map[string]bool     // The set of user-defined variables that are added to BUILD_DEFS within the bsd.pkg.mk file.
-       suggestedUpdates    []SuggestedUpdate   //
-       suggestedWipUpdates []SuggestedUpdate   //
-       LastChange          map[string]*Change  //
-       UserDefinedVars     map[string]MkLine   // varname => line; used for checking BUILD_DEFS
-       Deprecated          map[string]string   //
-       vartypes            map[string]*Vartype // varcanon => type
-       latest              map[string]string   // "lang/php[0-9]*" => "lang/php70"
-}
-
-// Change is a change entry from the `doc/CHANGES-*` files.
-type Change struct {
-       Line    Line
-       Action  string
-       Pkgpath string
-       Version string
-       Author  string
-       Date    string
-}
-
-// SuggestedUpdate is from the `doc/TODO` file.
-type SuggestedUpdate struct {
-       Line    Line
-       Pkgname string
-       Version string
-       Comment string
-}
-
-// Initialize reads the pkgsrc infrastructure files to
-// extract information like the tools, packages to update,
-// user-defined variables.
-func (gd *GlobalData) Initialize() {
-       firstArg := G.Todo[0]
-       if fileExists(firstArg) {
-               firstArg = path.Dir(firstArg)
-       }
-       if relTopdir := findPkgsrcTopdir(firstArg); relTopdir != "" {
-               gd.Pkgsrcdir = firstArg + "/" + relTopdir
-       } else {
-               dummyLine.Fatalf("%q is not inside a pkgsrc tree.", firstArg)
-       }
-
-       gd.vartypes = make(map[string]*Vartype)
-       gd.InitVartypes()
-       gd.loadDistSites()
-       gd.loadPkgOptions()
-       gd.loadDocChanges()
-       gd.loadSuggestedUpdates()
-       gd.loadUserDefinedVars()
-       gd.loadTools()
-       gd.loadDeprecatedVars()
-}
-
-func (gd *GlobalData) Latest(category string, re regex.Pattern, repl string) string {
-       key := category + "/" + string(re) + " => " + repl
-       if latest, found := gd.latest[key]; found {
-               return latest
-       }
-
-       if gd.latest == nil {
-               gd.latest = make(map[string]string)
-       }
-
-       error := func() string {
-               dummyLine.Errorf("Cannot find latest version of %q in %q.", re, gd.Pkgsrcdir)
-               gd.latest[key] = ""
-               return ""
-       }
-
-       all, err := ioutil.ReadDir(gd.Pkgsrcdir + "/" + category)
-       if err != nil {
-               return error()
-       }
-
-       latest := ""
-       for _, fileInfo := range all {
-               if matches(fileInfo.Name(), re) {
-                       latest = regex.Compile(re).ReplaceAllString(fileInfo.Name(), repl)
-               }
-       }
-       if latest == "" {
-               return error()
-       }
-
-       gd.latest[key] = latest
-       return latest
-}
-
-func (gd *GlobalData) loadDistSites() {
-       fname := gd.Pkgsrcdir + "/mk/fetch/sites.mk"
-       lines := LoadExistingLines(fname, true)
-
-       nameToUrl := make(map[string]string)
-       urlToName := make(map[string]string)
-       for _, line := range lines {
-               if m, commented, varname, _, _, _, urls, _, _ := MatchVarassign(line.Text); m {
-                       if !commented && hasPrefix(varname, "MASTER_SITE_") && varname != "MASTER_SITE_BACKUP" {
-                               for _, url := range splitOnSpace(urls) {
-                                       if matches(url, `^(?:http://|https://|ftp://)`) {
-                                               if nameToUrl[varname] == "" {
-                                                       nameToUrl[varname] = url
-                                               }
-                                               urlToName[url] = varname
-                                       }
-                               }
-                       }
-               }
-       }
-
-       // Explicitly allowed, although not defined in mk/fetch/sites.mk.
-       nameToUrl["MASTER_SITE_LOCAL"] = "ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/LOCAL_PORTS/";
-
-       if trace.Tracing {
-               trace.Stepf("Loaded %d MASTER_SITE_* URLs.", len(urlToName))
-       }
-       gd.MasterSiteURLToVar = urlToName
-       gd.MasterSiteVarToURL = nameToUrl
-}
-
-func (gd *GlobalData) loadPkgOptions() {
-       fname := gd.Pkgsrcdir + "/mk/defaults/options.description"
-       lines := LoadExistingLines(fname, false)
-
-       gd.PkgOptions = make(map[string]string)
-       for _, line := range lines {
-               if m, optname, optdescr := match2(line.Text, `^([-0-9a-z_+]+)(?:\s+(.*))?$`); m {
-                       gd.PkgOptions[optname] = optdescr
-               } else {
-                       line.Fatalf("Unknown line format.")
-               }
-       }
-}
-
-func (gd *GlobalData) loadTools() {
-       toolFiles := []string{"defaults.mk"}
-       {
-               fname := G.globalData.Pkgsrcdir + "/mk/tools/bsd.tools.mk"
-               lines := LoadExistingLines(fname, true)
-               for _, line := range lines {
-                       if m, _, _, includefile := MatchMkInclude(line.Text); m {
-                               if !contains(includefile, "/") {
-                                       toolFiles = append(toolFiles, includefile)
-                               }
-                       }
-               }
-               if len(toolFiles) <= 1 {
-                       NewLineWhole(fname).Fatalf("Too few tool files.")
-               }
-       }
-
-       reg := NewToolRegistry()
-       reg.RegisterTool(&Tool{"echo", "ECHO", true, true, true})
-       reg.RegisterTool(&Tool{"echo -n", "ECHO_N", true, true, true})
-       reg.RegisterTool(&Tool{"false", "FALSE", true /*why?*/, true, false})
-       reg.RegisterTool(&Tool{"test", "TEST", true, true, true})
-       reg.RegisterTool(&Tool{"true", "TRUE", true /*why?*/, true, true})
-
-       systemBuildDefs := make(map[string]bool)
-
-       for _, basename := range toolFiles {
-               fname := G.globalData.Pkgsrcdir + "/mk/tools/" + basename
-               lines := LoadExistingLines(fname, true)
-               for _, line := range lines {
-                       reg.ParseToolLine(line)
-               }
-       }
-
-       for _, relativeName := range [...]string{"mk/bsd.prefs.mk", "mk/bsd.pkg.mk"} {
-               fname := G.globalData.Pkgsrcdir + "/" + relativeName
-               condDepth := 0
-
-               lines := LoadExistingLines(fname, true)
-               for _, line := range lines {
-                       text := line.Text
-                       if hasPrefix(text, "#") {
-                               continue
-                       }
-
-                       if m, _, varname, _, _, _, value, _, _ := MatchVarassign(text); m {
-                               if varname == "USE_TOOLS" {
-                                       if trace.Tracing {
-                                               trace.Stepf("[condDepth=%d] %s", condDepth, value)
-                                       }
-                                       if condDepth == 0 || condDepth == 1 && relativeName == "mk/bsd.prefs.mk" {
-                                               for _, toolname := range splitOnSpace(value) {
-                                                       if !containsVarRef(toolname) {
-                                                               for _, tool := range [...]*Tool{reg.Register(toolname), reg.Register("TOOLS_" + toolname)} {
-                                                                       tool.Predefined = true
-                                                                       if relativeName == "mk/bsd.prefs.mk" {
-                                                                               tool.UsableAtLoadtime = true
-                                                                       }
-                                                               }
-                                                       }
-                                               }
-                                       }
-
-                               } else if varname == "_BUILD_DEFS" {
-                                       for _, bdvar := range splitOnSpace(value) {
-                                               systemBuildDefs[bdvar] = true
-                                       }
-                               }
-
-                       } else if m, _, cond, _ := matchMkCond(text); m {
-                               switch cond {
-                               case "if", "ifdef", "ifndef", "for":
-                                       condDepth++
-                               case "endif", "endfor":
-                                       condDepth--
-                               }
-                       }
-               }
-       }
-
-       if trace.Tracing {
-               reg.Trace()
-       }
-       if trace.Tracing {
-               trace.Stepf("systemBuildDefs: %v", systemBuildDefs)
-       }
-
-       // Some user-defined variables do not influence the binary
-       // package at all and therefore do not have to be added to
-       // BUILD_DEFS; therefore they are marked as "already added".
-       systemBuildDefs["DISTDIR"] = true
-       systemBuildDefs["FETCH_CMD"] = true
-       systemBuildDefs["FETCH_OUTPUT_ARGS"] = true
-       systemBuildDefs["GAMES_USER"] = true
-       systemBuildDefs["GAMES_GROUP"] = true
-       systemBuildDefs["GAMEDATAMODE"] = true
-       systemBuildDefs["GAMEDIRMODE"] = true
-       systemBuildDefs["GAMEMODE"] = true
-       systemBuildDefs["GAMEOWN"] = true
-       systemBuildDefs["GAMEGRP"] = true
-
-       gd.Tools = reg
-       gd.SystemBuildDefs = systemBuildDefs
-}
-
-func loadSuggestedUpdates(fname string) []SuggestedUpdate {
-       lines := LoadExistingLines(fname, false)
-       return parselinesSuggestedUpdates(lines)
-}
-
-func parselinesSuggestedUpdates(lines []Line) []SuggestedUpdate {
-       var updates []SuggestedUpdate
-       state := 0
-       for _, line := range lines {
-               text := line.Text
-
-               if state == 0 && text == "Suggested package updates" {
-                       state = 1
-               } else if state == 1 && text == "" {
-                       state = 2
-               } else if state == 2 {
-                       state = 3
-               } else if state == 3 && text == "" {
-                       state = 4
-               }
-
-               if state == 3 {



Home | Main Index | Thread Index | Old Index