config

package
v0.40.1-geaaru Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: GPL-3.0 Imports: 13 Imported by: 2

Documentation

Overview

Copyright © 2021-2023 Macaroni OS Linux See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2021-2023 Macaroni OS Linux See AUTHORS and LICENSE for the license details and contributors.

Index

Constants

View Source
const (
	LuetVersion     = "0.40.1"
	LuetEnvPrefix   = "LUET"
	LuetForkVersion = "geaaru"
)

Variables

View Source
var (
	BuildTime      string
	BuildCommit    string
	BuildGoVersion string
)

Functions

func GenDefault

func GenDefault(viper *v.Viper)

Types

type ConfigProtect

type ConfigProtect struct {
	AnnotationDir string
	MapProtected  map[string]bool
}

func NewConfigProtect

func NewConfigProtect(annotationDir string) *ConfigProtect

func (*ConfigProtect) AddAnnotationDir

func (c *ConfigProtect) AddAnnotationDir(d string)

func (*ConfigProtect) GetAnnotationDir

func (c *ConfigProtect) GetAnnotationDir() string

func (*ConfigProtect) GetProtectFiles

func (c *ConfigProtect) GetProtectFiles(withSlash bool) []string

func (*ConfigProtect) Map

func (c *ConfigProtect) Map(files []string)

func (*ConfigProtect) Protected

func (c *ConfigProtect) Protected(file string) bool

type ConfigProtectConfFile

type ConfigProtectConfFile struct {
	Filename string

	Name        string   `mapstructure:"name" yaml:"name" json:"name"`
	Directories []string `mapstructure:"dirs" yaml:"dirs" json:"dirs"`
}

func NewConfigProtectConfFile

func NewConfigProtectConfFile(filename string) *ConfigProtectConfFile

func (*ConfigProtectConfFile) String

func (c *ConfigProtectConfFile) String() string

type LuetConfig

type LuetConfig struct {
	Viper *v.Viper `yaml:"-"`

	Logging  LuetLoggingConfig  `yaml:"logging,omitempty" mapstructure:"logging"`
	General  LuetGeneralConfig  `yaml:"general,omitempty" mapstructure:"general"`
	System   LuetSystemConfig   `yaml:"system" mapstructure:"system"`
	Solver   LuetSolverOptions  `yaml:"solver,omitempty" mapstructure:"solver"`
	TarFlows LuetTarflowsConfig `yaml:"tar_flows,omitempty" mapstructure:"tar_flows,omitempty"`

	RepositoriesConfDir  []string         `yaml:"repos_confdir,omitempty" mapstructure:"repos_confdir"`
	ConfigProtectConfDir []string         `yaml:"config_protect_confdir,omitempty" mapstructure:"config_protect_confdir"`
	PackagesMaskDir      []string         `yaml:"packages_maskdir,omitempty" mapstructure:"packages_maskdir,omitempty"`
	ConfigProtectSkip    bool             `yaml:"config_protect_skip,omitempty" mapstructure:"config_protect_skip"`
	ConfigFromHost       bool             `yaml:"config_from_host,omitempty" mapstructure:"config_from_host"`
	CacheRepositories    []LuetRepository `yaml:"repetitors,omitempty" mapstructure:"repetitors"`
	SystemRepositories   []LuetRepository `yaml:"repositories,omitempty" mapstructure:"repositories"`

	FinalizerEnvs []LuetKV `json:"finalizer_envs,omitempty" yaml:"finalizer_envs,omitempty" mapstructure:"finalizer_envs,omitempty"`

	ConfigProtectConfFiles []ConfigProtectConfFile `yaml:"-" mapstructure:"-"`

	// Subsets config directories for users override.
	SubsetsConfDir []string          `yaml:"subsets_confdir,omitempty" mapstructure:"subsets_confdir"`
	SubsetsDefDir  []string          `yaml:"subsets_defdir,omitempty" mapstructure:"subsets_defdir"`
	Subsets        LuetSubsetsConfig `yaml:"subsets,omitempty" mapstructure:"subsets"`

	SubsetsDefinitions *LuetSubsetsDefinition            `yaml:"-" mapstructure:"-"`
	SubsetsPkgsDefMap  map[string]*LuetSubsetsDefinition `yaml:"-" mapstructure:"-"`
	SubsetsCatDefMap   map[string]*LuetSubsetsDefinition `yaml:"-" mapstructure:"-"`
}
var LuetCfg *LuetConfig = NewLuetConfig(nil)

