You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2020/01/28 17:26:04 UTC

[mynewt-newt] branch master updated (e33ba77 -> 2c4af9d)

This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git.


    from e33ba77  Fix clone of repos for non-[install|upgrade] cmds
     new f8d0ab7  Remove unused function (LocalPackage*).Hash
     new 40575dc  repo: Remove logically dead code
     new afea2f3  repo: Ensure cast of `vers` map succeeds
     new cf66769  toolchain: Check for error when deleting .a file
     new 7bb99e8  config: Handle case where config tree lacks a root
     new 2278c30  toolchain: Return nil if no error
     new d1dcc19  install: Don't dereference nil pointer
     new b49bb52  manifest: Remove duplicate if / else branch
     new 2c4af9d  mfg: Clarify error message

The 9 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 newt/config/tree.go        |  5 +++++
 newt/install/install.go    | 26 ++++++++++++++------------
 newt/manifest/manifest.go  | 10 ++--------
 newt/mfg/build.go          |  3 ++-
 newt/pkg/localpackage.go   | 34 ----------------------------------
 newt/repo/repo.go          |  7 ++-----
 newt/toolchain/compiler.go |  9 ++++-----
 7 files changed, 29 insertions(+), 65 deletions(-)


[mynewt-newt] 05/09: config: Handle case where config tree lacks a root

Posted by cc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit 7bb99e866462ef485e1e659c9534fb9de5416d1b
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Mon Jan 27 11:03:03 2020 -0800

    config: Handle case where config tree lacks a root
---
 newt/config/tree.go | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/newt/config/tree.go b/newt/config/tree.go
index d7e3dc8..7750cb6 100644
--- a/newt/config/tree.go
+++ b/newt/config/tree.go
@@ -87,6 +87,11 @@ func BuildTree(entries []FileEntry) (*Node, error) {
 		}
 	}
 
+	if root == nil {
+		return nil, util.FmtNewtError(
+			"failed to build a config tree: no root file")
+	}
+
 	SortTree(root)
 	return root, nil
 }


[mynewt-newt] 03/09: repo: Ensure cast of `vers` map succeeds

Posted by cc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit afea2f3aff9ef16fd4c5fcb67f2cae508b721e70
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Mon Jan 27 10:53:02 2020 -0800

    repo: Ensure cast of `vers` map succeeds
    
    The code was checking the wrong variable to determine success (`ok`
    instead of `err`).
---
 newt/repo/repo.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/newt/repo/repo.go b/newt/repo/repo.go
index 14bfc89..d316b67 100644
--- a/newt/repo/repo.go
+++ b/newt/repo/repo.go
@@ -417,8 +417,8 @@ func parseRepoDepMap(depName string,
 	}
 
 	versMap, err := cast.ToStringMapStringE(versYml)
