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 2019/01/04 18:21:18 UTC
[mynewt-newt] 13/17: newt - Use latest artifact library
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 22ef74cc1f16af8f7d9c6a0dc4fdb1d4ec700c90
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Tue Dec 18 18:20:31 2018 -0800
newt - Use latest artifact library
---
newt/mfg/emit.go | 20 +++++++++-----------
newt/mfg/paths.go | 2 +-
util/util.go | 8 ++++++++
3 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/newt/mfg/emit.go b/newt/mfg/emit.go
index b977fe7..9eb8cf3 100644
--- a/newt/mfg/emit.go
+++ b/newt/mfg/emit.go
@@ -20,7 +20,6 @@
package mfg
import (
- "fmt"
"io/ioutil"
"os"
"path/filepath"
@@ -30,6 +29,7 @@ import (
"mynewt.apache.org/newt/artifact/image"
"mynewt.apache.org/newt/artifact/manifest"
"mynewt.apache.org/newt/artifact/mfg"
+ "mynewt.apache.org/newt/artifact/misc"
"mynewt.apache.org/newt/newt/builder"
"mynewt.apache.org/newt/newt/flashmap"
"mynewt.apache.org/newt/newt/target"
@@ -234,22 +234,16 @@ func copyBinFiles(entries []CpEntry) error {
// emitManifest generates an mfg manifest.
func (me *MfgEmitter) emitManifest() ([]byte, error) {
- hashBytes := me.Mfg.Meta.Hash()
- if hashBytes == nil {
- // No hash TLV; calculate hash manually.
- bin, err := me.Mfg.Bytes(0xff)
- if err != nil {
- return nil, err
- }
- hashBytes = mfg.CalcHash(bin)
+ hashBytes, err := me.Mfg.Hash()
+ if err != nil {
+ return nil, err
}
- hashStr := fmt.Sprintf("%x", hashBytes)
mm := manifest.MfgManifest{
Name: me.Name,
BuildTime: time.Now().Format(time.RFC3339),
Format: MANIFEST_FORMAT,
- MfgHash: hashStr,
+ MfgHash: misc.HashString(hashBytes),
Version: me.Ver.String(),
Device: me.Device,
BinPath: mfg.MFG_IMG_FILENAME,
@@ -297,6 +291,10 @@ func (me *MfgEmitter) emitManifest() ([]byte, error) {
// @return [source-paths], [dest-paths], error
func (me *MfgEmitter) Emit() ([]string, []string, error) {
+ if err := me.Mfg.RecalcHash(0xff); err != nil {
+ return nil, nil, err
+ }
+
mbin, err := me.Mfg.Bytes(0xff)
if err != nil {
return nil, nil, err
diff --git a/newt/mfg/paths.go b/newt/mfg/paths.go
index 3b3e1f6..8c70b94 100644
--- a/newt/mfg/paths.go
+++ b/newt/mfg/paths.go
@@ -38,7 +38,7 @@ func MfgBinPath(mfgPkgName string) string {
}
func MfgManifestPath(mfgPkgName string) string {
- return MfgBinDir(mfgPkgName) + "/" + mfg.MFG_MANIFEST_FILENAME
+ return MfgBinDir(mfgPkgName) + "/" + mfg.MANIFEST_FILENAME
}
func MfgTargetDir(targetNum int) string {
diff --git a/util/util.go b/util/util.go
index fa9098b..b1d7973 100644
--- a/util/util.go
+++ b/util/util.go
@@ -103,6 +103,14 @@ func ChildNewtError(parent error) *NewtError {
return newtErr
}
+func FmtChildNewtError(parent error, format string,
+ args ...interface{}) *NewtError {
+
+ ne := ChildNewtError(parent)
+ ne.Text = fmt.Sprintf(format, args...)
+ return ne
+}
+
// Print Silent, Quiet and Verbose aware status messages to stdout.
func WriteMessage(f *os.File, level int, message string,
args ...interface{}) {