func NewLuetConfig

func NewLuetConfig(viper *v.Viper) *LuetConfig

func (*LuetConfig) AddConfigProtectConfFile

func (c *LuetConfig) AddConfigProtectConfFile(file *ConfigProtectConfFile)

func (*LuetConfig) AddSystemRepository

func (c *LuetConfig) AddSystemRepository(r *LuetRepository)

func (*LuetConfig) GetConfigProtectConfFiles

func (c *LuetConfig) GetConfigProtectConfFiles() []ConfigProtectConfFile

func (*LuetConfig) GetFinalizerEnv

func (c *LuetConfig) GetFinalizerEnv(k string) (string, error)

func (*LuetConfig) GetFinalizerEnvs

func (c *LuetConfig) GetFinalizerEnvs() []string

func (*LuetConfig) GetFinalizerEnvsMap

func (c *LuetConfig) GetFinalizerEnvsMap() map[string]string

func (*LuetConfig) GetGeneral

func (c *LuetConfig) GetGeneral() *LuetGeneralConfig

func (*LuetConfig) GetLockFilePath

func (c *LuetConfig) GetLockFilePath(lockfile string) string

func (*LuetConfig) GetLogging

func (c *LuetConfig) GetLogging() *LuetLoggingConfig

func (*LuetConfig) GetSolverOptions

func (c *LuetConfig) GetSolverOptions() *LuetSolverOptions

func (*LuetConfig) GetSystem

func (c *LuetConfig) GetSystem() *LuetSystemConfig

func (*LuetConfig) GetSystemDB

func (c *LuetConfig) GetSystemDB() pkg.PackageDatabase

func (*LuetConfig) GetSystemRepository

func (c *LuetConfig) GetSystemRepository(name string) (*LuetRepository, error)

func (*LuetConfig) GetTarFlows

func (c *LuetConfig) GetTarFlows() *LuetTarflowsConfig

func (*LuetConfig) SetFinalizerEnv

func (c *LuetConfig) SetFinalizerEnv(k, v string)

func (*LuetConfig) YAML

func (c *LuetConfig) YAML() ([]byte, error)

type LuetGeneralConfig

type LuetGeneralConfig struct {
	SameOwner       bool `yaml:"same_owner,omitempty" json:"same_owner,omitempty" mapstructure:"same_owner"`
	Concurrency     int  `yaml:"concurrency,omitempty" json:"concurrency,omitempty" mapstructure:"concurrency"`
	Debug           bool `yaml:"debug,omitempty" json:"debug,omitempty" mapstructure:"debug"`
	ShowBuildOutput bool `yaml:"show_build_output,omitempty" json:"show_build_output,omitempty" mapstructure:"show_build_output"`
	SpinnerMs       int  `yaml:"spinner_ms,omitempty" json:"spinner_ms,omitempty" mapstructure:"spinner_ms"`
	SpinnerCharset  int  `yaml:"spinner_charset,omitempty" json:"spinner_charset,omitempty" mapstructure:"spinner_charset"`
	FatalWarns      bool `yaml:"fatal_warnings,omitempty" json:"fatal_warnings,omitempty" mapstructure:"fatal_warnings"`

	ClientTimeout    int `yaml:"client_timeout,omitempty" json:"client_timeout,omitempty" mapstructure:"client_timeout,omitempty"`
	ClientMultiFetch int `yaml:"client_multifetch,omitempty" json:"client_multifetch,omitempty" mapstructure:"client_multifetch,omitempty"`

	OverwriteDirPerms bool `yaml:"overwrite_dir_perms,omitempty" json:"overwrite_dir_perms,omitempty" mapstructure:"overwrite_dir_perms,omitempty"`
}

