Documentation ¶
Index ¶
- Constants
- func GetRawPackages(yml []byte) (rawPackages, error)
- type BhojpurConfig
- type BhojpurGeneralConfig
- type BhojpurLoggingConfig
- type BhojpurRepositories
- type BhojpurRepository
- type BhojpurSolverOptions
- type BhojpurSystemConfig
- type Collection
- type Context
- type FinalizerEnv
- type Finalizers
- type GarbageCollector
- type Logger
- type Package
- func DecodePackage(ID string, db PackageDatabase) (*Package, error)
- func NewPackage(name, version string, requires []*Package, conflicts []*Package) *Package
- func PackageFromString(s string) *Package
- func PackageFromYaml(yml []byte) (Package, error)
- func PackagesFromYAML(yml []byte) ([]Package, error)
- func (p *Package) AddAnnotation(k, v string)
- func (p *Package) AddLabel(k, v string)
- func (p *Package) AddURI(s string)
- func (p *Package) AddUse(use string)
- func (p *Package) AtomMatches(m *Package) bool
- func (pack *Package) BuildFormula(definitiondb PackageDatabase, db PackageDatabase) ([]bf.Formula, error)
- func (p *Package) BumpBuildVersion() error
- func (p *Package) Clone() *Package
- func (p *Package) Conflicts(req []*Package) *Package
- func (p *Package) Encode(db PackageDatabase) (string, error)
- func (p *Package) Expand(definitiondb PackageDatabase) (Packages, error)
- func (p *Package) Explain()
- func (p *Package) GetBuildTimestamp() string
- func (p *Package) GetCategory() string
- func (p *Package) GetConflicts() []*Package
- func (p *Package) GetDescription() string
- func (p *Package) GetFingerPrint() string
- func (p *Package) GetLabels() map[string]string
- func (p *Package) GetLicense() string
- func (d *Package) GetMetadataFilePath() string
- func (p *Package) GetName() string
- func (p *Package) GetPackageName() string
- func (p *Package) GetPath() string
- func (p *Package) GetProvides() []*Package
- func (p *Package) GetRequires() []*Package
- func (p *Package) GetRuntimePackage() (*Package, error)
- func (p *Package) GetTreeDir() string
- func (p *Package) GetURI() []string
- func (p *Package) GetUses() []string
- func (p *Package) GetVersion() string
- func (p *Package) HasLabel(label string) (b bool)
- func (p *Package) HashFingerprint(salt string) string
- func (p *Package) HumanReadableString() string
- func (p *Package) ImageID() string
- func (p Package) IsCollection() bool
- func (p *Package) IsHidden() bool
- func (p *Package) IsSelector() bool
- func (t *Package) JSON() ([]byte, error)
- func (p *Package) LabelDeps(definitiondb PackageDatabase, labelKey string) Packages
- func (p *Package) Mark() *Package
- func (p *Package) MatchAnnotation(r *regexp.Regexp) (b bool)
- func (p *Package) MatchLabel(r *regexp.Regexp) (b bool)
- func (p *Package) Matches(m *Package) bool
- func (p *Package) Rel(s string) string
- func (p *Package) Related(definitiondb PackageDatabase) Packages
- func (p *Package) RemoveUse(use string)
- func (p *Package) Requires(req []*Package) *Package
- func (pack *Package) RequiresContains(definitiondb PackageDatabase, s *Package) (bool, error)
- func (p *Package) Revdeps(definitiondb PackageDatabase) Packages
- func (p *Package) SelectorMatchVersion(ver string, v version.Versioner) (bool, error)
- func (p *Package) SetBuildTimestamp(s string)
- func (p *Package) SetCategory(s string)
- func (p *Package) SetDescription(s string)
- func (p *Package) SetLicense(s string)
- func (p *Package) SetName(s string)
- func (p *Package) SetPath(s string)
- func (p *Package) SetProvides(req []*Package) *Package
- func (p *Package) SetTreeDir(s string)
- func (p *Package) SetVersion(v string)
- func (p *Package) String() string
- func (p *Package) VersionMatchSelector(selector string, v version.Versioner) (bool, error)
- func (p *Package) Yaml() ([]byte, error)
- type PackageAnnotation
- type PackageAssert
- type PackageDatabase
- type PackageFile
- type PackageHash
- type PackageMap
- type PackageResolver
- type PackageSet
- type PackageSolver
- type Packages
- type PackagesAssertions
- func (assertions PackagesAssertions) AssertionHash() string
- func (assertions PackagesAssertions) Cut(p *Package) PackagesAssertions
- func (assertions PackagesAssertions) Drop(p *Package) PackagesAssertions
- func (assertions PackagesAssertions) EnsureOrder() PackagesAssertions
- func (assertions PackagesAssertions) HashFrom(p *Package) string
- func (a PackagesAssertions) Len() int
- func (a PackagesAssertions) Less(i, j int) bool
- func (assertions PackagesAssertions) Mark(p *Package) PackagesAssertions
- func (assertions PackagesAssertions) Order(definitiondb PackageDatabase, fingerprint string) (PackagesAssertions, error)
- func (assertions PackagesAssertions) SaltedAssertionHash(salts map[string]string) string
- func (assertions PackagesAssertions) SaltedHashFrom(p *Package, salts map[string]string) string
- func (assertions PackagesAssertions) Search(f string) *PackageAssert
- func (assertions PackagesAssertions) SearchByName(f string) *PackageAssert
- func (a PackagesAssertions) Swap(i, j int)
- func (assertions PackagesAssertions) TrueLen() int
- type SolverOptions
- type SolverType
- type State
Constants ¶
const ( PackageMetaSuffix = "metadata.yaml" PackageCollectionFile = "collection.yaml" PackageDefinitionFile = "definition.yaml" )
Variables ¶
This section is empty.
Functions ¶
func GetRawPackages ¶
Types ¶
type BhojpurConfig ¶
type BhojpurConfig struct { Logging BhojpurLoggingConfig `yaml:"logging,omitempty" mapstructure:"logging"` General BhojpurGeneralConfig `yaml:"general,omitempty" mapstructure:"general"` System BhojpurSystemConfig `yaml:"system" mapstructure:"system"` Solver BhojpurSolverOptions `yaml:"solver,omitempty" mapstructure:"solver"` RepositoriesConfDir []string `yaml:"repos_confdir,omitempty" mapstructure:"repos_confdir"` ConfigProtectConfDir []string `yaml:"config_protect_confdir,omitempty" mapstructure:"config_protect_confdir"` ConfigProtectSkip bool `yaml:"config_protect_skip,omitempty" mapstructure:"config_protect_skip"` ConfigFromHost bool `yaml:"config_from_host,omitempty" mapstructure:"config_from_host"` SystemRepositories BhojpurRepositories `yaml:"repositories,omitempty" mapstructure:"repositories"` FinalizerEnvs Finalizers `json:"finalizer_envs,omitempty" yaml:"finalizer_envs,omitempty" mapstructure:"finalizer_envs,omitempty"` ConfigProtectConfFiles []config.ConfigProtectConfFile `yaml:"-" mapstructure:"-"` }
BhojpurConfig is the general structure which holds all the configuration fields. It includes, Logging, General, System and Solver sub configurations.
func (*BhojpurConfig) AddSystemRepository ¶
func (c *BhojpurConfig) AddSystemRepository(r BhojpurRepository)
AddSystemRepository is just syntax sugar to add a repository in the system set
func (*BhojpurConfig) GetSystemRepository ¶
func (c *BhojpurConfig) GetSystemRepository(name string) (*BhojpurRepository, error)
GetSystemRepository retrieve the system repository inside the configuration Note, the configuration needs to be loaded first.
func (*BhojpurConfig) Init ¶
func (c *BhojpurConfig) Init() error
Init reads the config and replace user-defined paths with absolute paths where necessary, and construct the paths for the cache and database on the real system
func (*BhojpurConfig) SetFinalizerEnv ¶
func (c *BhojpurConfig) SetFinalizerEnv(k, v string)
SetFinalizerEnv sets a k,v couple among the finalizers It ensures that the key is unique, and if set again it gets updated
func (*BhojpurConfig) YAML ¶
func (c *BhojpurConfig) YAML() ([]byte, error)
YAML returns the config in yaml format
type BhojpurGeneralConfig ¶
type BhojpurGeneralConfig struct { SameOwner bool `yaml:"same_owner,omitempty" mapstructure:"same_owner"` Concurrency int `yaml:"concurrency,omitempty" mapstructure:"concurrency"` Debug bool `yaml:"debug,omitempty" mapstructure:"debug"` ShowBuildOutput bool `yaml:"show_build_output,omitempty" mapstructure:"show_build_output"` FatalWarns bool `yaml:"fatal_warnings,omitempty" mapstructure:"fatal_warnings"` HTTPTimeout int `yaml:"http_timeout,omitempty" mapstructure:"http_timeout"` Quiet bool `yaml:"quiet" mapstructure:"quiet"` }
BhojpurGeneralConfig is the general configuration structure which applies to all the Bhojpur ISO actions
type BhojpurLoggingConfig ¶
type BhojpurLoggingConfig struct { // Path of the logfile Path string `yaml:"path" mapstructure:"path"` // Enable/Disable logging to file EnableLogFile bool `yaml:"enable_logfile" mapstructure:"enable_logfile"` // Enable JSON format logging in file JSONFormat bool `yaml:"json_format" mapstructure:"json_format"` // Log level Level string `yaml:"level" mapstructure:"level"` // Enable emoji EnableEmoji bool `yaml:"enable_emoji" mapstructure:"enable_emoji"` // Enable/Disable color in logging Color bool `yaml:"color" mapstructure:"color"` // NoSpinner disable spinner NoSpinner bool `yaml:"no_spinner" mapstructure:"no_spinner"` }
BhojpurLoggingConfig is the config relative to logging of Bhojpur ISO
type BhojpurRepositories ¶
type BhojpurRepositories []BhojpurRepository
func (BhojpurRepositories) Enabled ¶
func (l BhojpurRepositories) Enabled() (res BhojpurRepositories)
type BhojpurRepository ¶
type BhojpurRepository struct { Name string `json:"name" yaml:"name" mapstructure:"name"` Description string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description"` Urls []string `json:"urls" yaml:"urls" mapstructure:"urls"` Type string `json:"type" yaml:"type" mapstructure:"type"` Mode string `json:"mode,omitempty" yaml:"mode,omitempty" mapstructure:"mode,omitempty"` Priority int `json:"priority,omitempty" yaml:"priority,omitempty" mapstructure:"priority"` Enable bool `json:"enable" yaml:"enable" mapstructure:"enable"` Cached bool `json:"cached,omitempty" yaml:"cached,omitempty" mapstructure:"cached,omitempty"` Authentication map[string]string `json:"auth,omitempty" yaml:"auth,omitempty" mapstructure:"auth,omitempty"` TreePath string `json:"treepath,omitempty" yaml:"treepath,omitempty" mapstructure:"treepath"` MetaPath string `json:"metapath,omitempty" yaml:"metapath,omitempty" mapstructure:"metapath"` Verify bool `json:"verify,omitempty" yaml:"verify,omitempty" mapstructure:"verify"` Arch string `json:"arch,omitempty" yaml:"arch,omitempty" mapstructure:"arch"` ReferenceID string `json:"reference,omitempty" yaml:"reference,omitempty" mapstructure:"reference"` // Incremented value that identify revision of the repository in a user-friendly way. Revision int `json:"revision,omitempty" yaml:"-" mapstructure:"-"` // Epoch time in seconds LastUpdate string `json:"last_update,omitempty" yaml:"-" mapstructure:"-"` }
func LoadRepository ¶
func LoadRepository(data []byte) (*BhojpurRepository, error)
func NewBhojpurRepository ¶
func NewBhojpurRepository(name, t, descr string, urls []string, priority int, enable, cached bool) *BhojpurRepository
func NewEmptyBhojpurRepository ¶
func NewEmptyBhojpurRepository() *BhojpurRepository
func (*BhojpurRepository) Enabled ¶
func (r *BhojpurRepository) Enabled() bool
Enabled returns a boolean indicating if the repository should be considered enabled or not
func (*BhojpurRepository) String ¶
func (r *BhojpurRepository) String() string
type BhojpurSolverOptions ¶
type BhojpurSolverOptions struct { SolverOptions `yaml:"options,omitempty"` Type string `yaml:"type,omitempty" mapstructure:"type"` LearnRate float32 `yaml:"rate,omitempty" mapstructure:"rate"` Discount float32 `yaml:"discount,omitempty" mapstructure:"discount"` MaxAttempts int `yaml:"max_attempts,omitempty" mapstructure:"max_attempts"` Implementation SolverType `yaml:"implementation,omitempty" mapstructure:"implementation"` }
BhojpurSolverOptions this is the option struct for the Bhojpur ISO solver
func (*BhojpurSolverOptions) CompactString ¶
func (opts *BhojpurSolverOptions) CompactString() string
CompactString returns a compact string to display solver options over CLI
type BhojpurSystemConfig ¶
type BhojpurSystemConfig struct { DatabaseEngine string `yaml:"database_engine" mapstructure:"database_engine"` DatabasePath string `yaml:"database_path" mapstructure:"database_path"` Rootfs string `yaml:"rootfs" mapstructure:"rootfs"` PkgsCachePath string `yaml:"pkgs_cache_path" mapstructure:"pkgs_cache_path"` TmpDirBase string `yaml:"tmpdir_base" mapstructure:"tmpdir_base"` }
BhojpurSystemConfig is the system configuration. Typically this represent a host system that is about to perform operations on a Rootfs. Note all the fields needs to be in absolute form.
func (BhojpurSystemConfig) GetRepoDatabaseDirPath ¶
func (s BhojpurSystemConfig) GetRepoDatabaseDirPath(name string) string
GetRepoDatabaseDirPath is synatx sugar to return the repository path given a repository name in the system target
type Collection ¶
type Collection struct {
Packages []Package `json:"packages"`
}
type Context ¶
type Context interface { Logger GarbageCollector GetConfig() BhojpurConfig Copy() Context // SetAnnotation sets generic annotations to hold in a context SetAnnotation(s string, i interface{}) // GetAnnotation gets generic annotations to hold in a context GetAnnotation(s string) interface{} WithLoggingContext(s string) Context }
type FinalizerEnv ¶
type FinalizerEnv struct { Key string `json:"key" yaml:"key" mapstructure:"key"` Value string `json:"value" yaml:"value" mapstructure:"value"` }
FinalizerEnv represent a Key/Value environment to be set while running a package finalizer
type Finalizers ¶
type Finalizers []FinalizerEnv
Finalizers are a slice of K/V environments to set while running package finalizers
func (Finalizers) Slice ¶
func (f Finalizers) Slice() (sl []string)
Slice returns the finalizers as a string slice in k=v form.
type GarbageCollector ¶
type GarbageCollector interface { Clean() error TempDir(pattern string) (string, error) TempFile(s string) (*os.File, error) String() string }
GarbageCollector is a general garbage collector for temporary files It is responsible of assigning temporary files and cleaning up afterwards
type Logger ¶
type Logger interface { Info(...interface{}) Success(...interface{}) Warning(...interface{}) Warn(...interface{}) Debug(...interface{}) Error(...interface{}) Fatal(...interface{}) Panic(...interface{}) Trace(...interface{}) Infof(string, ...interface{}) Warnf(string, ...interface{}) Debugf(string, ...interface{}) Errorf(string, ...interface{}) Fatalf(string, ...interface{}) Panicf(string, ...interface{}) Tracef(string, ...interface{}) SpinnerStop() Spinner() Ask() bool Screen(string) }
Logger is a standard logging interface
type Package ¶
type Package struct { ID int `storm:"id,increment" json:"id"` // primary key with auto increment Name string `json:"name"` // Affects YAML field names too. Version string `json:"version"` // Affects YAML field names too. Category string `json:"category"` // Affects YAML field names too. UseFlags []string `json:"use_flags,omitempty"` // Affects YAML field names too. State State `json:"state,omitempty"` PackageRequires []*Package `json:"requires"` // Affects YAML field names too. PackageConflicts []*Package `json:"conflicts"` // Affects YAML field names too. Provides []*Package `json:"provides,omitempty"` // Affects YAML field names too. Hidden bool `json:"hidden,omitempty"` // Affects YAML field names too. // Annotations are used for core features/options Annotations map[PackageAnnotation]string `json:"annotations,omitempty"` // Affects YAML field names too // Path is set only internally when tree is loaded from disk Path string `json:"path,omitempty"` Description string `json:"description,omitempty"` Uri []string `json:"uri,omitempty"` License string `json:"license,omitempty"` BuildTimestamp string `json:"buildtimestamp,omitempty"` Labels map[string]string `json:"labels,omitempty"` // Affects YAML field names too. TreeDir string `json:"treedir,omitempty"` }
Package represent a standard package definition
func DecodePackage ¶
func DecodePackage(ID string, db PackageDatabase) (*Package, error)
func NewPackage ¶
NewPackage returns a new package
func PackageFromString ¶
func PackageFromYaml ¶
>> Unmarshallers PackageFromYaml decodes a package from yaml bytes
func PackagesFromYAML ¶
func (*Package) AddAnnotation ¶
func (*Package) AtomMatches ¶
func (*Package) BuildFormula ¶
func (pack *Package) BuildFormula(definitiondb PackageDatabase, db PackageDatabase) ([]bf.Formula, error)
func (*Package) BumpBuildVersion ¶
func (*Package) Encode ¶
func (p *Package) Encode(db PackageDatabase) (string, error)
Encode encodes the package to string. It returns an ID which can be used to retrieve the package later on.
func (*Package) GetBuildTimestamp ¶
GetBuildTimestamp returns the package build timestamp
func (*Package) GetCategory ¶
func (*Package) GetConflicts ¶
func (*Package) GetDescription ¶
func (*Package) GetFingerPrint ¶
GetFingerPrint returns a UUID of the package. FIXME: this needs to be unique, now just name is generalized
func (*Package) GetLicense ¶
func (*Package) GetMetadataFilePath ¶
GetMetadataFilePath returns the canonical name of an artifact metadata file
func (*Package) GetPackageName ¶
func (*Package) GetProvides ¶
func (*Package) GetRequires ¶
func (*Package) GetRuntimePackage ¶
func (*Package) GetTreeDir ¶
func (*Package) GetVersion ¶
func (*Package) HashFingerprint ¶
func (*Package) HumanReadableString ¶
func (Package) IsCollection ¶
func (*Package) IsSelector ¶
func (*Package) JSON ¶
JSON returns the package in JSON form. Note this function sets a specific encoder as major and minor gets escaped when marshalling in JSON, making compiler fails recognizing selectors for expansion
func (*Package) LabelDeps ¶
func (p *Package) LabelDeps(definitiondb PackageDatabase, labelKey string) Packages
func (*Package) Related ¶
func (p *Package) Related(definitiondb PackageDatabase) Packages
func (*Package) RequiresContains ¶
func (pack *Package) RequiresContains(definitiondb PackageDatabase, s *Package) (bool, error)
RequiresContains recursively scans into the database packages dependencies to find a match with the given package It is used by the solver during uninstall.
func (*Package) Revdeps ¶
func (p *Package) Revdeps(definitiondb PackageDatabase) Packages
func (*Package) SelectorMatchVersion ¶
func (*Package) SetBuildTimestamp ¶
SetBuildTimestamp sets the package Build timestamp
func (*Package) SetCategory ¶
func (*Package) SetDescription ¶
func (*Package) SetLicense ¶
func (*Package) SetProvides ¶
func (*Package) SetTreeDir ¶
func (*Package) SetVersion ¶
func (*Package) VersionMatchSelector ¶
type PackageAnnotation ¶
type PackageAnnotation string
const (
ConfigProtectAnnotation PackageAnnotation = "config_protect"
)
type PackageAssert ¶
type PackageAssert struct { Package *Package Value bool Hash PackageHash }
PackageAssert represent a package assertion. It is composed of a Package and a Value which is indicating the absence or not of the associated package state.
func (*PackageAssert) String ¶
func (a *PackageAssert) String() string
type PackageDatabase ¶
type PackageDatabase interface { PackageSet Get(s string) (string, error) Set(k, v string) error Create(string, []byte) (string, error) Retrieve(ID string) ([]byte, error) }
Database is a merely simple in-memory db. FIXME: Use a proper structure or delegate to third-party
type PackageFile ¶
type PackageHash ¶
type PackageMap ¶
func (PackageMap) String ¶
func (pm PackageMap) String() string
type PackageResolver ¶
type PackageResolver interface {
Solve(bf.Formula, PackageSolver) (PackagesAssertions, error)
}
PackageResolver assists PackageSolver on unsat cases
type PackageSet ¶
type PackageSet interface { Clone(PackageDatabase) error Copy() (PackageDatabase, error) GetRevdeps(p *Package) (Packages, error) GetPackages() []string //Ids CreatePackage(pkg *Package) (string, error) GetPackage(ID string) (*Package, error) Clean() error FindPackage(*Package) (*Package, error) FindPackages(p *Package) (Packages, error) UpdatePackage(p *Package) error GetAllPackages(packages chan *Package) error RemovePackage(*Package) error GetPackageFiles(*Package) ([]string, error) SetPackageFiles(*PackageFile) error RemovePackageFiles(*Package) error FindPackageVersions(p *Package) (Packages, error) World() Packages FindPackageCandidate(p *Package) (*Package, error) FindPackageLabel(labelKey string) (Packages, error) FindPackageLabelMatch(pattern string) (Packages, error) FindPackageMatch(pattern string) (Packages, error) FindPackageByFile(pattern string) (Packages, error) }
type PackageSolver ¶
type PackageSolver interface { SetDefinitionDatabase(PackageDatabase) Install(p Packages) (PackagesAssertions, error) RelaxedInstall(p Packages) (PackagesAssertions, error) Uninstall(checkconflicts, full bool, candidate ...*Package) (Packages, error) ConflictsWithInstalled(p *Package) (bool, error) ConflictsWith(p *Package, ls Packages) (bool, error) Conflicts(pack *Package, lsp Packages) (bool, error) World() Packages Upgrade(checkconflicts, full bool) (Packages, PackagesAssertions, error) UpgradeUniverse(dropremoved bool) (Packages, PackagesAssertions, error) UninstallUniverse(toremove Packages) (Packages, error) SetResolver(PackageResolver) Solve() (PackagesAssertions, error) }
PackageSolver is an interface to a generic package solving algorithm
type Packages ¶
type Packages []*Package
type PackagesAssertions ¶
type PackagesAssertions []PackageAssert
func (PackagesAssertions) AssertionHash ¶
func (assertions PackagesAssertions) AssertionHash() string
func (PackagesAssertions) Cut ¶
func (assertions PackagesAssertions) Cut(p *Package) PackagesAssertions
Cut returns an assertion list of installed (filter by Value) "cutted" until the package is found (included)
func (PackagesAssertions) Drop ¶
func (assertions PackagesAssertions) Drop(p *Package) PackagesAssertions
func (PackagesAssertions) EnsureOrder ¶
func (assertions PackagesAssertions) EnsureOrder() PackagesAssertions
func (PackagesAssertions) HashFrom ¶
func (assertions PackagesAssertions) HashFrom(p *Package) string
HashFrom computes the assertion hash From a given package. It drops it from the assertions and checks it's not the only one. if it's unique it marks it specially - so the hash which is generated is unique for the selected package
func (PackagesAssertions) Len ¶
func (a PackagesAssertions) Len() int
func (PackagesAssertions) Less ¶
func (a PackagesAssertions) Less(i, j int) bool
func (PackagesAssertions) Mark ¶
func (assertions PackagesAssertions) Mark(p *Package) PackagesAssertions
Mark returns a new assertion with the package marked
func (PackagesAssertions) Order ¶
func (assertions PackagesAssertions) Order(definitiondb PackageDatabase, fingerprint string) (PackagesAssertions, error)
func (PackagesAssertions) SaltedAssertionHash ¶
func (assertions PackagesAssertions) SaltedAssertionHash(salts map[string]string) string
func (PackagesAssertions) SaltedHashFrom ¶
func (assertions PackagesAssertions) SaltedHashFrom(p *Package, salts map[string]string) string
func (PackagesAssertions) Search ¶
func (assertions PackagesAssertions) Search(f string) *PackageAssert
func (PackagesAssertions) SearchByName ¶
func (assertions PackagesAssertions) SearchByName(f string) *PackageAssert
SearchByName searches a string matching a package in the assetion list in the category/name format
func (PackagesAssertions) Swap ¶
func (a PackagesAssertions) Swap(i, j int)
func (PackagesAssertions) TrueLen ¶
func (assertions PackagesAssertions) TrueLen() int
TrueLen returns the lenth of true assertions in the slice
type SolverOptions ¶
type SolverOptions struct { Type SolverType `yaml:"type,omitempty"` Concurrency int `yaml:"concurrency,omitempty"` }