types

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: MIT Imports: 28 Imported by: 1

Documentation

Index

Constants

View Source
const (
	PackageMetaSuffix     = "metadata.yaml"
	PackageCollectionFile = "collection.yaml"
	PackageDefinitionFile = "definition.yaml"
)

Variables

This section is empty.

Functions

func GetRawPackages

func GetRawPackages(yml []byte) (rawPackages, error)

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

func NewPackage(name, version string, requires []*Package, conflicts []*Package) *Package

NewPackage returns a new package

func PackageFromString

func PackageFromString(s string) *Package

func PackageFromYaml

func PackageFromYaml(yml []byte) (Package, error)

>> Unmarshallers PackageFromYaml decodes a package from yaml bytes

func PackagesFromYAML

func PackagesFromYAML(yml []byte) ([]Package, error)

func (*Package) AddAnnotation

func (p *Package) AddAnnotation(k, v string)

func (*Package) AddLabel

func (p *Package) AddLabel(k, v string)

func (*Package) AddURI

func (p *Package) AddURI(s string)

func (*Package) AddUse

func (p *Package) AddUse(use string)

AddUse adds a use to a package

func (*Package) AtomMatches

func (p *Package) AtomMatches(m *Package) bool

func (*Package) BuildFormula

func (pack *Package) BuildFormula(definitiondb PackageDatabase, db PackageDatabase) ([]bf.Formula, error)

func (*Package) BumpBuildVersion

func (p *Package) BumpBuildVersion() error

func (*Package) Clone

func (p *Package) Clone() *Package

func (*Package) Conflicts

func (p *Package) Conflicts(req []*Package) *Package

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) Expand

func (p *Package) Expand(definitiondb PackageDatabase) (Packages, error)

func (*Package) Explain

func (p *Package) Explain()

func (*Package) GetBuildTimestamp

func (p *Package) GetBuildTimestamp() string

GetBuildTimestamp returns the package build timestamp

func (*Package) GetCategory

func (p *Package) GetCategory() string

func (*Package) GetConflicts

func (p *Package) GetConflicts() []*Package

func (*Package) GetDescription

func (p *Package) GetDescription() string

func (*Package) GetFingerPrint

func (p *Package) GetFingerPrint() string

GetFingerPrint returns a UUID of the package. FIXME: this needs to be unique, now just name is generalized

func (*Package) GetLabels

func (p *Package) GetLabels() map[string]string

func (*Package) GetLicense

func (p *Package) GetLicense() string

func (*Package) GetMetadataFilePath

func (d *Package) GetMetadataFilePath() string

GetMetadataFilePath returns the canonical name of an artifact metadata file

func (*Package) GetName

func (p *Package) GetName() string

func (*Package) GetPackageName

func (p *Package) GetPackageName() string

func (*Package) GetPath

func (p *Package) GetPath() string

GetPath returns the path where the definition file was found

func (*Package) GetProvides

func (p *Package) GetProvides() []*Package

func (*Package) GetRequires

func (p *Package) GetRequires() []*Package

func (*Package) GetRuntimePackage

func (p *Package) GetRuntimePackage() (*Package, error)

func (*Package) GetTreeDir

func (p *Package) GetTreeDir() string

func (*Package) GetURI

func (p *Package) GetURI() []string

func (*Package) GetUses

func (p *Package) GetUses() []string

func (*Package) GetVersion

func (p *Package) GetVersion() string

func (*Package) HasLabel

func (p *Package) HasLabel(label string) (b bool)

func (*Package) HashFingerprint

func (p *Package) HashFingerprint(salt string) string

func (*Package) HumanReadableString

func (p *Package) HumanReadableString() string

func (*Package) ImageID

func (p *Package) ImageID() string

func (Package) IsCollection

func (p Package) IsCollection() bool

func (*Package) IsHidden

func (p *Package) IsHidden() bool

func (*Package) IsSelector

func (p *Package) IsSelector() bool

func (*Package) JSON

func (t *Package) JSON() ([]byte, error)

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) Mark

func (p *Package) Mark() *Package

func (*Package) MatchAnnotation

func (p *Package) MatchAnnotation(r *regexp.Regexp) (b bool)

func (*Package) MatchLabel

func (p *Package) MatchLabel(r *regexp.Regexp) (b bool)

func (*Package) Matches

func (p *Package) Matches(m *Package) bool

func (*Package) Rel

func (p *Package) Rel(s string) string

func (*Package) Related

func (p *Package) Related(definitiondb PackageDatabase) Packages

func (*Package) RemoveUse

func (p *Package) RemoveUse(use string)

RemoveUse removes a use to a package

func (*Package) Requires

func (p *Package) Requires(req []*Package) *Package

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 (p *Package) SelectorMatchVersion(ver string, v version.Versioner) (bool, error)

func (*Package) SetBuildTimestamp

func (p *Package) SetBuildTimestamp(s string)

SetBuildTimestamp sets the package Build timestamp

func (*Package) SetCategory

func (p *Package) SetCategory(s string)

func (*Package) SetDescription

func (p *Package) SetDescription(s string)

func (*Package) SetLicense

func (p *Package) SetLicense(s string)

func (*Package) SetName

func (p *Package) SetName(s string)

func (*Package) SetPath

func (p *Package) SetPath(s string)

func (*Package) SetProvides

func (p *Package) SetProvides(req []*Package) *Package

func (*Package) SetTreeDir

func (p *Package) SetTreeDir(s string)

func (*Package) SetVersion

func (p *Package) SetVersion(v string)

func (*Package) String

func (p *Package) String() string

func (*Package) VersionMatchSelector

func (p *Package) VersionMatchSelector(selector string, v version.Versioner) (bool, error)

func (*Package) Yaml

func (p *Package) Yaml() ([]byte, error)

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 PackageFile struct {
	ID                 int `storm:"id,increment"` // primary key with auto increment
	PackageFingerprint string
	Files              []string
}

type PackageHash

type PackageHash struct {
	BuildHash   string
	PackageHash string
}

type PackageMap

type PackageMap map[string]*Package

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

func (Packages) Best

func (set Packages) Best(v version.Versioner) *Package

Best returns the best version of the package (the most bigger) from a list Accepts a versioner interface to change the ordering policy. If null is supplied It defaults to version.WrappedVersioner which supports both semver and debian versioning

func (Packages) Find

func (set Packages) Find(packageName string) (*Package, error)

func (Packages) Hash

func (d Packages) Hash(salt string) string

func (Packages) Unique

func (set Packages) Unique() Packages

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"`
}

type SolverType

type SolverType int
const (
	SolverSingleCoreSimple SolverType = 0
)

type State

type State string

State represent the package state

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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