Documentation
¶
Overview ¶
Package gentooling provides read-only, interoperable Gentoo system and package-state primitives for Go applications.
Index ¶
- Variables
- func PortageStateLockPath(path string) string
- func SortedRepositoryNames(repositories []RepositoryPath) []string
- type Atom
- type BuildMetadata
- type ConfigOptions
- type DependencyMetadata
- type EffectiveConfig
- type FlagChange
- type InstalledInventory
- type InstalledOptions
- type InstalledPackage
- type IntegrityError
- type IntegrityMode
- type Issue
- type IssueCode
- type Op
- type PackageContext
- type PackageFlagRule
- type PackageID
- type PolicySource
- type Profile
- type ProfileLayer
- type RepositoryPath
- type Selection
- type SelectionKind
- type Selections
- type SlotOp
- type SnapshotOptions
- type SystemPaths
- type SystemSnapshot
- type UseDecision
- type UseDeclaration
- type UseDefault
- type UseEvaluation
- type UseEvidence
- type UseFlag
- type UseState
- type Version
Constants ¶
This section is empty.
Variables ¶
var ( ErrIncompleteEvidence = errors.New("gentooling: incomplete evidence") ErrInterruptedRecord = errors.New("gentooling: interrupted package record") ErrCorruptRecord = errors.New("gentooling: corrupt package record") ErrUnreadableRecord = errors.New("gentooling: unreadable package record") ErrConcurrentMutation = errors.New("gentooling: concurrent mutation") )
var ErrInvalidData = errors.New("gentooling: invalid data")
var ErrLockObservationUnsupported = errors.New("gentooling: Portage lock observation unsupported")
var ErrProfileCycle = errors.New("gentooling: profile parent cycle")
Functions ¶
func PortageStateLockPath ¶ added in v0.5.0
PortageStateLockPath mirrors portage.locks.lockdir. A state path or directory is protected by a sibling .<basename>.portage_lockfile.
func SortedRepositoryNames ¶
func SortedRepositoryNames(repositories []RepositoryPath) []string
SortedRepositoryNames provides deterministic diagnostics for configured repository maps.
Types ¶
type Atom ¶
type Atom struct {
Op Op
Category string
Package string
Version *Version
Slot string
Subslot string
SlotOp SlotOp
Repo string
UseFlags []UseFlag
}
Atom is a parsed Gentoo package dependency atom.
func ParsePackageAtom ¶
ParsePackageAtom is the pointer-returning compatibility form of ParseAtom.
func ParsePackageVersion ¶
ParsePackageVersion parses a CPV. Unlike ParseAtom, it accepts a version without a dependency operator.
type BuildMetadata ¶
type ConfigOptions ¶
type ConfigOptions struct {
// Environment is command input, not the process environment. Only
// documented Portage variables and active USE_EXPAND variables are used.
Environment []string
}
type DependencyMetadata ¶
type EffectiveConfig ¶
type EffectiveConfig struct {
Variables map[string]string
Profile *Profile
ProfileUse []FlagChange
UserUse []FlagChange
CommandUse []FlagChange
UserPackageUse []PackageFlagRule
UseExpand []string
UseExpandHidden []string
UseExpandImplicit []string
}
func ReadEffectiveConfig ¶
func ReadEffectiveConfig(ctx context.Context, paths SystemPaths, options ConfigOptions) (EffectiveConfig, error)
ReadEffectiveConfig loads make.globals, the active profile graph, user make.conf/package.use, and an explicit command environment. It never reads the process environment or paths absent from SystemPaths.
func (EffectiveConfig) EvaluateUse ¶
func (config EffectiveConfig) EvaluateUse(ctx context.Context, packageContext PackageContext) (UseEvaluation, error)
EvaluateUse computes effective USE for one package. It only returns flags declared by IUSE and retains every applied policy input in precedence order.
type FlagChange ¶
type FlagChange struct {
Name string
Enabled bool
Source PolicySource
Layer string
}
type InstalledInventory ¶
type InstalledInventory struct {
Packages []InstalledPackage
Issues []Issue
}
func ReadInstalled ¶
func ReadInstalled(ctx context.Context, paths SystemPaths, options InstalledOptions) (InstalledInventory, error)
ReadInstalled reads Portage's installed-package database. AllowPartial returns stable records alongside typed issues. RequireComplete returns the same diagnostic result plus ErrIncompleteEvidence when any evidence is incomplete. The scan detects observed mutations without claiming an atomic snapshot in the absence of a package-manager transaction lock.
type InstalledOptions ¶
type InstalledOptions struct {
Integrity IntegrityMode
IncludeContents bool
// Workers bounds concurrent record reads. Zero chooses a safe runtime-based
// default. Negative values are invalid.
Workers int
// contains filtered or unexported fields
}
type InstalledPackage ¶
type InstalledPackage struct {
ID PackageID
EAPI string
EnabledUse []string
DeclaredUse []UseDeclaration
Dependencies DependencyMetadata
Build BuildMetadata
Contents string
}
type IntegrityError ¶
type IntegrityError struct {
Issues []Issue
}
func (*IntegrityError) Error ¶
func (e *IntegrityError) Error() string
func (*IntegrityError) Unwrap ¶
func (e *IntegrityError) Unwrap() error
type IntegrityMode ¶
type IntegrityMode uint8
const ( AllowPartial IntegrityMode = iota RequireComplete )
type IssueCode ¶
type IssueCode string
const ( IssueMalformedIdentity IssueCode = "malformed_identity" IssueInterruptedRecord IssueCode = "interrupted_record" IssueCorruptRecord IssueCode = "corrupt_record" IssueUnreadableRecord IssueCode = "unreadable_record" IssueInvalidMetadata IssueCode = "invalid_metadata" IssueConcurrentMutation IssueCode = "concurrent_mutation" )
type PackageContext ¶
type PackageContext struct {
ID PackageID
DeclaredUse []UseDeclaration
Stable bool
}
PackageContext is the package-specific evidence required for USE policy evaluation. Stable is explicit because keyword acceptance is consumer policy.
type PackageFlagRule ¶
type PackageFlagRule struct {
Atom string
Flags []string
Source PolicySource
}
type PackageID ¶
type PackageID struct {
Category string
Name string
Version string
Slot string
Subslot string
Repository string
}
PackageID is the stable identity of one package version.
func ParsePackageID ¶
ParsePackageID parses a category/package-version identity. It deliberately does not accept dependency atom operators.
type PolicySource ¶
type Profile ¶
type Profile struct {
ActivePath string
Directories []string
Layers []ProfileLayer
MakeDefaults map[string]string
System []string
PackageProvided []string
UseForce []string
UseMask []string
UseStableForce []string
UseStableMask []string
PackageUse []PackageFlagRule
PackageUseForce []PackageFlagRule
PackageUseMask []PackageFlagRule
PackageUseStableForce []PackageFlagRule
PackageUseStableMask []PackageFlagRule
}
func ReadProfile ¶
func ReadProfile(ctx context.Context, paths SystemPaths) (Profile, error)
ReadProfile loads the active Portage profile in root-to-leaf order. All cross-repository parents are resolved from explicit repository paths.
type ProfileLayer ¶
type ProfileLayer struct {
Path string
Parents []string
MakeDefaults map[string]string
System []string
PackageProvided []string
UseForce []string
UseMask []string
UseStableForce []string
UseStableMask []string
PackageUse []PackageFlagRule
PackageUseForce []PackageFlagRule
PackageUseMask []PackageFlagRule
PackageUseStableForce []PackageFlagRule
PackageUseStableMask []PackageFlagRule
}
type RepositoryPath ¶
type Selection ¶ added in v0.5.0
type Selection struct {
Value string
Kind SelectionKind
Atom *Atom
Source PolicySource
}
Selection is one ordered world or system entry with source provenance.
type SelectionKind ¶ added in v0.5.0
type SelectionKind uint8
SelectionKind distinguishes package atoms from named package sets.
const ( PackageSelection SelectionKind = iota SetSelection )
type Selections ¶ added in v0.5.0
Selections contains explicit user world entries and effective profile system entries. Both slices are deterministic and independently owned.
func ReadSelections ¶ added in v0.5.0
func ReadSelections(ctx context.Context, paths SystemPaths) (Selections, error)
ReadSelections reads the world file and active profile system selection.
type SnapshotOptions ¶ added in v0.5.0
type SnapshotOptions struct {
Installed InstalledOptions
Config ConfigOptions
// Attempts is the maximum number of complete observations. Zero uses 3.
Attempts int
// contains filtered or unexported fields
}
SnapshotOptions configures one combined system-state observation.
type SystemPaths ¶
type SystemPaths struct {
Root string
ConfigRoot string
VDB string
World string
MakeGlobals string
Repositories []RepositoryPath
ActiveProfile string
}
SystemPaths names every host location a Gentooling operation may inspect. Callers may use DefaultSystemPaths for a live system or provide fixture and alternate-root paths explicitly.
func DefaultSystemPaths ¶
func DefaultSystemPaths(root string) SystemPaths
type SystemSnapshot ¶ added in v0.5.0
type SystemSnapshot struct {
Installed InstalledInventory
Config EffectiveConfig
Selections Selections
}
SystemSnapshot is a mutually consistent view of installed packages, effective Portage policy, and world/system selections.
func ReadSystemSnapshot ¶ added in v0.5.0
func ReadSystemSnapshot(ctx context.Context, paths SystemPaths, options SnapshotOptions) (SystemSnapshot, error)
ReadSystemSnapshot returns only after two consecutive complete observations agree while shared VDB and world locks exclude cooperating package-state writers. Persistent change is reported as ErrConcurrentMutation instead of returning mixed state.
type UseDecision ¶
type UseDecision struct {
Name string
Enabled bool
Default UseDefault
Forced bool
Masked bool
Evidence []UseEvidence
}
UseDecision is the effective state and provenance for one declared flag.
type UseDeclaration ¶
type UseDeclaration struct {
Name string
Default UseDefault
}
func (UseDeclaration) String ¶
func (d UseDeclaration) String() string
type UseDefault ¶
type UseDefault uint8
const ( UseDefaultUnspecified UseDefault = iota UseDefaultEnabled UseDefaultDisabled )
type UseEvaluation ¶
type UseEvaluation struct {
Package PackageID
Decisions []UseDecision
}
UseEvaluation contains deterministic package-specific USE decisions.
func (UseEvaluation) Decision ¶
func (evaluation UseEvaluation) Decision(name string) (UseDecision, bool)
Decision returns a flag decision by name.
type UseEvidence ¶
type UseEvidence struct {
Enabled bool
Kind string
Source PolicySource
Layer string
}
UseEvidence records one ordered input to an effective USE decision.
type UseFlag ¶
type UseFlag struct {
Name string
Enabled bool
Conditional bool
Equal bool
Negated bool
Default *bool
}
UseDependency is one USE constraint attached to an atom.
type UseState ¶
UseState contains both enabled and declared USE state. Caller is used to evaluate conditional and equality dependencies.
type Version ¶
Version is a parsed Gentoo package version.
func ParseVersion ¶
ParseVersion parses a Gentoo version.