func BuildDepGraph(repos RepoMap, rootReqs RequirementMap) (DepGraph, error) {
	dg := DepGraph{}
	for repoName, verReq := range rootReqs {
		repo := repos[repoName]
		normalizedReq, err := repo.NormalizeVerReq(verReq)
		if err != nil {
			return nil, err
		}
		if err := dg.AddRootDep(repoName, normalizedReq); err != nil {
			return nil, err
		}
	}
	for _, r := range repos.Sorted() {
		nvers, err := r.NormalizedVersions()
		if err != nil {
			return nil, err
		}
		for _, v := range nvers {
			deps := r.DepsForVersion(v)
			reqMap := RequirementMap{}
			for _, d := range deps {
				depRepo := repos[d.Name]
				verReqs, err := depRepo.NormalizeVerReq(d.VerReqs)
				if err != nil {
					return nil, err
				}
				reqMap[d.Name] = verReqs
			}
			if err := dg.AddRepoVer(r.Name(), v, reqMap); err != nil {
				return nil, err
			}
		}
	}
	return dg, nil
}
Builds a repo dependency graph from the repo requirements expressed in the
`project.yml` file.
package deprepo
import (
	"fmt"
	"sort"
	"strings"
	log "github.com/sirupsen/logrus"
	"mynewt.apache.org/newt/newt/newtutil"
	"mynewt.apache.org/newt/newt/repo"
	"mynewt.apache.org/newt/util"
)
type RepoMap map[string]*repo.Repo
type VersionMap map[string]newtutil.RepoVersion
type RequirementMap map[string]newtutil.RepoVersion
type ConflictEntry struct {
	Dependent   RVPair
	DependeeVer newtutil.RepoVersion
}
type Conflict struct {
	DependeeName string
	Entries      []ConflictEntry
}
func (c *Conflict) SortEntries() {
	sort.Slice(c.Entries, func(i int, j int) bool {
		ci := c.Entries[i]
		cj := c.Entries[j]
		x := CompareRVPairs(ci.Dependent, cj.Dependent)
		if x != 0 {
			return x < 0
		}
		return newtutil.CompareRepoVersions(ci.DependeeVer, cj.DependeeVer) < 0
	})
}
func (vm VersionMap) SortedNames() []string {
	names := make([]string, 0, len(vm))
	for name, _ := range vm {
		names = append(names, name)
	}
	sort.Strings(names)
	return names
}
func (rm RepoMap) Sorted() []*repo.Repo {
	names := make([]string, 0, len(rm))
	for n, _ := range rm {
		names = append(names, n)
	}
	sort.Strings(names)
	repos := make([]*repo.Repo, len(names))
	for i, n := range names {
		repos[i] = rm[n]
	}
	return repos
}
func (vm VersionMap) String() string {
	s := ""
	names := vm.SortedNames()
	for _, name := range names {
		ver := vm[name]
		if len(s) > 0 {
			s += "\n"
		}
		s += fmt.Sprintf("%s:%s", name, ver.String())
	}
	return s
}