graph

package
v0.22.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 8 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dependencies

func Dependencies(g *Graph) (pacman.Packages, aur.Packages, []string)

Dependencies returns a list of all dependencies in the graph, those in repositories, those from AUR, and those unknown.

Types

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

func NewFactory(ignoreRepos ...string) (*Factory, error)

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

func (f *Factory) NewGraph(pkgs aur.Packages) (*Graph, error)

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

func (f *Factory) NumRequestsAUR() int

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

func (f *Factory) SetNoUnknown(yes bool)

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

func (f *Factory) SetSkipInstalled(yes bool)

SetSkipInstalled controls whether installed packages are disregarded from the dependency tree.

func (*Factory) SetTruncate

func (f *Factory) SetTruncate(yes bool)

SetTruncate controls whether packages available in a repository are not further investigated.

type Graph

type Graph struct {
	*simple.DirectedGraph
	// contains filtered or unexported fields
}

Graph implements graph.Graph.

func NewGraph

func NewGraph() *Graph

NewGraph returns a new graph.

func (*Graph) AddEdgeFromTo

func (g *Graph) AddEdgeFromTo(u, v graph.Node)

AddEdgeFromTo adds a directed edge from u to v.

func (*Graph) AddNode

func (g *Graph) AddNode(v graph.Node)

AddNode adds the node and initializes data structures but does nothing else.

func (*Graph) Has

func (g *Graph) Has(id int64) bool

Has returns whether the node exists within the graph.

func (*Graph) HasName

func (g *Graph) HasName(name string) bool

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

func (g *Graph) NodeWithName(name string) *Node

NodeWithName returns the node with the given name, or nil.

type Node

type Node struct {
	simple.Node
	pacman.AnyPackage
}

Node implements graph.Node.

func (*Node) AllDepends

func (n *Node) AllDepends() []string

AllDepends returns a (newly created) string slice of the installation and make dependencies of this package.

func (*Node) IsFromAUR

func (n *Node) IsFromAUR() bool

IsFromAUR returns whether the node comes from AUR.

func (*Node) NumAllDepends

func (n *Node) NumAllDepends() int

NumAllDepends returns the number of make and installation dependencies the package has.

func (*Node) String

func (n *Node) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL