[ 
https://issues.apache.org/jira/browse/MYNEWT-860?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16223098#comment-16223098
 ] 

ASF GitHub Bot commented on MYNEWT-860:
---------------------------------------

ccollins476ad closed pull request #105: MYNEWT-860 Newt - Empty `pkg.yml` 
issues.
URL: https://github.com/apache/mynewt-newt/pull/105
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/newt/pkg/localpackage.go b/newt/pkg/localpackage.go
index 7a6beb4..7919a06 100644
--- a/newt/pkg/localpackage.go
+++ b/newt/pkg/localpackage.go
@@ -294,8 +294,7 @@ func (pkg *LocalPackage) Save() error {
        return nil
 }
 
-// Load reads everything that isn't identity specific into the
-// package
+// Load reads everything that isn't identity specific into the package
 func (pkg *LocalPackage) Load() error {
        // Load configuration
        log.Debugf("Loading configuration for package %s", pkg.basePath)
@@ -311,6 +310,11 @@ func (pkg *LocalPackage) Load() error {
 
        // Set package name from the package
        pkg.name = pkg.PkgV.GetString("pkg.name")
+       if pkg.name == "" {
+               return util.FmtNewtError(
+                       "Package \"%s\" missing \"pkg.name\" field in its 
`pkg.yml` file",
+                       pkg.basePath)
+       }
 
        typeString := pkg.PkgV.GetString("pkg.type")
        pkg.packageType = PACKAGE_TYPE_LIB
@@ -387,6 +391,11 @@ func (pkg *LocalPackage) Clone(newRepo *repo.Repo,
 func LoadLocalPackage(repo *repo.Repo, pkgDir string) (*LocalPackage, error) {
        pkg := NewLocalPackage(repo, pkgDir)
        err := pkg.Load()
+       if err != nil {
+               err = util.FmtNewtError("%s; ignoring package.", err.Error())
+               return nil, err
+       }
+
        return pkg, err
 }
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Newt - Empty `pkg.yml` file causes target to be built as split image
> --------------------------------------------------------------------
>
>                 Key: MYNEWT-860
>                 URL: https://issues.apache.org/jira/browse/MYNEWT-860
>             Project: Mynewt
>          Issue Type: Bug
>      Security Level: Public(Viewable by anyone) 
>          Components: Newt
>            Reporter: Christopher Collins
>            Assignee: Christopher Collins
>
> (Pull request: https://github.com/apache/mynewt-newt/pull/105)
> 1. Create a directory in your project:
> {noformat}
> mkdir blah
> {noformat}
> 2. Create an empty {{pkg.yml}} file in the directory:
> {noformat}
> touch blah/pkg.yml
> {noformat}
> 3. Build a non-split-image target.
> Newt will compile everything twice, as if it were building a split image.  
> Then it will fail in an unpredictable way, e.g.:
> {noformat}
> Error: In file included from apps/krang/src/main.c:23:0:
> repos/apache-mynewt-core/sys/sysinit/include/sysinit/sysinit.h:28:25: fatal 
> error: split/split.h: No such file or directory
>  #include "split/split.h"
> {noformat}
> {noformat}
> panic: runtime error: invalid memory address or nil pointer dereference
> [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x12a71d4]
> goroutine 1 [running]:
> mynewt.apache.org/newt/newt/pkg.(*LocalPackage).Name(...)
>         
> /Users/ccollins/go/src/mynewt.apache.org/newt/newt/builder/paths.go:179
> mynewt.apache.org/newt/newt/builder.(*Builder).TestExePath(0xc4205307e0, 0x0, 
> 0x0)
>         
> /Users/ccollins/go/src/mynewt.apache.org/newt/newt/builder/paths.go:179 +0x34
> mynewt.apache.org/newt/newt/builder.(*Builder).CompileCmdsPath(0xc4205307e0, 
> 0xc420308920, 0x0)
>         
> /Users/ccollins/go/src/mynewt.apache.org/newt/newt/builder/paths.go:198 +0xad
> mynewt.apache.org/newt/newt/builder.(*Builder).Build(0xc4205307e0, 0x0, 0x0)
>         
> /Users/ccollins/go/src/mynewt.apache.org/newt/newt/builder/build.go:601 +0xa20
> mynewt.apache.org/newt/newt/builder.(*TargetBuilder).buildLoader(0xc420518120,
>  0x0, 0x0)
>         
> /Users/ccollins/go/src/mynewt.apache.org/newt/newt/builder/targetbuild.go:319 
> +0xc6
> mynewt.apache.org/newt/newt/builder.(*TargetBuilder).Build(0xc420518120, 
> 0xc420518120, 0x0)
>         
> /Users/ccollins/go/src/mynewt.apache.org/newt/newt/builder/targetbuild.go:372 
> +0x16d
> mynewt.apache.org/newt/newt/cli.buildRunCmd(0xc420090b40, 0xc420048d50, 0x1, 
> 0x1, 0x0)
>         
> /Users/ccollins/go/src/mynewt.apache.org/newt/newt/cli/build_cmds.go:160 
> +0x2c9
> mynewt.apache.org/newt/newt/cli.AddBuildCommands.func1(0xc420090b40, 
> 0xc420048d50, 0x1, 0x1)
>         
> /Users/ccollins/go/src/mynewt.apache.org/newt/newt/cli/build_cmds.go:404 +0x5f
> mynewt.apache.org/newt/newt/vendor/github.com/spf13/cobra.(*Command).execute(0xc420090b40,
>  0xc420048d10, 0x1, 0x1, 0xc420090b40, 0xc420048d10)
>         
> /Users/ccollins/go/src/mynewt.apache.org/newt/newt/vendor/github.com/spf13/cobra/command.go:636
>  +0x234
> mynewt.apache.org/newt/newt/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc4200906c0,
>  0x5, 0x25, 0x1399e93)
>         
> /Users/ccollins/go/src/mynewt.apache.org/newt/newt/vendor/github.com/spf13/cobra/command.go:722
>  +0x2fe
> mynewt.apache.org/newt/newt/vendor/github.com/spf13/cobra.(*Command).Execute(0xc4200906c0,
>  0x1399e93, 0x5)
>         
> /Users/ccollins/go/src/mynewt.apache.org/newt/newt/vendor/github.com/spf13/cobra/command.go:681
>  +0x2b
> main.main()
>         /Users/ccollins/go/src/mynewt.apache.org/newt/newt/newt.go:170 +0x1ac
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to