Documentation ¶
Overview ¶
Package graph provides dependency resolution for AUR packages. It is not very optimized, but it should work (hopefully).
Usage ¶
First, you have to create a graph:
pkgs, err := aur.ReadAll(list) if err != nil { return err } g, err := graph.NewGraph() if err != nil { return err }
Once you have a graph, you can then get the ordered dependency list with the following function:
graph.Dependencies(g)
Index ¶
- func AllNodesBottomUp(g graph.Directed) []graph.Node
- func Dependencies(g *Graph) (pacman.Packages, aur.Packages, []string)
- func NodesBottomUp(g graph.Directed, root graph.Node) []graph.Node
- func Roots(g graph.Directed) []graph.Node
- type Edge
- type Factory
- type Graph
- func (g *Graph) AddEdgeFromTo(u, v graph.Node)
- func (g *Graph) AddNode(v graph.Node)
- func (g *Graph) Edge(u, v graph.Node) graph.Edge
- func (g *Graph) From(v graph.Node) []graph.Node
- func (g *Graph) Has(n graph.Node) bool
- func (g *Graph) HasEdgeBetween(u, v graph.Node) bool
- func (g *Graph) HasEdgeFromTo(u, v graph.Node) bool
- func (g *Graph) HasName(name string) bool
- func (g *Graph) NewNode(pkg pacman.AnyPackage) *Node
- func (g *Graph) NewNodeID() int
- func (g *Graph) NodeWithName(name string) *Node
- func (g *Graph) Nodes() []graph.Node
- func (g *Graph) To(v graph.Node) []graph.Node
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllNodesBottomUp ¶
AllNodesBottomUp returns for all roots the nodes bottom-up.
func Dependencies ¶
Dependencies returns a list of all dependencies in the graph, those in repositories, those from AUR, and those unknown.
func NodesBottomUp ¶
NodesBottomUp returns the subtree from the bottom levels upwards to the root. The nodes may appear multiple times however.
Types ¶
type Edge ¶
type Edge struct {
// contains filtered or unexported fields
}
Edge implements the graph.Edge interface.
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
A Factory creates a dependency graph given a set of packages.
It can perform AUR calls to resolve dependencies and it can truncate dependencies so that they are not resolved beyond packages available in repositories. This reduces the dependency list
func NewFactory ¶
NewFactory returns a new dependency graph, ignoring repositories given in `ignore`.
Note that it makes a difference between dependencies that are in AUR, and those availabe in the repositories. Ignoring repositories effectively "demotes" any packages available in them back to AUR.
Any package that is in the dependency graph that is not from AUR is treated as a leaf in the graph, since we assume that pacman can resolve those dependencies.
func (*Factory) NewGraph ¶
NewGraph returns a dependency graph of the given AUR packages. Extra packages may be pulled into the graph to properly build the dependency graph.
func (*Factory) NumRequestsAUR ¶
NumRequestsAUR returns the number of requests made to AUR.
func (*Factory) SetDependencyFunc ¶
func (f *Factory) SetDependencyFunc(fn func(pacman.AnyPackage) []string)
SetDependencyFunc controls which dependency list is used. By default, make and install dependencies are included.
func (*Factory) SetNoUnknown ¶
SetNoUnknown controls whether unknown packages (i.e., not on AUR) are injected into the graph. If this is set to true, NewGraph will fail if any unknown packages are found.
func (*Factory) SetSkipInstalled ¶
SetSkipInstalled controls whether installed packages are disregarded from the dependency tree.
func (*Factory) SetTruncate ¶
SetTruncate controls whether packages available in a repository are not further investigated.
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph implements graph.Graph.
func (*Graph) AddEdgeFromTo ¶
AddEdgeFromTo adds an edge betwewen the two nodes.
func (*Graph) AddNode ¶
AddNode adds the node and initializes data structures but does nothing else.
func (*Graph) Edge ¶
Edge returns the edge from u to v if such an edge exists and nil otherwise. The node v must be directly reachable from u as defined by the From method.
func (*Graph) HasEdgeBetween ¶
HasEdgeBetween returns whether an edge exists between nodes u and v without considering direction.
func (*Graph) HasEdgeFromTo ¶
HasEdgeFromTo returns whether an edge exists in the graph from u to v.
func (*Graph) HasName ¶
HasName returns whether the package with the given name exists within the graph.
func (*Graph) NewNode ¶
func (g *Graph) NewNode(pkg pacman.AnyPackage) *Node
NewNode returns a new node.
func (*Graph) NodeWithName ¶
NodeWithName returns the node with the given name, or nil.
type Node ¶
type Node struct { pacman.AnyPackage // contains filtered or unexported fields }
Node implements graph.Node.
func (*Node) AllDepends ¶
AllDepends returns a (newly created) string slice of the installation and make dependencies of this package.
func (*Node) NumAllDepends ¶
NumDepends returns the number of make and installation dependencies the package has.