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 2017/05/18 23:00:52 UTC
[1/2] incubator-mynewt-newt git commit: MYNEWT-583;
newt - allow use of specific tag/repository revision.
Repository: incubator-mynewt-newt
Updated Branches:
refs/heads/master da27d98ee -> 24a7b8beb
MYNEWT-583; newt - allow use of specific tag/repository revision.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/26b618f3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/26b618f3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/26b618f3
Branch: refs/heads/master
Commit: 26b618f3df44c01a721ec59df3120f1ed758e06e
Parents: da27d98
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Mar 23 20:29:52 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon May 15 13:26:36 2017 -0700
----------------------------------------------------------------------
newt/interfaces/interfaces.go | 1 +
newt/project/projectstate.go | 7 +++-
newt/repo/repo.go | 85 ++++++++++++++++++++++++++++++++++++--
newt/repo/version.go | 31 +++++++++++++-
4 files changed, 119 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/26b618f3/newt/interfaces/interfaces.go
----------------------------------------------------------------------
diff --git a/newt/interfaces/interfaces.go b/newt/interfaces/interfaces.go
index c12b58b..12826d0 100644
--- a/newt/interfaces/interfaces.go
+++ b/newt/interfaces/interfaces.go
@@ -48,6 +48,7 @@ type VersionInterface interface {
Minor() int64
Revision() int64
Stability() string
+ Tag() string
String() string
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/26b618f3/newt/project/projectstate.go
----------------------------------------------------------------------
diff --git a/newt/project/projectstate.go b/newt/project/projectstate.go
index 2c14359..0e0cc3b 100644
--- a/newt/project/projectstate.go
+++ b/newt/project/projectstate.go
@@ -57,7 +57,12 @@ func (ps *ProjectState) Save() error {
defer file.Close()
for k, v := range ps.installedRepos {
- str := fmt.Sprintf("%s,%d.%d.%d\n", k, v.Major(), v.Minor(), v.Revision())
+ str := ""
+ if v.Tag() == "" {
+ str = fmt.Sprintf("%s,%d.%d.%d\n", k, v.Major(), v.Minor(), v.Revision())
+ } else {
+ str = fmt.Sprintf("%s,%s-tag\n", k, v.Tag())
+ }
file.WriteString(str)
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/26b618f3/newt/repo/repo.go
----------------------------------------------------------------------
diff --git a/newt/repo/repo.go b/newt/repo/repo.go
index e058466..3a6e1de 100644
--- a/newt/repo/repo.go
+++ b/newt/repo/repo.go
@@ -20,10 +20,12 @@
package repo
import (
+ "bufio"
"fmt"
"io/ioutil"
"os"
"path/filepath"
+ "strconv"
"strings"
"time"
@@ -68,6 +70,20 @@ type RepoDependency struct {
Storerepo *Repo
}
+func (rd *RepoDependency) String() string {
+ rstr := "<"
+
+ for idx, vr := range rd.versreq {
+ if idx != 0 {
+ rstr = rstr + " " + vr.Version().String()
+ } else {
+ rstr = rstr + vr.Version().String()
+ }
+ }
+ rstr = rstr + ">"
+ return rstr
+}
+
func (r *Repo) Deps() []*RepoDependency {
return r.deps
}
@@ -157,6 +173,32 @@ func NewRepoDependency(rname string, verstr string) (*RepoDependency, error) {
return rd, nil
}
+func pickVersion(repo *Repo, versions []*Version) ([]*Version, error) {
+ fmt.Printf("Dependency list for %s contains a specific commit tag, " +
+ "so normal version number/stability comparison cannot be done.\n",
+ repo.Name())
+ fmt.Printf("If the following list does not contain the requirement to use, "+
+ "then modify your project.yml so that it does.\n")
+ for {
+ for i, vers := range versions {
+ fmt.Printf(" %d) %s\n", i, vers)
+ }
+ fmt.Printf("Pick the index of a version to use from above list: ")
+ line, _, err := bufio.NewReader(os.Stdin).ReadLine()
+ if err != nil {
+ return nil, util.NewNewtError(fmt.Sprintf("Couldn't read "+
+ "response: %s", err.Error()))
+ }
+ idx, err := strconv.ParseUint(string(line), 10, 8)
+ if err != nil {
+ fmt.Printf("Error: could not parse the response.\n")
+ } else {
+ repo.versreq, err = LoadVersionMatches(versions[idx].String())
+ return []*Version{versions[idx]}, nil
+ }
+ }
+}
+
func CheckDeps(upgrade bool, checkRepos map[string]*Repo) error {
// For each dependency, get it's version
depArray := map[string][]*Version{}
@@ -181,6 +223,27 @@ func CheckDeps(upgrade bool, checkRepos map[string]*Repo) error {
}
for repoName, depVersList := range depArray {
+ if len(depVersList) <= 1 {
+ continue
+ }
+
+ pickVer := false
+ for _, depVers := range depVersList {
+ if depVers.Tag() != "" {
+ pickVer = true
+ break
+ }
+ }
+ if pickVer {
+ newArray, err := pickVersion(checkRepos[repoName],
+ depArray[repoName])
+ depArray[repoName] = newArray
+ if err != nil {
+ return err
+ }
+ }
+ }
+ for repoName, depVersList := range depArray {
for _, depVers := range depVersList {
for _, curVers := range depVersList {
if depVers.CompareVersions(depVers, curVers) != 0 ||
@@ -208,8 +271,9 @@ func (rd *RepoDesc) MatchVersion(searchVers *Version) (string, *Version, bool) {
}
func (rd *RepoDesc) Match(r *Repo) (string, *Version, bool) {
+ log.Debugf("Requires repository version %s for %s\n", r.VersionRequirements(),
+ r.Name())
for vers, branch := range rd.vers {
- log.Debugf("Repository version requires for %s are %s\n", r.Name(), r.VersionRequirements())
if vers.SatisfiesVersion(r.VersionRequirements()) {
log.Debugf("Found matching version %s for repo %s",
vers.String(), r.Name())
@@ -234,9 +298,24 @@ func (rd *RepoDesc) Match(r *Repo) (string, *Version, bool) {
}
return branch, vers, true
+ } else {
+ log.Debugf("Rejected version %s for repo %s",
+ vers.String(), r.Name())
}
}
+ /*
+ * No match so far. See if requirements have a repository tag directly.
+ * If so, then return that as the branch.
+ */
+ for _, versreq := range r.VersionRequirements() {
+ tag := versreq.Version().Tag()
+ if tag != "" {
+ log.Debugf("Requirements for %s have a tag option %s\n",
+ r.Name(), tag)
+ return tag, NewTag(tag), true
+ }
+ }
return "", nil, false
}
@@ -442,8 +521,8 @@ func (r *Repo) Install(force bool) (*Version, error) {
branchName, vers, found := r.rdesc.Match(r)
if !found {
- return nil, util.NewNewtError(fmt.Sprintf("No repository matching description %s found",
- r.rdesc.String()))
+ return nil, util.NewNewtError(fmt.Sprintf("No repository " +
+ "matching description %s found", r.rdesc.String()))
}
// if the repo is already cloned, try to cleanup and checkout the requested branch
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/26b618f3/newt/repo/version.go
----------------------------------------------------------------------
diff --git a/newt/repo/version.go b/newt/repo/version.go
index bbf5b56..f09d38c 100644
--- a/newt/repo/version.go
+++ b/newt/repo/version.go
@@ -28,6 +28,8 @@ import (
"mynewt.apache.org/newt/newt/interfaces"
"mynewt.apache.org/newt/newt/newtutil"
"mynewt.apache.org/newt/util"
+
+ log "github.com/Sirupsen/logrus"
)
const VERSION_FORMAT = "%d.%d.%d-%s"
@@ -37,6 +39,7 @@ const (
VERSION_STABILITY_STABLE = "stable"
VERSION_STABILITY_DEV = "dev"
VERSION_STABILITY_LATEST = "latest"
+ VERSION_STABILITY_TAG = "tag"
)
type VersionMatch struct {
@@ -49,6 +52,7 @@ type Version struct {
minor int64
revision int64
stability string
+ tag string
}
func (vm *VersionMatch) CompareType() string {
@@ -79,6 +83,10 @@ func (v *Version) Stability() string {
return v.stability
}
+func (v *Version) Tag() string {
+ return v.tag
+}
+
func (v *Version) CompareVersions(vers1 interfaces.VersionInterface,
vers2 interfaces.VersionInterface) int64 {
if r := vers1.Major() - vers2.Major(); r != 0 {
@@ -93,6 +101,10 @@ func (v *Version) CompareVersions(vers1 interfaces.VersionInterface,
return r
}
+ if vers1.Tag() != vers2.Tag() {
+ return 1
+ }
+
return 0
}
@@ -102,6 +114,10 @@ func (v *Version) SatisfiesVersion(versMatches []interfaces.VersionReqInterface)
}
for _, match := range versMatches {
+ if match.Version().Tag() != "" && match.CompareType() != "==" {
+ log.Warningf("Version comparison with a tag %s %s %s",
+ match.Version(), match.CompareType(), v)
+ }
r := v.CompareVersions(match.Version(), v)
switch match.CompareType() {
case "<":
@@ -135,6 +151,9 @@ func (v *Version) SatisfiesVersion(versMatches []interfaces.VersionReqInterface)
}
func (vers *Version) String() string {
+ if vers.tag != "" {
+ return fmt.Sprintf("%s-tag", vers.tag)
+ }
return fmt.Sprintf(VERSION_FORMAT, vers.Major(), vers.Minor(), vers.Revision(), vers.Stability())
}
@@ -155,6 +174,8 @@ func LoadVersion(versStr string) (*Version, error) {
if len(sparts) > 1 {
stability = strings.Trim(sparts[1], " ")
switch stability {
+ case VERSION_STABILITY_TAG:
+ return NewTag(strings.Trim(sparts[0], " ")), nil
case VERSION_STABILITY_STABLE:
fallthrough
case VERSION_STABILITY_DEV:
@@ -165,7 +186,6 @@ func LoadVersion(versStr string) (*Version, error) {
fmt.Sprintf("Unknown stability (%s) in version ", stability) + versStr)
}
}
-
parts := strings.Split(sparts[0], ".")
if len(parts) > 3 {
return nil, util.NewNewtError(fmt.Sprintf("Invalid version string: %s", versStr))
@@ -202,6 +222,15 @@ func NewVersion(major int64, minor int64, rev int64) *Version {
vers.major = major
vers.minor = minor
vers.revision = rev
+ vers.tag = ""
+
+ return vers
+}
+
+func NewTag(tag string) *Version {
+ vers := &Version{}
+ vers.tag = tag
+ vers.stability = VERSION_STABILITY_NONE
return vers
}
[2/2] incubator-mynewt-newt git commit: unixchild - Remove child from
parent's pgid.
Posted by cc...@apache.org.
unixchild - Remove child from parent's pgid.
This prevents the child process from receiving a ^C SIGINT.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/24a7b8be
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/24a7b8be
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/24a7b8be
Branch: refs/heads/master
Commit: 24a7b8beb344f4817b277b778bb51d1ce2bf5a73
Parents: 26b618f
Author: Christopher Collins <cc...@apache.org>
Authored: Thu May 18 16:00:01 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Thu May 18 16:00:01 2017 -0700
----------------------------------------------------------------------
util/unixchild/unixchild.go | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/24a7b8be/util/unixchild/unixchild.go
----------------------------------------------------------------------
diff --git a/util/unixchild/unixchild.go b/util/unixchild/unixchild.go
index 3474424..cb4734d 100644
--- a/util/unixchild/unixchild.go
+++ b/util/unixchild/unixchild.go
@@ -29,6 +29,7 @@ import (
"os/exec"
"strings"
"sync"
+ "syscall"
"time"
log "github.com/Sirupsen/logrus"
@@ -107,6 +108,7 @@ func New(conf Config) *Client {
func (c *Client) startChild() (*exec.Cmd, error) {
subProcess := exec.Command(c.childPath, c.childArgs...)
+ subProcess.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
stdin, err := subProcess.StdinPipe()
if err != nil {