Documentation
¶
Overview ¶
Package king provides high-level interfaces to interact with kiss-compatible package system
Index ¶
- Variables
- type Alternative
- type AlternativeOptions
- type BuildOptions
- type Config
- type ConfigOptions
- type Dependency
- type DownloadOptions
- type Downloader
- type Extractor
- type File
- type Git
- type HTTP
- func (h *HTTP) Download(do *DownloadOptions) error
- func (h *HTTP) DownloadContext(ctx context.Context, do *DownloadOptions) error
- func (h *HTTP) Extract(d string) error
- func (h *HTTP) ExtractDir() string
- func (h *HTTP) Sha256() (string, error)
- func (h *HTTP) String() string
- func (h *HTTP) Verify() error
- type InstallOptions
- type Package
- func (p *Package) Build(bo *BuildOptions) (*Tarball, error)
- func (p *Package) BuildContext(ctx context.Context, bo *BuildOptions) (*Tarball, error)
- func (p *Package) Dependencies() ([]*Dependency, error)
- func (p *Package) RecursiveDependencies() ([]*Dependency, error)
- func (p *Package) Remove(ro *RemoveOptions) error
- func (p *Package) ReverseDependencies() ([]string, error)
- func (p *Package) Sources() ([]Source, error)
- func (p *Package) String() string
- func (p *Package) Tarball() (*Tarball, error)
- func (p *Package) Version() (*Version, error)
- type PackageOptions
- type RemoveOptions
- type RepositoryType
- type Source
- type Tarball
- type UpdateOptions
- type Verifier
- type Version
Constants ¶
This section is empty.
Variables ¶
var ( ErrPackagePathNotFound = errors.New("target not owned by any package") ErrPackageNameNotFound = errors.New("target not found in database/repository") )
var ( ErrSourceGitSchemeInvalid = errors.New("target scheme cannot be file") ErrSourceGitHashInvalid = errors.New("target contains invalid commit hash") ErrSourceHTTPSchemeInvalid = errors.New("target scheme must be a http or https") ErrSourceFileNotFound = errors.New("target not found in relative or absolute location") )
var ( ErrTarballNotFound = errors.New("target has not been built yet") ErrTarballNotRegular = errors.New("target must be a regular file") ErrTarballInvalid = errors.New("target has no separator") )
var ( ErrAlternativePathDirectory = errors.New("Path cannot be a directory") ErrAlternativePathNotAbsolute = errors.New("Path must be absolute") ErrAlternativePathEmpty = errors.New("Path must be set") ErrBuildCompressionNotSupported = errors.New("Compression contains an unsupported format") ErrBuildPackageDirEmpty = errors.New("PackageDir must be set") ErrBuildBuildDirEmpty = errors.New("BuildDir must be set") ErrConfigRootDirNotDirectory = errors.New("RootDir must be a directory") ErrConfigAlternativeDirEmpty = errors.New("AlternativeDir must be set") ErrConfigDatabaseDirEmpty = errors.New("DatabaseDir must be set") ErrConfigSourceDirEmpty = errors.New("SourceDir must be set") ErrConfigBinaryDirEmpty = errors.New("BinaryDir must be set") ErrInstallExtractDirEmpty = errors.New("ExtractDir must be set") ErrPackagePathNameExclusive = errors.New("Path and Name are mutually exclusive") )
var ( ErrSha256NotRegular = errors.New("target must be a regular file") ErrVerifyMismatch = errors.New("checksum mismatch") )
var ErrAlternativeNotFound = errors.New("conflict has not been occured yet")
var ErrDownloadAlreadyExist = errors.New("target already downloaded")
var ErrInstallUnmetDependencies = errors.New("target requires other packages")
var ErrRemoveUnresolvedDependencies = errors.New("other packages depend on target")
var ErrReverseDependenciesNotFound = errors.New("no package depends on target")
var ErrVersionInvalid = errors.New("target must contain only two fields")
Functions ¶
This section is empty.
Types ¶
type Alternative ¶
Alternative represents conflict between multiple packages.
See https://k1sslinux.org/package-manager#3.2
func Alternatives ¶
func Alternatives(c *Config) ([]*Alternative, error)
func NewAlternative ¶
func NewAlternative(c *Config, ao *AlternativeOptions) (*Alternative, error)
func (*Alternative) String ¶
func (a *Alternative) String() string
func (*Alternative) Swap ¶
func (a *Alternative) Swap() (*Alternative, error)
type AlternativeOptions ¶
func (*AlternativeOptions) Validate ¶
func (ao *AlternativeOptions) Validate() error
type BuildOptions ¶
type BuildOptions struct { // Output points where build log will be written. Output io.Writer // Compression defines which compression format will be used to create tarball. // // TODO allow none format // Valid formats are sz, br, gz, xz, zst, bz2, lz4. Compression string // TODO mention that p.Name is appended // BuildDir specifies where build will happen. BuildDir string // TODO mention that p.Name is appended // PackageDir specifies where build script places package files // to turn them into tarball later. PackageDir string // Debug preserves BuildDir and PackageDir. Useful for debugging purposes. Debug bool }
BuildOptions provides facilities for building package.
func (*BuildOptions) Validate ¶
func (bo *BuildOptions) Validate() error
type Config ¶
type Config struct { // Repositories contains list of user-defined repositories. Repositories []string // DatabaseDir contains path with prepended RootDir to installed packages. DatabaseDir string // AlternativeDir contains path with prepended RootDir to occurred conflicts. AlternativeDir string // BinaryDir contains path to pre-built packages. BinaryDir string // SourceDir contains path to package sources. SourceDir string // RootDir contains path to real root. RootDir string // contains filtered or unexported fields }
Config represents in-memory copy of configuration.
See https://k1sslinux.org/package-manager#4.0 TODO embed ConfigOptions TODO add SystemPackages[musl, pkgconf, ...]
func NewConfig ¶
func NewConfig(co *ConfigOptions) (*Config, error)
NewConfig allocates new instance of configuration.
func (*Config) ResetOwnedPaths ¶
func (c *Config) ResetOwnedPaths()
ResetOwnedPaths resets cached manifests of installed packages.
func (*Config) ResetReverseDependencies ¶
func (c *Config) ResetReverseDependencies()
ResetReverseDependencies resets cached reverse dependencies.
type ConfigOptions ¶
type ConfigOptions struct { // Repositories contains list of user-defined repositories. Repositories []string // AlternativeDir contains path with prepended RootDir to occurred conflicts. AlternativeDir string // DatabaseDir contains path with prepended RootDir to installed packages. DatabaseDir string // BinaryDir points where pre-built packages will be located. BinaryDir string // SourceDir points where sources of packages will be downloaded. SourceDir string // RootDir intended to specify real root of filesystem. Default is '/'. // Useful to bootstrap new system. RootDir string }
ConfigOptions allows to configure returned configuration.
func (*ConfigOptions) Validate ¶
func (co *ConfigOptions) Validate() error
type Dependency ¶
Dependency represents dependency of package.
See https://k1sslinux.org/package-system#3.0
func (*Dependency) String ¶
func (d *Dependency) String() string
type DownloadOptions ¶
func (*DownloadOptions) Validate ¶
func (do *DownloadOptions) Validate() error
type Downloader ¶
type Downloader interface { Download(do *DownloadOptions) error DownloadContext(ctx context.Context, do *DownloadOptions) error }
type File ¶
type File struct { Path string // contains filtered or unexported fields }
File represents absolute or relative (to the path of package) file source.
func (*File) ExtractDir ¶
ExtractDir returns extraction directory (second field within sources file)
type Git ¶
type Git struct { URL string // contains filtered or unexported fields }
Git represents git source.
func (*Git) ExtractDir ¶
ExtractDir returns extraction directory (second field within sources file)
type HTTP ¶
type HTTP struct { URL string // contains filtered or unexported fields }
HTTP represents source that can be downloaded.
func (*HTTP) Download ¶
func (h *HTTP) Download(do *DownloadOptions) error
func (*HTTP) DownloadContext ¶
func (h *HTTP) DownloadContext(ctx context.Context, do *DownloadOptions) error
func (*HTTP) Extract ¶
Extract copies (or extracts - it depends on ?no-extract flag) source into specified directory.
func (*HTTP) ExtractDir ¶
ExtractDir returns extraction directory (second field within sources file)
type InstallOptions ¶
type InstallOptions struct { // NoCheckDependencies forcefully installs package without // checking if dependencies are met. NoCheckDependencies bool // OverwriteEtcFiles overwrites /etc/* files without special handling. // // See https://k1sslinux.org/package-manager#3.3 OverwriteEtcFiles bool // TODO mention that t.Name is appended // ExtractDir specifies where pre-built package will be extracted. ExtractDir string // Debug preserves ExtractDir. Useful for debugging purposes. Debug bool }
InstallOptions provides facilities for installing package.
func (*InstallOptions) Validate ¶
func (lo *InstallOptions) Validate() error
type Package ¶
type Package struct { Name string Path string From RepositoryType // contains filtered or unexported fields }
Package represents package within repository or database.
See https://k1sslinux.org/package-system#1.0
func NewPackage ¶
func NewPackage(c *Config, po *PackageOptions) (*Package, error)
NewPackage allocates new instance of package.
func Update ¶
func Update(c *Config, uo *UpdateOptions) ([]*Package, error)
Update optionally updates repositories and parses candidates for upgrade.
func UpdateContext ¶
func (*Package) Build ¶
func (p *Package) Build(bo *BuildOptions) (*Tarball, error)
Build builds package and turns it into installable tarball.
func (*Package) BuildContext ¶
func (*Package) Dependencies ¶
func (p *Package) Dependencies() ([]*Dependency, error)
func (*Package) RecursiveDependencies ¶
func (p *Package) RecursiveDependencies() ([]*Dependency, error)
func (*Package) Remove ¶
func (p *Package) Remove(ro *RemoveOptions) error
Remove purges package from the system and gracefully swaps dangling alternatives if they are exist.
func (*Package) ReverseDependencies ¶
func (*Package) Sources ¶
Sources parses package sources. Lines that starts with '#' will be ignored.
type PackageOptions ¶
type PackageOptions struct { // Name defines package name that will be used to traverse // repositories or database. Name string // Path defines path that will be used to grep manifests files // within database to find owner of that path. Path string // From defines where to search package. Applies only to Name field. From RepositoryType }
PackageOptions intended to configure searching of package.
func (*PackageOptions) Validate ¶
func (po *PackageOptions) Validate() error
type RemoveOptions ¶
type RemoveOptions struct { // NoCheckReverseDependencies forcefully removes package even if other // installed packages depends on it. NoCheckReverseDependencies bool // RemoveEtcFiles forcefully removes /etc/* files without special handling RemoveEtcFiles bool }
RemoveOptions provides facilities for removing package.
type RepositoryType ¶
type RepositoryType uint
const ( All RepositoryType = iota Database Repository )
func (RepositoryType) String ¶
func (rt RepositoryType) String() string
type Source ¶
Source represents package source. See https://k1sslinux.org/package-system#4.0
type Tarball ¶
Tarball represents pre-built package.
func NewTarball ¶
NewTarball allocates new instance of pre-built package.
type UpdateOptions ¶
type UpdateOptions struct { // NoUpdateRepositories disables updating repositories. NoUpdateRepositories bool // ContinueOnError ignores possible errors during updating repositories. ContinueOnError bool // ExcludePackages ignores update for specified packages. ExcludePackages []string }
UpdateOptions provides facilities for updating repositories.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package checksums provides in-memory structure for checksums file
|
Package checksums provides in-memory structure for checksums file |
cmd
|
|
Package etcsums provides in-memory structure for etcsums file
|
Package etcsums provides in-memory structure for etcsums file |
internal
|
|
Package manifest provides in-memory structure for manifest file
|
Package manifest provides in-memory structure for manifest file |