Documentation ¶
Index ¶
- Constants
- func FindRPMFiles(srpmPath string, pkgGraph *PkgGraph, graphMutex *sync.RWMutex) (expectedFiles, missingFiles []string)
- func ReadDOTGraph(g graph.DirectedBuilder, input io.Reader) (err error)
- func WriteDOTGraph(g graph.Directed, output io.Writer) (err error)
- func WriteDOTGraphFile(g graph.Directed, filename string) (err error)
- type LookupNode
- type NodeState
- type NodeType
- type PkgGraph
- func (g *PkgGraph) AddEdge(from *PkgNode, to *PkgNode) (err error)
- func (g *PkgGraph) AddGoalNode(goalName string, packages, tests []*pkgjson.PackageVer, strict bool) (goalNode *PkgNode, err error)
- func (g *PkgGraph) AddGoalNodeToNodes(goalName string, existingNodes []*PkgNode, extraLayers int) (goalNode *PkgNode, err error)
- func (g *PkgGraph) AddGoalNodeWithExtraLayers(goalName string, packages, tests []*pkgjson.PackageVer, strict bool, ...) (goalNode *PkgNode, err error)
- func (g *PkgGraph) AddMetaNode(from []*PkgNode, to []*PkgNode) (metaNode *PkgNode)
- func (g *PkgGraph) AddPkgNode(versionedPkg *pkgjson.PackageVer, nodeState NodeState, nodeType NodeType, ...) (newNode *PkgNode, err error)
- func (g *PkgGraph) AddRemoteUnresolvedNode(versionedPkg *pkgjson.PackageVer) (newNode *PkgNode, err error)
- func (g *PkgGraph) AllBuildNodes() []*PkgNode
- func (g *PkgGraph) AllImplicitNodes() []*PkgNode
- func (g *PkgGraph) AllNodes() []*PkgNode
- func (g *PkgGraph) AllNodesFrom(rootNode *PkgNode) []*PkgNode
- func (g *PkgGraph) AllPreferredRunNodes() []*PkgNode
- func (g *PkgGraph) AllRunNodes() []*PkgNode
- func (g *PkgGraph) AllTestNodes() []*PkgNode
- func (g *PkgGraph) CloneNode(pkgNode *PkgNode) (newNode *PkgNode)
- func (g *PkgGraph) CreateCollapsedNode(versionedPkg *pkgjson.PackageVer, parentNode *PkgNode, ...) (newNode *PkgNode, err error)
- func (g *PkgGraph) CreateSubGraph(rootNode *PkgNode) (subGraph *PkgGraph, err error)
- func (g *PkgGraph) DeepCopy() (deepCopy *PkgGraph, err error)
- func (g *PkgGraph) FindAnyDirectedCycle() (nodes []*PkgNode, err error)
- func (g *PkgGraph) FindBestPkgNode(pkgVer *pkgjson.PackageVer) (lookupEntry *LookupNode, err error)
- func (g *PkgGraph) FindDoubleConditionalPkgNodeFromPkg(pkgVer *pkgjson.PackageVer) (lookupEntry *LookupNode, err error)
- func (g *PkgGraph) FindExactPkgNodeFromPkg(pkgVer *pkgjson.PackageVer) (lookupEntry *LookupNode, err error)
- func (g *PkgGraph) FindGoalNode(goalName string) *PkgNode
- func (g *PkgGraph) HasNode(pkgNode *PkgNode) bool
- func (g *PkgGraph) MakeDAG() (err error)
- func (g *PkgGraph) MakeDAGUsingUpstreamRepos(resolveCyclesFromUpstream, ignoreVersionToResolveSelfDep bool, ...) (err error)
- func (g *PkgGraph) NewNode() graph.Node
- func (g *PkgGraph) NodesMatchingFilter(filter func(*PkgNode) bool) (nodes []*PkgNode)
- func (g *PkgGraph) RemovePkgNode(pkgNode *PkgNode)
- type PkgNode
- func (n *PkgNode) Attributes() []encoding.Attribute
- func (n *PkgNode) Copy() (copy *PkgNode)
- func (n *PkgNode) DOTColor() string
- func (n PkgNode) DOTID() string
- func (n *PkgNode) Equal(otherNode *PkgNode) bool
- func (n *PkgNode) FriendlyName() string
- func (n PkgNode) ID() int64
- func (n PkgNode) MarshalBinary() (data []byte, err error)
- func (n *PkgNode) SRPMFileName() string
- func (n *PkgNode) SetAttribute(attr encoding.Attribute) (err error)
- func (n PkgNode) SetDOTID(id string)
- func (n *PkgNode) SpecName() string
- func (n *PkgNode) String() string
- func (n *PkgNode) UnmarshalBinary(inBuffer []byte) (err error)
Constants ¶
const ( LocalRepo = "<LOCAL_REPO>" NoArchitecture = "<NO_ARCHITECTURE>" NoName = "<NO_NAME>" NoRPMPath = "<NO_RPM_PATH>" NoSourceDir = "<NO_SOURCE_DIR>" NoSourceRepo = "<NO_SOURCE_REPO>" NoSpecPath = "<NO_SPEC_PATH>" NoSRPMPath = "<NO_SRPM_PATH>" )
Constants representing empty member fields of the 'PkgNode' struct.
Variables ¶
This section is empty.
Functions ¶
func FindRPMFiles ¶
func FindRPMFiles(srpmPath string, pkgGraph *PkgGraph, graphMutex *sync.RWMutex) (expectedFiles, missingFiles []string)
FindRPMFiles returns a list of all RPMs built by an SRPM and a list of these RPMs that are not available on the disk. The function will lock 'graphMutex' before performing the check if the mutex is not nil.
func ReadDOTGraph ¶
func ReadDOTGraph(g graph.DirectedBuilder, input io.Reader) (err error)
ReadDOTGraph de-serializes a graph from a DOT formatted object
func WriteDOTGraph ¶
WriteDOTGraph serializes a graph into a DOT formatted object
Types ¶
type LookupNode ¶
type LookupNode struct { RunNode *PkgNode // The "meta" run node for a package. Tracks the run-time dependencies for the package. Remote packages will only have a RunNode. BuildNode *PkgNode // The build node for a package. Tracks the build requirements for the package. May be nil for remote packages. TestNode *PkgNode // The test node for a package. Tracks the test requirements for the package. Nil for non-test builds and when its spec has no '%check' section. }
LookupNode represents a graph node for a package in the lookup list
func (*LookupNode) PackageVer ¶
func (n *LookupNode) PackageVer() (packageVer *pkgjson.PackageVer)
type NodeState ¶
type NodeState int
NodeState indicates if a node is a package node (build, upToDate,unresolved,cached) or a meta node (meta)
const ( StateUnknown NodeState = iota // Unknown state StateMeta NodeState = iota // Meta nodes do not represent actual build artifacts, but additional nodes used for managing dependencies StateBuild NodeState = iota // A package from a local SRPM which should be built from source StateUpToDate NodeState = iota // A local RPM is already built and is available StateUnresolved NodeState = iota // A dependency is not available locally and must be acquired from a remote repo StateCached NodeState = iota // A dependency was not available locally, but is now available in the chache StateBuildError NodeState = iota // A package from a local SRPM which failed to build StateDelta NodeState = iota // Same as build state, but an attempt has been made to pre-download the .rpm to the cache StateMAX NodeState = iota // Max allowable state )
Valid values for NodeState type
type NodeType ¶
type NodeType int
NodeType indicates the general node type (build, run, goal, remote).
const ( TypeUnknown NodeType = iota // Unknown type TypeLocalBuild NodeType = iota // Package can be build if all dependency edges are satisfied TypeLocalRun NodeType = iota // Package can be run if all dependency edges are satisfied. Will be associated with a partner build node TypeGoal NodeType = iota // Meta node which depends on a user selected subset of packages to be built. TypeRemoteRun NodeType = iota // A non-local node which may have a cache entry TypePureMeta NodeType = iota // An arbitrary meta node with no other meaning TypePreBuilt NodeType = iota // A node indicating a pre-built SRPM used in breaking cyclic build dependencies TypeTest NodeType = iota // A node for running the '%check' section of the underlying package TypeMAX NodeType = iota // Max allowable type )
Valid values for NodeType type
type PkgGraph ¶
type PkgGraph struct { *simple.DirectedGraph // contains filtered or unexported fields }
PkgGraph implements a simple.DirectedGraph using pkggraph Nodes.
func NewPkgGraph ¶
func NewPkgGraph() *PkgGraph
NewPkgGraph creates a new package dependency graph based on a simple.DirectedGraph
func ReadDOTGraphFile ¶
ReadDOTGraphFile reads the graph from a DOT graph format file
func (*PkgGraph) AddGoalNode ¶
func (g *PkgGraph) AddGoalNode(goalName string, packages, tests []*pkgjson.PackageVer, strict bool) (goalNode *PkgNode, err error)
AddGoalNode adds a goal node to the graph which links to existing nodes. An empty package list will add an edge to all nodes
- goalName: The name of the goal node to add
- packages: A list of packages to add to link the goal node to. If empty, all nodes will be added to the goal node
- strict: If true, the goal node will fail if any of the packages are not found
func (*PkgGraph) AddGoalNodeToNodes ¶
func (g *PkgGraph) AddGoalNodeToNodes(goalName string, existingNodes []*PkgNode, extraLayers int) (goalNode *PkgNode, err error)
AddGoalNodeToNodes behaves similarly to AddGoalNodeWithExtraLayers, but instead of using a list of package versions (via graph lookup) to create the goal node, it uses a list of existing nodes in the graph.
- goalName: The name of the goal node to add
- existingNodes: A list of nodes to link the goal node to.
- extraLayers: The number of levels to expand the goal node. Each level will add one more layer of packages beyond the goal node. For example, if the goal node is "x" and extraLevels is 1, the goal node will link to all nodes which depend on "x" as well as "x" itself (Specifically run nodes, all other nodes are stepped over)
func (*PkgGraph) AddGoalNodeWithExtraLayers ¶
func (g *PkgGraph) AddGoalNodeWithExtraLayers(goalName string, packages, tests []*pkgjson.PackageVer, strict bool, extraLayers int) (goalNode *PkgNode, err error)
AddGoalNodeWithExtraLayers adds a goal node to the graph which links to existing nodes. An empty package list will add an edge to all nodes
- goalName: The name of the goal node to add
- packages: A list of packages to add to link the goal node to. If empty, all nodes will be added to the goal node
- strict: If true, the goal node will fail if any of the packages are not found
- extraLayers: The number of levels to expand the goal node. Each level will add one more layer of packages beyond the goal node. For example, if the goal node is "x" and extraLevels is 1, the goal node will link to all nodes which depend on "x" as well as "x" itself (Specifically run nodes, all other nodes are stepped over)
func (*PkgGraph) AddMetaNode ¶
AddMetaNode adds a generic meta node with edges: <from> -> metaNode -> <to>
func (*PkgGraph) AddPkgNode ¶
func (g *PkgGraph) AddPkgNode(versionedPkg *pkgjson.PackageVer, nodeState NodeState, nodeType NodeType, srpmPath, rpmPath, specPath, sourceDir, architecture, sourceRepo string) (newNode *PkgNode, err error)
AddPkgNode adds a new node to the package graph. Run, Build, and Unresolved nodes are recorded in the lookup table.
func (*PkgGraph) AddRemoteUnresolvedNode ¶
func (g *PkgGraph) AddRemoteUnresolvedNode(versionedPkg *pkgjson.PackageVer) (newNode *PkgNode, err error)
AddRemoteUnresolvedNode adds a new node to the package graph representing an unresolved remote dependency.
func (*PkgGraph) AllBuildNodes ¶
AllBuildNodes returns a list of all build nodes in the graph
func (*PkgGraph) AllImplicitNodes ¶
AllImplicitNodes returns a list of all implicit remote nodes in the graph
func (*PkgGraph) AllNodesFrom ¶
AllNodesFrom returns a list of all nodes accessible from a root node
func (*PkgGraph) AllPreferredRunNodes ¶
AllPreferredRunNodes returns all RunNodes in the LookupTable Though a graph can contain both LocalRun and RemoteRun node for a single package-version, the LookupTable will have: 1. LocalRun Node if only LocalRun node is present in the graph 2. RemoteRun Node if only RemoteRun node is present in the graph 3. LocalRun Node if both LocalRun and RemoteRun nodes are present in the graph This function will return all RunNodes in the LookupTable.
func (*PkgGraph) AllRunNodes ¶
AllRunNodes returns a list of all run nodes in the graph It traverses the graph and returns all nodes of type TypeLocalRun and TypeRemoteRun.
func (*PkgGraph) AllTestNodes ¶
AllTestNodes returns a list of all test nodes in the graph
func (*PkgGraph) CloneNode ¶
CloneNode creates a clone of the input node with a new, unique ID. The clone doesn't have any edges attached to it.
func (*PkgGraph) CreateCollapsedNode ¶
func (g *PkgGraph) CreateCollapsedNode(versionedPkg *pkgjson.PackageVer, parentNode *PkgNode, nodesToCollapse []*PkgNode) (newNode *PkgNode, err error)
CreateCollapsedNode creates a new run node linked to a given parent node. All nodes in nodesToCollapse will be collapsed into the new node. - When a node is collapsed all of its dependents will be mirrored onto the new node. - The parentNode must be a run node. - The collapsed node will inherit all attributes of the parent node minus the versionedPkg.
func (*PkgGraph) CreateSubGraph ¶
CreateSubGraph returns a new graph with which only contains the nodes accessible from rootNode.
func (*PkgGraph) DeepCopy ¶
DeepCopy returns a deep copy of the receiver. On error, the returned deepCopy is in an invalid state
func (*PkgGraph) FindAnyDirectedCycle ¶
FindAnyDirectedCycle returns any single cycle in the graph, if one exists. Multiple instances of this routine should not be run at the same time on a given graph.
func (*PkgGraph) FindBestPkgNode ¶
func (g *PkgGraph) FindBestPkgNode(pkgVer *pkgjson.PackageVer) (lookupEntry *LookupNode, err error)
FindBestPkgNode will search the lookup table to see if a node which satisfies the PackageVer structure has already been created. Returns nil if no lookup entry is found. Condition = "" is equivalent to Condition = "=".
func (*PkgGraph) FindDoubleConditionalPkgNodeFromPkg ¶
func (g *PkgGraph) FindDoubleConditionalPkgNodeFromPkg(pkgVer *pkgjson.PackageVer) (lookupEntry *LookupNode, err error)
FindDoubleConditionalPkgNodeFromPkg has the same behavior as FindConditionalPkgNodeFromPkg but supports two conditionals
func (*PkgGraph) FindExactPkgNodeFromPkg ¶
func (g *PkgGraph) FindExactPkgNodeFromPkg(pkgVer *pkgjson.PackageVer) (lookupEntry *LookupNode, err error)
FindExactPkgNodeFromPkg attempts to find a LookupNode which has the exactly correct version information listed in the PackageVer structure. Returns nil if no lookup entry is found.
func (*PkgGraph) FindGoalNode ¶
FindGoalNode returns a named goal node if one exists.
func (*PkgGraph) HasNode ¶
HasNode returns true if pkgNode points to a node that is present in the graph. If the object is not the same, but the ID is the same, it will return false (i.e., the node is a copy)
func (*PkgGraph) MakeDAGUsingUpstreamRepos ¶
func (g *PkgGraph) MakeDAGUsingUpstreamRepos(resolveCyclesFromUpstream, ignoreVersionToResolveSelfDep bool, cloner *rpmrepocloner.RpmRepoCloner) (err error)
MakeDAGUsingUpstreamRepos ensures the graph is a directed acyclic graph (DAG). If the graph is not a DAG, this routine will attempt to resolve any cycles using RPMs in the PMC to make the graph a DAG.
func (*PkgGraph) NodesMatchingFilter ¶
NodesMatchingFilter returns a list of all nodes satisfying the input filter.
func (*PkgGraph) RemovePkgNode ¶
RemovePkgNode removes a node from the package graph and lookup tables.
type PkgNode ¶
type PkgNode struct { VersionedPkg *pkgjson.PackageVer // JSON derived structure holding the exact version information for a graph State NodeState // The current state of the node (ie needs to be build, up-to-date, cached, etc) Type NodeType // The purpose of the node (build, run , meta goal, etc) SrpmPath string // SRPM file used to generate this package (likely shared with multiple other nodes) RpmPath string // RPM file that produces this package (likely shared with multiple other nodes) SpecPath string // The SPEC file extracted from the SRPM SourceDir string // The directory containing extracted sources from the SRPM Architecture string // The architecture of the resulting package built. SourceRepo string // The location this package was acquired from GoalName string // Optional string for goal nodes Implicit bool // If the package is an implicit provide This *PkgNode // Self reference since the graph library returns nodes by value, not reference // contains filtered or unexported fields }
PkgNode represents a package.
func (*PkgNode) Attributes ¶
Attributes marshals all relevent node data into a DOT graph structure. The entire node is encoded using base64 and gob.
func (PkgNode) DOTID ¶
DOTID generates an id for a DOT graph of the form "pkg(ver:=xyz)<TYPE> (ID=x,STATE=state)""
func (*PkgNode) FriendlyName ¶
FriendlyName formats a summary of a node into a string.
func (PkgNode) MarshalBinary ¶
MarshalBinary implements the GOB encoding interface
func (*PkgNode) SRPMFileName ¶
SRPMFileName returns the name of the SRPM file associated with this node. Returns "." if the node doesn't have an SRPM file path or URL.
func (*PkgNode) SetAttribute ¶
SetAttribute sets a DOT attribute for the current node when parsing a DOT file
func (*PkgNode) SpecName ¶
SpecName returns the name of the spec associated with this node. Returns "." if the node doesn't have a spec file path or URL.
func (*PkgNode) UnmarshalBinary ¶
UnmarshalBinary implements the GOB encoding interface