-	if !ok {
-		return nil, util.FmtNewtError("invalid \"vers\" map")
+	if err != nil {
+		return nil, util.FmtNewtError("invalid \"vers\" map: %v", err)
 	}
 
 	fields := map[string]string{}


[mynewt-newt] 01/09: Remove unused function (LocalPackage*).Hash

Posted by cc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit f8d0ab7885414bb94d9d5177c57d6ff3dbeacc32
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Mon Jan 27 10:42:53 2020 -0800

    Remove unused function (LocalPackage*).Hash
---
 newt/pkg/localpackage.go | 34 ----------------------------------
 1 file changed, 34 deletions(-)

diff --git a/newt/pkg/localpackage.go b/newt/pkg/localpackage.go
index 47a52a4..9db822f 100644
--- a/newt/pkg/localpackage.go
+++ b/newt/pkg/localpackage.go
@@ -21,9 +21,7 @@ package pkg
 
 import (
 	"bytes"
-	"crypto/sha1"
 	"fmt"
-	"io/ioutil"
 	"os"
 	"path/filepath"
 	"strings"
@@ -157,38 +155,6 @@ func (pkg *LocalPackage) SetRepo(r *repo.Repo) {
 	pkg.repo = r
 }
 
-func (pkg *LocalPackage) Hash() (string, error) {
-	hash := sha1.New()
-
-	err := filepath.Walk(pkg.basePath,
-		func(path string, info os.FileInfo, err error) error {
-			name := info.Name()
-			if PackageHashIgnoreDirs[name] {
-				return filepath.SkipDir
-			}
-
-			if info.IsDir() {
-				// SHA the directory name into the hash
-				hash.Write([]byte(name))
-			} else {
-				// SHA the file name & contents into the hash
-				contents, err := ioutil.ReadFile(path)
-				if err != nil {
-					return err
-				}
-				hash.Write(contents)
-			}
-			return nil
-		})
-	if err != nil && err != filepath.SkipDir {
-		return "", util.NewNewtError(err.Error())
-	}
-
-	hashStr := fmt.Sprintf("%x", hash.Sum(nil))
-
-	return hashStr, nil
-}
-
 func (pkg *LocalPackage) CfgFilenames() []string {
 	return pkg.cfgFilenames
 }


[mynewt-newt] 04/09: toolchain: Check for error when deleting .a file

Posted by cc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit cf66769bc901e79c93ea2bc88e822f76f0f9577f
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Mon Jan 27 10:56:22 2020 -0800

    toolchain: Check for error when deleting .a file
    
    The code was checking the `err` variable without assigning it.  As a
    result, it was checking for an error from a prior operation (which was
    already being checked).
---
 newt/toolchain/compiler.go | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/newt/toolchain/compiler.go b/newt/toolchain/compiler.go
index a1851e5..05dc424 100644
--- a/newt/toolchain/compiler.go
+++ b/newt/toolchain/compiler.go
@@ -1246,15 +1246,14 @@ func (c *Compiler) CompileArchive(archiveFile string) error {
 		return nil
 	}
 
-	// Delete the old archive, if it exists.
-	os.Remove(archiveFile)
-
 	util.StatusMessage(util.VERBOSITY_DEFAULT, "Archiving %s",
 		path.Base(archiveFile))
 	util.StatusMessage(util.VERBOSITY_VERBOSE, " with object files %s",
 		strings.Join(objList, " "))
 	util.StatusMessage(util.VERBOSITY_DEFAULT, "\n")
 
+	// Delete the old archive, if it exists.
+	err = os.Remove(archiveFile)
 	if err != nil && !os.IsNotExist(err) {
 		return util.NewNewtError(err.Error())
 	}


[mynewt-newt] 02/09: repo: Remove logically dead code

Posted by cc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit 40575dcd481d261b33b1b91fb24497b69b5d9259
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Mon Jan 27 10:47:23 2020 -0800

    repo: Remove logically dead code
    
    The code was comparing `err` a second time.
---
 newt/repo/repo.go | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/newt/repo/repo.go b/newt/repo/repo.go
index 17d9e60..14bfc89 100644
--- a/newt/repo/repo.go
+++ b/newt/repo/repo.go
@@ -134,9 +134,6 @@ func (repo *Repo) FilteredSearchList(
 		}
 
 		name := entry.Name()
-		if err != nil {
-			continue
-		}
 
 		if !entry.IsDir() {
 			continue


[mynewt-newt] 09/09: mfg: Clarify error message

Posted by cc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit 2c4af9d3c283853810ce71acbc2719c6c071e660
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Mon Jan 27 11:40:40 2020 -0800

    mfg: Clarify error message
---
 newt/mfg/build.go | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/newt/mfg/build.go b/newt/mfg/build.go
index 7f76447..bf23219 100644
--- a/newt/mfg/build.go
+++ b/newt/mfg/build.go
@@ -155,7 +155,8 @@ func calcBsp(dm DecodedMfg,
 	}
 
 	if len(bspMap) == 0 {
-		return nil, util.FmtNewtError("at least one target required")
+		return nil, util.FmtNewtError(
+			"failed to determine BSP: no targets and no \"bsp\" field")
 	}
 
 	if len(bspMap) > 1 {


[mynewt-newt] 08/09: manifest: Remove duplicate if / else branch

Posted by cc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit b49bb52015a1f753d47e97fb64ba34558225c7d9
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Mon Jan 27 11:31:18 2020 -0800

    manifest: Remove duplicate if / else branch
---
 newt/manifest/manifest.go | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/newt/manifest/manifest.go b/newt/manifest/manifest.go
index adb1299..cb1c285 100644
--- a/newt/manifest/manifest.go
+++ b/newt/manifest/manifest.go
@@ -133,14 +133,8 @@ func (r *RepoManager) GetManifestPkg(
 		Name: lpkg.FullName(),
 	}
 
-	var path string
-	if lpkg.Repo().IsLocal() {
-		ip.Repo = lpkg.Repo().Name()
-		path = lpkg.BasePath()
-	} else {
-		ip.Repo = lpkg.Repo().Name()
-		path = lpkg.BasePath()
-	}
+	ip.Repo = lpkg.Repo().Name()
+	path := lpkg.BasePath()
 
 	if _, present := r.repos[ip.Repo]; present {
 		return ip


[mynewt-newt] 06/09: toolchain: Return nil if no error

Posted by cc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit 2278c30c3e22d378d3b4e7b8595c2d413bf73fe7
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Mon Jan 27 11:08:57 2020 -0800

    toolchain: Return nil if no error
    
    The code already handles the `err != nil` case.  If the code gets past
    that check, we can assume that `err == nil`.
---
 newt/toolchain/compiler.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/newt/toolchain/compiler.go b/newt/toolchain/compiler.go
index 05dc424..cf0531a 100644
--- a/newt/toolchain/compiler.go
+++ b/newt/toolchain/compiler.go
@@ -1363,7 +1363,7 @@ func (c *Compiler) ParseLibrary(libraryFile string) (error, []byte) {
 	if err != nil {
 		return err, nil
 	}
-	return err, out
+	return nil, out
 }
 
 func (c *Compiler) CopySymbols(infile string, outfile string, sm *symbol.SymbolMap) error {
@@ -1373,7 +1373,7 @@ func (c *Compiler) CopySymbols(infile string, outfile string, sm *symbol.SymbolM
 	if err != nil {
 		return err
 	}
-	return err
+	return nil
 }
 
 func (c *Compiler) ConvertBinToHex(inFile string, outFile string, baseAddr int) error {


[mynewt-newt] 07/09: install: Don't dereference nil pointer

Posted by cc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit d1dcc192da7a6db6d8cf65a44994296c2f32f920
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Mon Jan 27 11:29:16 2020 -0800

    install: Don't dereference nil pointer
    
    The code was dereferencing `curVer` without checking if it was nil.
---
 newt/install/install.go | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/newt/install/install.go b/newt/install/install.go
index 9085f28..5bc5f0c 100644
--- a/newt/install/install.go
+++ b/newt/install/install.go
@@ -344,21 +344,23 @@ func (inst *Installer) installPrompt(vm deprepo.VersionMap, op installOp,
 	for _, name := range names {
 		r := inst.repos[name]
 		curVer := inst.installedVer(name)
-		if curVer != nil && curVer.Commit != "" {
-			c, err := r.CurrentHash()
-			if err == nil {
-				curVer.Commit = c
+		if curVer != nil {
+			if curVer.Commit != "" {
+				c, err := r.CurrentHash()
+				if err == nil {
+					curVer.Commit = c
+				}
 			}
-		}
-		destVer := vm[name]
+			destVer := vm[name]
 
-		msg, err := inst.installMessageOneRepo(
-			r, op, force, curVer, destVer)
-		if err != nil {
-			return false, err
-		}
+			msg, err := inst.installMessageOneRepo(
+				r, op, force, curVer, destVer)
+			if err != nil {
+				return false, err
+			}
 
-		util.StatusMessage(util.VERBOSITY_DEFAULT, "%s\n", msg)
+			util.StatusMessage(util.VERBOSITY_DEFAULT, "%s\n", msg)
+		}
 	}
 
 	if !ask {