Esempio n. 1
0
// downloadPackage downloads package either use version control tools or not.
func downloadPackage(ctx *cli.Context, nod *doc.Node) (*doc.Node, []string) {
	log.Message("Downloading", fmt.Sprintf("package: %s@%s:%s",
		nod.ImportPath, nod.Type, doc.CheckNodeValue(nod.Value)))
	// Mark as donwloaded.
	downloadCache[nod.RootPath] = true

	// Check if only need to use VCS tools.
	var imports []string
	var err error
	gopathDir := path.Join(installGopath, nod.RootPath)
	vcs := getVcsName(gopathDir)
	if ctx.Bool("update") && ctx.Bool("gopath") && len(vcs) > 0 {
		err = updateByVcs(vcs, gopathDir)
		imports = doc.GetAllImports([]string{gopathDir}, nod.RootPath, false)
	} else {
		// If package has revision and exist, then just check dependencies.
		if nod.IsGetDepsOnly {
			return nod, doc.GetAllImports([]string{path.Join(installRepoPath, nod.RootPath) + versionSuffix(nod.Value)},
				nod.RootPath, ctx.Bool("example"))
		}
		nod.Revision = doc.LocalNodes.MustValue(nod.RootPath, "value")
		imports, err = doc.PureDownload(nod, installRepoPath, ctx) //CmdGet.Flags)
	}

	if err != nil {
		log.Error("get", "Fail to download pakage: "+nod.ImportPath)
		log.Error("", "\t"+err.Error())
		failConut++
		os.RemoveAll(installRepoPath + "/" + nod.RootPath)
		return nil, nil
	}
	return nod, imports
}
Esempio n. 2
0
// saveNode saves node into local nodes.
func saveNode(n *doc.Node) {
	// Node dependencies list.
	n.Deps = nil

	// Check if this node exists.
	for i, v := range localNodes {
		if n.ImportPath == v.ImportPath {
			localNodes[i] = n
			return
		}
	}

	// Add new node.
	localNodes = append(localNodes, n)
}
Esempio n. 3
0
File: get.go Progetto: nashtsai/gopm
// downloadPackage downloads package either use version control tools or not.
func downloadPackage(ctx *cli.Context, nod *doc.Node) (*doc.Node, []string) {
	log.Message("Downloading", fmt.Sprintf("package: %s@%s:%s",
		nod.ImportPath, nod.Type, doc.CheckNodeValue(nod.Value)))
	// Mark as donwloaded.
	downloadCache[nod.RootPath] = true

	nod.Revision = doc.LocalNodes.MustValue(nod.RootPath, "value")
	imports, err := doc.PureDownload(nod, installRepoPath, ctx) //CmdGet.Flags)

	if err != nil {
		log.Error("get", "Fail to download pakage: "+nod.ImportPath)
		log.Error("", "\t"+err.Error())
		failConut++
		os.RemoveAll(installRepoPath + "/" + nod.RootPath)
		return nil, nil
	}
	return nod, imports
}