func (*LuetGeneralConfig) GetSpinnerMs

func (c *LuetGeneralConfig) GetSpinnerMs() time.Duration

type LuetKV

type LuetKV struct {
	Key   string `json:"key" yaml:"key" mapstructure:"key"`
	Value string `json:"value" yaml:"value" mapstructure:"value"`
}

type LuetLoggingConfig

type LuetLoggingConfig struct {
	// Path of the logfile
	Path string `yaml:"path,omitempty" json:"path,omitempty" mapstructure:"path"`
	// Enable/Disable logging to file
	EnableLogFile bool `yaml:"enable_logfile,omitempty" json:"enable_logfile,omitempty" mapstructure:"enable_logfile"`
	// Enable JSON format logging in file
	JsonFormat bool `yaml:"json_format,omitempty" json:"json_format,omitempty" mapstructure:"json_format"`

	// Log level
	Level string `yaml:"level,omitempty" json:"level,omitempty" mapstructure:"level"`
	// Enable extra debug logging
	Paranoid bool `yaml:"paranoid,omitempty" json:"paranoid,omitempty" mapstructure:"paranoid"`

	// Enable emoji
	EnableEmoji bool `yaml:"enable_emoji,omitempty" json:"enable_emoji,omitempty" mapstructure:"enable_emoji"`
	// Enable/Disable color in logging
	Color bool `yaml:"color,omitempty" json:"color,omitempty" mapstructure:"color"`
}

func (*LuetLoggingConfig) SetLogLevel

func (c *LuetLoggingConfig) SetLogLevel(s string)

type LuetRepository

type LuetRepository 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"`

	// Incremented value that identify revision of the repository in a user-friendly way.
	Revision int `json:"revision,omitempty" yaml:"revision,omitempty" mapstructure:"-"`
	// Epoch time in seconds
	LastUpdate string `json:"last_update,omitempty" yaml:"last_update,omitempty" mapstructure:"-"`

	File string `json:"-" yaml:"-" mapstructure:"-"`
}

func NewEmptyLuetRepository

func NewEmptyLuetRepository() *LuetRepository

func NewLuetRepository

func NewLuetRepository(name, t, descr string, urls []string, priority int, enable, cached bool) *LuetRepository

func (*LuetRepository) Clone

func (r *LuetRepository) Clone() *LuetRepository

func (*LuetRepository) String

func (r *LuetRepository) String() string

func (*LuetRepository) YAML

func (r *LuetRepository) YAML() ([]byte, error)

type LuetSolverOptions

type LuetSolverOptions struct {
	Type           string  `yaml:"type,omitempty" json:"type,omitempty" mapstructure:"type"`
	LearnRate      float32 `yaml:"rate,omitempty" json:"rate,omitempty" mapstructure:"rate"`
	Discount       float32 `yaml:"discount,omitempty" json:"discount,omitempty" mapstructure:"discount"`
	MaxAttempts    int     `yaml:"max_attempts,omitempty" json:"max_attempts,omitempty" mapstructure:"max_attempts"`
	Implementation string  `yaml:"implementation,omitempty" json:"implementation,omitempty" mapstructure:"implementation"`
}

func (*LuetSolverOptions) CompactString

func (opts *LuetSolverOptions) CompactString() string

type LuetSubsetDefinition

type LuetSubsetDefinition struct {
	Description string   `yaml:"descr,omitempty" mapstructure:"descr"`
	Name        string   `yaml:"name,omitempty" mapstructure:"name"`
	Rules       []string `yaml:"rules,omitempty" mapstructure:"rules"`

	Packages   []string `yaml:"packages,omitempty" mapstructure:"packages"`
	Categories []string `yaml:"categories,omitempty" mapstructure:"categories"`
}

type LuetSubsetsConfig

