Exemple #1
0
// query the AUR for build deps to packages.
func getDeps(pkgs []string, curr *depNode, updates map[string]*depNode) error {
	var err error
	pkgsInfo, err := aur.Info(pkgs)
	if err != nil {
		return err
	}

	for _, pkg := range pkgsInfo {
		var pkgNode *depNode

		pkgNode, ok := updates[pkg.Name]
		if !ok {
			pkgNode = &depNode{
				name:     pkg.Name,
				version:  pkg.Version,
				parents:  make(map[string]*depNode),
				children: make(map[string]*depNode),
			}
			updates[pkg.Name] = pkgNode
		}

		if curr != nil {
			curr.parents[pkgNode.name] = pkgNode
			pkgNode.children[curr.name] = curr
		}

		// TODO: maybe add optdepends
		depends := make([]string, 0, len(pkg.Depends)+len(pkg.MakeDepends))
		err := addDeps(&depends, pkg.Depends)
		if err != nil {
			return err
		}
		err = addDeps(&depends, pkg.MakeDepends)
		if err != nil {
			return err
		}
		getDeps(depends, pkgNode, updates)
	}

	return nil
}
Exemple #2
0
// query the AUR for build deps to packages.
func (a AUR) getDeps(pkgs []string, updates map[string]struct{}) error {
	pkgsInfo, err := aur.Info(pkgs)
	if err != nil {
		return err
	}

	for _, pkg := range pkgsInfo {
		updates[pkg.PackageBase] = struct{}{}

		// TODO: maybe add optdepends
		depends := make([]string, 0, len(pkg.Depends)+len(pkg.MakeDepends))
		err := addDeps(&depends, pkg.Depends)
		if err != nil {
			return err
		}
		err = addDeps(&depends, pkg.MakeDepends)
		if err != nil {
			return err
		}
		a.getDeps(depends, updates)
	}

	return nil
}