Documentation
¶
Index ¶
- Variables
- func ComputeMD5Sum(filename string) (string, error)
- func ComputeSHA256Sum(filename string) (string, error)
- func VerCmp(v1, v2 string) int
- func Version() string
- type Backup
- type CapabilitiesMask
- type Conflict
- type Database
- type DepMissing
- type DepMod
- type Depend
- type Dependency
- type DownloadCallback
- type DownloadCompletedData
- type DownloadEvent
- type DownloadEventData
- type DownloadEventType
- type DownloadInitData
- type DownloadProgressData
- type DownloadRetryData
- type Event
- type EventCallback
- type FetchCallback
- type File
- type FileConflict
- type FileConflictType
- type Group
- type Handle
- type LogLevel
- type Package
- type PackageIterator
- type PkgFrom
- type PkgReason
- type PkgValidation
- type ProgressCallback
- type Question
- type QuestionAny
- type QuestionCallback
- type QuestionInstallIgnorepkg
- type QuestionSelectProvider
- type SigList
- type SigResult
- type SigStatus
- type SigValidity
- type Transaction
- type TransactionFlag
- type Usage
- type Validation
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidDatabase = errors.New("invalid database") ErrInvalidPackage = errors.New("invalid package") ErrInvalidGroup = errors.New("invalid group") ErrInvalidHandle = errors.New("invalid handle") ErrPackageNotFound = errors.New("package not found") ErrGroupNotFound = errors.New("group not found") ErrDatabaseUpdateFailed = errors.New("database update failed") ErrDatabaseUnregisterFailed = errors.New("database unregister failed") ErrTransactionInitFailed = errors.New("transaction init failed") ErrTransactionPrepareFailed = errors.New("transaction prepare failed") ErrTransactionCommitFailed = errors.New("transaction commit failed") ErrTransactionReleaseFailed = errors.New("transaction release failed") ErrAddPackageFailed = errors.New("add package failed") ErrRemovePackageFailed = errors.New("remove package failed") ErrSysupgradeFailed = errors.New("sysupgrade failed") ErrPackageFreeFailed = errors.New("package free failed") ErrPackageLoadFailed = errors.New("package load failed") ErrInvalidDependency = errors.New("invalid dependency") )
Functions ¶
func ComputeMD5Sum ¶
ComputeMD5Sum computes the MD5 sum of a file
func ComputeSHA256Sum ¶
ComputeSHA256Sum computes the SHA256 sum of a file
Types ¶
type CapabilitiesMask ¶
type CapabilitiesMask int
CapabilitiesMask represents the library capabilities bitmask
const ( CapNLS CapabilitiesMask = 1 << 0 CapDownloader CapabilitiesMask = 1 << 1 CapSignatures CapabilitiesMask = 1 << 2 )
func Capabilities ¶
func Capabilities() (CapabilitiesMask, error)
Capabilities returns the library capabilities
type Conflict ¶
type Conflict interface {
GetPackage1() string
GetPackage2() string
GetReason() Dependency
Free()
}
Conflict represents a package conflict
type Database ¶
type Database interface {
Name() string
Pkg(name string) Package
PkgCache() PackageIterator
Search(needles []string) PackageIterator
SetServers(servers []string) error
SetUsage(usage int) error
}
Database represents an ALPM database (minimal surface used by yay).
type DepMissing ¶
type DepMissing interface {
GetTarget() string
GetDepend() Dependency
GetCausingPkg() string
Free()
}
DepMissing represents a missing dependency
type Dependency ¶
type Dependency interface {
GetName() string
GetVersion() string
GetMod() DepMod
ComputeString() string
Free()
}
Dependency represents a package dependency
func DepFromString ¶
func DepFromString(depstring string) (Dependency, error)
DepFromString creates a dependency from a string
type DownloadCallback ¶
type DownloadCallback func(ev DownloadEvent)
DownloadCallback corresponds to alpm_cb_download, with decoded data when possible.
type DownloadCompletedData ¶
type DownloadEvent ¶
type DownloadEvent struct {
Filename string
Type DownloadEventType
Data DownloadEventData
RawData uintptr
}
DownloadEvent is passed to DownloadCallback.
type DownloadEventData ¶
type DownloadEventData interface {
// contains filtered or unexported methods
}
DownloadEventData is an optional decoded view of the download event payload.
type DownloadEventType ¶
type DownloadEventType int32
DownloadEventType corresponds to alpm_download_event_type_t.
const ( DownloadInit DownloadEventType = 0 // ALPM_DOWNLOAD_INIT DownloadProgress DownloadEventType = 1 // ALPM_DOWNLOAD_PROGRESS DownloadRetry DownloadEventType = 2 // ALPM_DOWNLOAD_RETRY DownloadCompleted DownloadEventType = 3 // ALPM_DOWNLOAD_COMPLETED )
type DownloadInitData ¶
type DownloadInitData struct {
Optional bool
}
type DownloadProgressData ¶
type DownloadRetryData ¶
type DownloadRetryData struct {
Resume bool
}
type Event ¶
Event is a minimal wrapper around alpm_event_t*. For advanced use, consult alpm.h and decode based on Type and Ptr.
type FetchCallback ¶
FetchCallback corresponds to alpm_cb_fetch. Return values: 0 success, 1 up-to-date, -1 error.
type FileConflict ¶
type FileConflict interface {
GetTarget() string
GetType() FileConflictType
GetFile() string
GetCTarget() string
Free()
}
FileConflict represents a file conflict
type FileConflictType ¶
type FileConflictType int
FileConflictType represents the type of file conflict
const ( FileConflictTarget FileConflictType = 1 FileConflictFilesystem FileConflictType = 2 )
type Handle ¶
type Handle interface {
// Release releases the handle and cleans up resources
Release() error
LocalDB() (Database, error)
SyncDBs() ([]Database, error)
SyncDBListByDBName(name string) ([]Database, error)
SyncDBByName(name string) (Database, error)
// Transaction methods
TransInit(flags TransactionFlag) error
TransRelease() error
SyncSysupgrade(enableDowngrade bool) error
TransGetAdd() PackageIterator
// RegisterSyncDB registers a sync database
RegisterSyncDB(name string, siglevel int) (Database, error)
// Root returns the root path
Root() string
// DBPath returns the database path
DBPath() string
// Errno returns the current error code
Errno() dyerrors.Errno
// StrError returns the error string for an error code
StrError(errno dyerrors.Errno) string
// Options
SetLogFile(path string) error
LogFile() string
SetGPGDir(path string) error
GPGDir() string
SetUseSyslog(enable bool) error
UseSyslog() bool
SetCheckSpace(enable bool) error
CheckSpace() bool
SetDBExt(ext string) error
DBExt() string
SetDefaultSigLevel(level int) error
DefaultSigLevel() int
SetLocalFileSigLevel(level int) error
LocalFileSigLevel() int
SetRemoteFileSigLevel(level int) error
RemoteFileSigLevel() int
SetParallelDownloads(num int) error
ParallelDownloads() int
// Architecture
Architectures() ([]string, error)
SetArchitectures(archs []string) error
AddArchitecture(arch string) error
RemoveArchitecture(arch string) error
// List Options
CacheDirs() ([]string, error)
SetCacheDirs(dirs []string) error
AddCacheDir(dir string) error
RemoveCacheDir(dir string) error
HookDirs() ([]string, error)
SetHookDirs(dirs []string) error
AddHookDir(dir string) error
RemoveHookDir(dir string) error
NoUpgrades() ([]string, error)
SetNoUpgrades(paths []string) error
AddNoUpgrade(path string) error
RemoveNoUpgrade(path string) error
MatchNoUpgrade(path string) (int, error)
NoExtracts() ([]string, error)
SetNoExtracts(paths []string) error
AddNoExtract(path string) error
RemoveNoExtract(path string) error
MatchNoExtract(path string) (int, error)
IgnorePkgs() ([]string, error)
SetIgnorePkgs(pkgs []string) error
AddIgnorePkg(pkg string) error
RemoveIgnorePkg(pkg string) error
IgnoreGroups() ([]string, error)
SetIgnoreGroups(groups []string) error
AddIgnoreGroup(group string) error
RemoveIgnoreGroup(group string) error
OverwriteFiles() ([]string, error)
SetOverwriteFiles(globs []string) error
AddOverwriteFile(glob string) error
RemoveOverwriteFile(glob string) error
SetSandboxUser(user string) error
SandboxUser() string
SetDisableDLTimeout(disable bool) error
SetDisableSandbox(disable bool) error
// LoadPackage loads a package from a file
LoadPackage(filename string, full bool, siglevel int) (Package, error)
// DB Management
UnregisterAllSyncDBs() error
// Utils
LogAction(prefix, message string) error
Unlock() error
FetchPkgURL(url string) (string, error)
FindGroupPkgs(dbs []Database, name string) ([]Package, error)
ExtractKeyID(identifier string, sig []byte) ([]string, error)
InterruptTransaction() error
SandboxSetupChild(user, dir string) error
// Assume Installed
AssumeInstalled() ([]Dependency, error)
SetAssumeInstalled(deps []Dependency) error
AddAssumeInstalled(dep Dependency) error
RemoveAssumeInstalled(dep Dependency) error
// Dependency Resolution
CheckDeps(pkgs []Package, remPkgs []Package, upgradePkgs []Package, reverseDeps bool) ([]DepMissing, error)
CheckConflicts(pkgs []Package) ([]Conflict, error)
FindDBSatisfier(dbs []Database, depstring string) Package
// Callbacks (raw pointers)
//
// NOTE: libalpm's log callback (`alpm_cb_log`) uses a `va_list`, which cannot be
// safely bridged to a Go function without a C shim. This wrapper therefore
// exposes logcb as raw pointers only.
LogCallback() (cb uintptr, ctx uintptr)
SetLogCallback(cb uintptr, ctx uintptr) error
DownloadCallback() (cb uintptr, ctx uintptr)
SetDownloadCallback(cb uintptr, ctx uintptr) error
SetDownloadCallbackFunc(cb DownloadCallback) error
FetchCallback() (cb uintptr, ctx uintptr)
SetFetchCallback(cb uintptr, ctx uintptr) error
SetFetchCallbackFunc(cb FetchCallback) error
EventCallback() (cb uintptr, ctx uintptr)
SetEventCallback(cb uintptr, ctx uintptr) error
SetEventCallbackFunc(cb EventCallback) error
QuestionCallback() (cb uintptr, ctx uintptr)
SetQuestionCallback(cb uintptr, ctx uintptr) error
SetQuestionCallbackFunc(cb QuestionCallback) error
ProgressCallback() (cb uintptr, ctx uintptr)
SetProgressCallback(cb uintptr, ctx uintptr) error
SetProgressCallbackFunc(cb ProgressCallback) error
}
Handle represents an ALPM handle
func Initialize ¶
Initialize creates a new ALPM handle
type Package ¶
type Package interface {
Name() string
Version() string
Description() string
Architecture() string
Size() int64
ISize() int64
DB() Database
Depends() []Depend
Provides() []Depend
OptionalDepends() []Depend
Groups() []string
BuildDate() time.Time
Reason() PkgReason
Base() string
ShouldIgnore() bool
}
Package represents an ALPM package (minimal surface used by yay).
func FindSatisfier ¶
FindSatisfier finds a package that satisfies a dependency in a list of packages
type PackageIterator ¶
type PackageIterator struct {
// contains filtered or unexported fields
}
PackageIterator provides lazy iteration over an ALPM package list.
func (PackageIterator) Collect ¶
func (it PackageIterator) Collect() []Package
Collect returns all packages in the iterator as a slice.
func (PackageIterator) FindSatisfier ¶
func (it PackageIterator) FindSatisfier(depstring string) (Package, error)
FindSatisfier finds the first package satisfying a depstring.
func (PackageIterator) ForEach ¶
func (it PackageIterator) ForEach(fn func(Package) error) error
ForEach iterates over packages lazily. If the underlying list must be freed, it will be freed after iteration.
func (PackageIterator) SortBySize ¶
func (it PackageIterator) SortBySize() []Package
SortBySize returns packages sorted by install size (descending).
type PkgValidation ¶
type PkgValidation int
PkgValidation represents package validation status
const ( PkgValidationUnknown PkgValidation = 0 PkgValidationNone PkgValidation = (1 << 0) PkgValidationMD5Sum PkgValidation = (1 << 1) PkgValidationSHA256Sum PkgValidation = (1 << 2) PkgValidationSignature PkgValidation = (1 << 3) )
type ProgressCallback ¶
ProgressCallback corresponds to alpm_cb_progress.
type Question ¶
Question is a minimal wrapper around alpm_question_t*. You can generally answer by setting the second field of the union (an int) using SetAnswerInt, since all question structs begin with (type, answer/int).
func (Question) SetAnswerInt ¶
SetAnswerInt sets the question's "answer" field. The meaning depends on q.Type.
type QuestionAny ¶
type QuestionAny struct {
Question Question
}
QuestionAny is a wrapper for question callback data (go-alpm/v2 compatibility)
func (QuestionAny) QuestionInstallIgnorepkg ¶
func (qa QuestionAny) QuestionInstallIgnorepkg() (*QuestionInstallIgnorepkg, error)
QuestionInstallIgnorepkg returns a QuestionInstallIgnorepkg if this is an install-ignorepkg question
func (QuestionAny) QuestionSelectProvider ¶
func (qa QuestionAny) QuestionSelectProvider() (*QuestionSelectProvider, error)
QuestionSelectProvider returns a QuestionSelectProvider if this is a select-provider question
type QuestionCallback ¶
type QuestionCallback func(q Question)
QuestionCallback corresponds to alpm_cb_question.
type QuestionInstallIgnorepkg ¶
type QuestionInstallIgnorepkg struct {
// contains filtered or unexported fields
}
QuestionInstallIgnorepkg is for handling install-ignorepkg questions
func (*QuestionInstallIgnorepkg) SetInstall ¶
func (qi *QuestionInstallIgnorepkg) SetInstall(install bool)
SetInstall sets whether to install the ignored package
type QuestionSelectProvider ¶
type QuestionSelectProvider struct {
// contains filtered or unexported fields
}
QuestionSelectProvider is for handling select-provider questions
func (*QuestionSelectProvider) Dep ¶
func (qp *QuestionSelectProvider) Dep() string
Dep returns the dependency string being resolved
func (*QuestionSelectProvider) Providers ¶
func (qp *QuestionSelectProvider) Providers(h Handle) PackageIterator
Providers returns the list of provider packages
func (*QuestionSelectProvider) SetUseIndex ¶
func (qp *QuestionSelectProvider) SetUseIndex(index int)
SetUseIndex sets which provider index to use (1-based)
type SigList ¶
type SigList struct {
Results []SigResult
}
SigList represents a list of signature results
type SigResult ¶
type SigResult struct {
KeyID string
Status SigStatus
Validity SigValidity
}
SigResult represents a single signature result
type SigValidity ¶
type SigValidity int
SigValidity represents the validity of a signature
const ( SigValidityFull SigValidity = iota SigValidityMarginal SigValidityNever SigValidityUnknown )
type Transaction ¶
type Transaction interface {
// Init initializes the transaction
Init(flags TransactionFlag) error
// Prepare prepares the transaction
Prepare() ([]DepMissing, error)
// Commit commits the transaction
Commit() ([]FileConflict, error)
// Release releases the transaction
Release() error
// AddPkg adds a package to the transaction
AddPkg(pkg Package) error
// RemovePkg removes a package from the transaction
RemovePkg(pkg Package) error
// SyncSysupgrade adds packages to upgrade to the transaction
SyncSysupgrade(enableDowngrade bool) error
// GetFlags returns the transaction flags
GetFlags() TransactionFlag
// GetAdd returns the list of packages to be added
GetAdd() ([]Package, error)
// GetRemove returns the list of packages to be removed
GetRemove() ([]Package, error)
}
Transaction represents an ALPM transaction
func NewTransaction ¶
func NewTransaction(h Handle) Transaction
NewTransaction creates a new transaction for the given handle
type TransactionFlag ¶
type TransactionFlag int
TransactionFlag represents transaction flags
const ( TransFlagNoDeps TransactionFlag = 1 TransFlagNoSave TransactionFlag = 1 << 2 TransFlagNoDepVersion TransactionFlag = 1 << 3 TransFlagCascade TransactionFlag = 1 << 4 TransFlagRecurse TransactionFlag = 1 << 5 TransFlagDBOnly TransactionFlag = 1 << 6 TransFlagNoHooks TransactionFlag = 1 << 7 TransFlagAllDeps TransactionFlag = 1 << 8 TransFlagDownloadOnly TransactionFlag = 1 << 9 TransFlagNoScriptlet TransactionFlag = 1 << 10 TransFlagNoConflicts TransactionFlag = 1 << 11 TransFlagNeeded TransactionFlag = 1 << 13 TransFlagAllExplicit TransactionFlag = 1 << 14 TransFlagUnneeded TransactionFlag = 1 << 15 TransFlagRecurseAll TransactionFlag = 1 << 16 TransFlagNoLock TransactionFlag = 1 << 17 )