type LuetSubsetsConfig struct {
	Enabled []string `yaml:"enabled,omitempty" mapstructure:"enabled"`
}

func NewLuetSubsetsConfig

func NewLuetSubsetsConfig() *LuetSubsetsConfig

func NewSubsetsConfig

func NewSubsetsConfig(data []byte) (*LuetSubsetsConfig, error)

func NewSubsetsConfigFromFile

func NewSubsetsConfigFromFile(f string) (*LuetSubsetsConfig, error)

func (*LuetSubsetsConfig) AddSubset

func (c *LuetSubsetsConfig) AddSubset(s string)

func (*LuetSubsetsConfig) DelSubset

func (c *LuetSubsetsConfig) DelSubset(s string)

func (*LuetSubsetsConfig) HasSubset

func (c *LuetSubsetsConfig) HasSubset(s string) bool

func (*LuetSubsetsConfig) Write

func (c *LuetSubsetsConfig) Write(f string) error

type LuetSubsetsDefinition

type LuetSubsetsDefinition struct {
	Definitions map[string]*LuetSubsetDefinition `yaml:"subsets_def,omitempty" mapstructure:"subsets_def,omitempty" json:"subsets_def,omitempty"`
}

func NewLuetSubsetsDefinition

func NewLuetSubsetsDefinition() *LuetSubsetsDefinition

type LuetSystemConfig

type LuetSystemConfig struct {
	DatabaseEngine string `yaml:"database_engine" json:"database_engine,omitempty" mapstructure:"database_engine"`
	DatabasePath   string `yaml:"database_path" json:"database_path" mapstructure:"database_path"`
	Rootfs         string `yaml:"rootfs" json:"rootfs" mapstructure:"rootfs"`
	PkgsCachePath  string `yaml:"pkgs_cache_path" json:"pkgs_cache_path" mapstructure:"pkgs_cache_path"`
	TmpDirBase     string `yaml:"tmpdir_base" json:"tmpdir_base" mapstructure:"tmpdir_base"`
}

func (*LuetSystemConfig) CleanupTmpDir

func (c *LuetSystemConfig) CleanupTmpDir() error

func (*LuetSystemConfig) GetRepoDatabaseDirPath

func (sc *LuetSystemConfig) GetRepoDatabaseDirPath(name string) string

func (*LuetSystemConfig) GetRootFsAbs

func (sc *LuetSystemConfig) GetRootFsAbs() (string, error)

func (*LuetSystemConfig) GetSystemPkgsCacheDirPath

func (sc *LuetSystemConfig) GetSystemPkgsCacheDirPath() (ans string)

func (*LuetSystemConfig) GetSystemRepoDatabaseDirPath

func (sc *LuetSystemConfig) GetSystemRepoDatabaseDirPath() string

func (*LuetSystemConfig) GetSystemReposDirPath

func (sc *LuetSystemConfig) GetSystemReposDirPath() string

func (*LuetSystemConfig) InitTmpDir

func (c *LuetSystemConfig) InitTmpDir() error

func (*LuetSystemConfig) SetRootFS

func (s *LuetSystemConfig) SetRootFS(path string) error

func (*LuetSystemConfig) TempDir

func (c *LuetSystemConfig) TempDir(pattern string) (string, error)

func (*LuetSystemConfig) TempFile

func (c *LuetSystemConfig) TempFile(pattern string) (*os.File, error)

type LuetTarflowsConfig

type LuetTarflowsConfig struct {
	CopyBufferSize int   `yaml:"copy_buffer_size,omitempty" mapstructure:"copy_buffer_size,omitempty"`
	MaxOpenFiles   int64 `yaml:"max_openfiles,omitempty" mapstructure:"max_openfiles,omitempty"`
	Mutex4Dirs     bool  `yaml:"mutex4dir,omitempty" mapstructure:"mutex4dir,omitempty"`
	Validate       bool  `yaml:"validate,omitempty" mapstructure:"validate,omitempty"`
}

Jump to

Keyboard shortcuts

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