Newt and Newtmgr are written in Go (golang). This guide shows you how to install Go and setup your environment to update and build the tools if you want to:
Build the tools with latest updates from the master branch on Linux or Windows platforms.
Note: For Mac OS, you can use the brew install mynewt-newt -HEAD
and the brew install mynewt-newtmgr --HEAD
commands.
Contribute to newt or newtmgr features or fix bugs.
This guide shows you how to perform the following:
Note: You will also need to read and follow the instructions from the FAQ to set up your git repos to submit changes.
The latest master branch of newt and newtmgr requires GO version 1.10. You can skip this step and proceed to Step 2 if you already have Go version 1.10 installed.
If you do not have Homebrew installed, run the following command. You will be prompted for your sudo password.
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
You can also extract (or git clone
) Homebrew and install it to /usr/local.
$ brew install go ==> ... ... ==> Summary 🍺 /usr/local/Cellar/go/1.10.3: 8,170 files, 336.8MB
You can also download the Go package directly from (https://golang.org/dl/) and install it in /usr/local/bin instead of brewing it.
This section describes the Go environment and how to setup a Go workspace. If you already have a Go workspace for your other Go projects, you can skip this step and proceed to Step 3.
Go provides an environment to compile Go code, construct Go packages, and import Go code. You will use Go commands to import the newt or newtmgr package repository into your local Go environment. The Go language environment dictates a specific directory structure, or workspace in Go parlance. It must contain three sibling directories with the names src, pkg and bin:
The GOPATH environment variable specifies the location of your workspace. To setup this workspace environment, create a dev directory and then a go directory under it. Set the GOPATH environment variable to this directory where you will clone the newt and newtmgr repositories.
$ cd $HOME $ mkdir -p dev/go $ cd dev/go $ export GOPATH=`pwd`
Newt and newtmgr are individual Go packages and have their own git repositories. You can download the source and install one or both tools.
We use the go get
command to download the source, build, and install the binary in the $GOPATH/bin directory.
The newt Go package is mynewt.apache.org/newt/newt and is stored in the Apache Mynewt newt tool repository mirrored on github.
Download the newt package source and install the tool:
$cd $GOPATH $go get mynewt.apache.org/newt/newt $cd $GOPATH/src/mynewt.apache.org/newt $ls DISCLAIMER RELEASE_NOTES.md util INSTALLING.md build.sh viper LICENSE newt yaml NOTICE newtmgr README.md newtvm $git status On branch master Your branch is up-to-date with 'origin/master'. nothing to commit, working directory clean
$ls $GOPATH/bin/newt ~/dev/go/bin/newt $which newt ~/dev/go/bin/newt $newt version Apache Newt version: 1.1.0-dev
The newtmgr Go package is mynewt.apache.org/newtmgr/newtmgr. It is stored in the Apache Mynewt newtmgr tool repository mirrored on github.
Download the newtmgr package and install the tool:
$cd $GOPATH $go get mynewt.apache.org/newtmgr/newtmgr $cd $GOPATH/src/mynewt.apache.org/newtmgr $ls LICENSE NOTICE README.md newtmgr nmxact $git status On branch master Your branch is up-to-date with 'origin/master'. nothing to commit, working directory clean
$ls $GOPATH/bin/newtmgr ~/dev/go/bin/newtmgr $which newtmgr ~/dev/go/bin/newtmgr
Here is the general procedure to rebuild either the newt or newtmgr tool. The only difference is the directory where you will be executing the commands from. You will need to repeat the procedure to rebuild both tools.
For the newt tool:
$cd $GOPATH/src/mynewt.apache.org/newt/newt
For the newtmgr tool:
$cd $GOPATH/src/mynewt.apache.org/newtmgr/newtmgr
$git pull
$go install
You can run the ls -l
command to check the modification time for the binary to ensure the new version is installed.