Exemplo 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
}
Exemplo n.º 2
0
Arquivo: get.go Projeto: 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
}