Ejemplo n.º 1
0
func buildMap(pkg *Package, m map[string]string) error {
	for _, dep := range pkg.Dependencies {
		var ch Package
		err := gx.FindPackageInDir(&ch, filepath.Join(vendorDir, dep.Hash))
		if err != nil {
			return err
		}

		if ch.Gx.DvcsImport != "" {
			e, ok := m[ch.Gx.DvcsImport]
			if ok {
				if e != dep.Hash {
					Log("have two dep packages with same import path: ", ch.Gx.DvcsImport)
					Log("  - ", e)
					Log("  - ", dep.Hash)
				}
				continue
			}
			m[ch.Gx.DvcsImport] = dep.Hash
		}

		err = buildMap(&ch, m)
		if err != nil {
			return err
		}
	}
	return nil
}
Ejemplo n.º 2
0
func reqCheckHook(pkghash string) error {
	p := filepath.Join(vendorDir, pkghash)

	var npkg Package
	err := gx.FindPackageInDir(&npkg, p)
	if err != nil {
		return err
	}

	if npkg.Gx.GoVersion != "" {
		out, err := exec.Command("go", "version").CombinedOutput()
		if err != nil {
			return fmt.Errorf("no go compiler installed")
		}

		parts := strings.Split(string(out), " ")
		if len(parts) < 4 {
			return fmt.Errorf("unrecognized output from go compiler")
		}

		havevers := parts[2][2:]

		reqvers := npkg.Gx.GoVersion

		badreq, err := versionComp(havevers, reqvers)
		if err != nil {
			return err
		}
		if badreq {
			return fmt.Errorf("package '%s' requires go version %s, you have %s installed.", npkg.Name, reqvers, havevers)
		}

	}
	return nil
}
Ejemplo n.º 3
0
func loadDep(dep *gx.Dependency, pkgdir string) (*Package, error) {
	var cpkg Package
	pdir := filepath.Join(pkgdir, dep.Hash)
	VLog("  - fetching dep: %s (%s)", dep.Name, dep.Hash)
	err := gx.FindPackageInDir(&cpkg, pdir)
	if err != nil {
		// try global
		p := filepath.Join(globalPath(), dep.Hash)
		VLog("  - checking in global namespace (%s)", p)
		gerr := gx.FindPackageInDir(&cpkg, p)
		if gerr != nil {
			return nil, fmt.Errorf("failed to find package: %s", gerr)
		}
	}

	return &cpkg, nil
}
Ejemplo n.º 4
0
			Name:  "global",
			Usage: "specifies whether or not the install was global",
		},
	},
	Action: func(c *cli.Context) error {
		if !c.Args().Present() {
			return fmt.Errorf("must specify path to newly installed package")
		}
		npkg := c.Args().First()
		// update sub-package refs here
		// ex:
		// if this package is 'github.com/X/Y' replace all imports
		// matching 'github.com/X/Y*' with 'gx/<hash>/name*'

		var pkg Package
		err := gx.FindPackageInDir(&pkg, npkg)
		if err != nil {
			return fmt.Errorf("find package failed: %s", err)
		}

		dir := filepath.Join(npkg, pkg.Name)

		// build rewrite mapping from parent package if
		// this call is made on one in the vendor directory
		var reldir string
		if strings.Contains(npkg, "vendor/gx/ipfs") {
			reldir = strings.Split(npkg, "vendor/gx/ipfs")[0]
			reldir = filepath.Join(reldir, "vendor", "gx", "ipfs")
		} else {
			reldir = dir
		}