Documentation
¶
Index ¶
- Constants
- Variables
- func BeginLogCapture(handler LogHandler) (stop func())
- func BeginOperation()
- func CaptureStdIO(enable bool)
- func CheckLockOrError() error
- func ClearInstallArguments()
- func ConfigRestore(snapshot unsafe.Pointer)
- func ConfigSnapshot() unsafe.Pointer
- func DumpConfig() string
- func EndOperation()
- func PreprocessInstallArguments(names []string) error
- func RegisterSignalChannel(ch chan os.Signal)
- func SetConfig(key, value string)
- func SetLogHandler(handler LogHandler)
- func SetNoLocking(noLock bool)
- func SetTranslator(fn func(msgid string) string)
- func WaitIdle()
- func WithConfigOverrides(overrides map[string]string, fn func() error) error
- type AptError
- type Cache
- func (c *Cache) Close()
- func (c *Cache) DownloadSource(names []string, destDir string, handler ProgressHandler) ([]SourcePackage, error)
- func (c *Cache) GetPackageInfo(packageName string) (*PackageInfo, error)
- func (c *Cache) NewTransaction() (*Transaction, error)
- func (c *Cache) Refresh() error
- func (c *Cache) SearchPackages(pattern string) ([]PackageInfo, error)
- func (c *Cache) SimulateAutoRemove() (*PackageChanges, error)
- func (c *Cache) SimulateChange(installNames []string, removeNames []string, purge bool, depends bool) (*PackageChanges, error)
- func (c *Cache) SimulateChangeWithRpmInfo(installNames []string, removeNames []string, purge bool, depends bool, ...) (*PackageChanges, []*PackageInfo, error)
- func (c *Cache) SimulateDistUpgrade() (*PackageChanges, error)
- func (c *Cache) SimulateInstall(packageNames []string) (*PackageChanges, error)
- func (c *Cache) SimulateReinstall(packageNames []string) (*PackageChanges, error)
- func (c *Cache) SimulateRemove(packageNames []string, purge bool, depends bool) (*PackageChanges, error)
- func (c *Cache) Update(handler ProgressHandler) error
- type ErrLocked
- type EssentialPackage
- type LockStatus
- type LogHandler
- type PackageChanges
- type PackageInfo
- type PackageState
- type ProgressHandler
- type ProgressType
- type SourcePackage
- type System
- type Transaction
- func (tx *Transaction) AutoRemove() error
- func (tx *Transaction) Close()
- func (tx *Transaction) DistUpgrade() error
- func (tx *Transaction) Execute(handler ProgressHandler, downloadOnly bool) error
- func (tx *Transaction) Install(names []string) error
- func (tx *Transaction) Plan() (*PackageChanges, error)
- func (tx *Transaction) Reinstall(names []string) error
- func (tx *Transaction) Remove(names []string, purge, depends bool) error
Constants ¶
const ( AptErrorPackageNotFound = 21 AptErrorInvalidParameters = 91 )
APT error codes (must match apt_error.h)
Variables ¶
var AptMutex sync.Mutex
AptMutex is the global mutex for all apt-lib operations
var T_ = func(msgid string) string { return msgid }
T_ is the string translation hook, defaults to identity
Functions ¶
func BeginLogCapture ¶
func BeginLogCapture(handler LogHandler) (stop func())
BeginLogCapture starts capturing APT output into handler, returns a stop function.
func BeginOperation ¶
func BeginOperation()
BeginOperation blocks signals and marks an active APT operation
func CaptureStdIO ¶
func CaptureStdIO(enable bool)
CaptureStdIO manually enables/disables stdout/stderr capture
func CheckLockOrError ¶
func CheckLockOrError() error
CheckLockOrError checks if APT/RPM is locked and returns an error if it is.
func ClearInstallArguments ¶
func ClearInstallArguments()
ClearInstallArguments clears the arguments
func ConfigRestore ¶
ConfigRestore restores APT configuration from the snapshot (frees it).
func ConfigSnapshot ¶
ConfigSnapshot creates a copy of the whole APT configuration tree.
func DumpConfig ¶
func DumpConfig() string
DumpConfig returns the whole APT configuration as a string.
func PreprocessInstallArguments ¶
PreprocessInstallArguments registers arguments in APT config before opening the cache
func RegisterSignalChannel ¶
RegisterSignalChannel registers the signal channel to restore after APT operations
func SetConfig ¶
func SetConfig(key, value string)
SetConfig sets an APT config value (e.g. "Dir::Cache::Archives", "/tmp/")
func SetLogHandler ¶
func SetLogHandler(handler LogHandler)
SetLogHandler intercepts stdout/stderr via LogHandler
func SetNoLocking ¶
func SetNoLocking(noLock bool)
SetNoLocking enables or disables APT file locking.
func SetTranslator ¶
SetTranslator sets the translation function
Types ¶
type AptError ¶
func CustomError ¶
func ErrorFromResult ¶
ErrorFromResult converts C.AptResult to Go error and frees message
type Cache ¶
Cache represents package cache
func (*Cache) DownloadSource ¶ added in v0.5.2
func (c *Cache) DownloadSource(names []string, destDir string, handler ProgressHandler) ([]SourcePackage, error)
DownloadSource downloads .src.rpm files for the given names into destDir
func (*Cache) GetPackageInfo ¶
func (c *Cache) GetPackageInfo(packageName string) (*PackageInfo, error)
func (*Cache) NewTransaction ¶
func (c *Cache) NewTransaction() (*Transaction, error)
NewTransaction creates a new transaction for the cache
func (*Cache) SearchPackages ¶
func (c *Cache) SearchPackages(pattern string) ([]PackageInfo, error)
func (*Cache) SimulateAutoRemove ¶
func (c *Cache) SimulateAutoRemove() (*PackageChanges, error)
SimulateAutoRemove simulates removal of unused packages
func (*Cache) SimulateChange ¶
func (c *Cache) SimulateChange(installNames []string, removeNames []string, purge bool, depends bool) (*PackageChanges, error)
SimulateChange simulates install and remove in a single transaction
func (*Cache) SimulateChangeWithRpmInfo ¶
func (c *Cache) SimulateChangeWithRpmInfo(installNames []string, removeNames []string, purge bool, depends bool, rpmFiles []string) (*PackageChanges, []*PackageInfo, error)
SimulateChangeWithRpmInfo simulates changes and fetches RPM file info in a single cache session
func (*Cache) SimulateDistUpgrade ¶
func (c *Cache) SimulateDistUpgrade() (*PackageChanges, error)
SimulateDistUpgrade simulates a system upgrade
func (*Cache) SimulateInstall ¶
func (c *Cache) SimulateInstall(packageNames []string) (*PackageChanges, error)
SimulateInstall simulates package installation
func (*Cache) SimulateReinstall ¶
func (c *Cache) SimulateReinstall(packageNames []string) (*PackageChanges, error)
SimulateReinstall simulates package reinstallation
func (*Cache) SimulateRemove ¶
func (c *Cache) SimulateRemove(packageNames []string, purge bool, depends bool) (*PackageChanges, error)
SimulateRemove simulates package removal
func (*Cache) Update ¶
func (c *Cache) Update(handler ProgressHandler) error
type ErrLocked ¶
type ErrLocked struct {
Status LockStatus
}
ErrLocked is returned when APT/RPM is locked by another process
type EssentialPackage ¶
EssentialPackage represents an essential/important package that will be removed
type LockStatus ¶
type LockStatus struct {
IsLocked bool
CanAcquire bool
LockPID int
LockHolder string
LockFilePath string
ErrorMessage string
}
LockStatus represents the status of APT/RPM locks
func CheckLockStatus ¶
func CheckLockStatus() LockStatus
CheckLockStatus checks if APT locks can be acquired without actually acquiring them.
type LogHandler ¶
type LogHandler func(message string)
type PackageChanges ¶
type PackageChanges struct {
ExtraInstalled []string `json:"extraInstalled"`
UpgradedPackages []string `json:"upgradedPackages"`
NewInstalledPackages []string `json:"newInstalledPackages"`
RemovedPackages []string `json:"removedPackages"`
KeptBackPackages []string `json:"keptBackPackages"`
UpgradedCount int `json:"upgradedCount"`
NewInstalledCount int `json:"newInstalledCount"`
RemovedCount int `json:"removedCount"`
KeptBackCount int `json:"keptBackCount"`
NotUpgradedCount int `json:"notUpgradedCount"`
DownloadSize uint64 `json:"downloadSize"`
InstallSize int64 `json:"installSize"`
EssentialPackages []EssentialPackage `json:"essentialPackages"`
}
PackageChanges represents the changes that would occur during package ops
type PackageInfo ¶
type PackageInfo struct {
Name string
Version string
Description string
ShortDescription string
Section string
Architecture string
Maintainer string
Homepage string
Priority string
MD5Hash string
Blake2bHash string
SourcePackage string
Changelog string
Filename string
Depends string
Provides string
Conflicts string
Obsoletes string
Recommends string
Suggests string
State PackageState
AutoInstalled bool
Essential bool
InstalledSize uint64
DownloadSize uint64
PackageID uint32
Aliases []string
Files []string
}
type PackageState ¶
type PackageState int
const ( // PackageStateNotInstalled PackageState = 0 PackageStateInstalled PackageState = 1 )
Package states (must match AptPackageState in apt_common.h)
type ProgressHandler ¶
type ProgressHandler func(packageName string, eventType ProgressType, current, total, speed uint64)
type ProgressType ¶
type ProgressType int
const ( CallbackInstallProgress ProgressType = 1 CallbackDownloadStart ProgressType = 20 CallbackDownloadProgress ProgressType = 21 CallbackDownloadStop ProgressType = 22 CallbackDownloadComplete ProgressType = 23 CallbackDownloadItemProgress ProgressType = 24 )
type SourcePackage ¶ added in v0.5.2
SourcePackage describes a downloaded source package (.src.rpm)
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction encapsulates the lifecycle of a package operation
func (*Transaction) AutoRemove ¶
func (tx *Transaction) AutoRemove() error
AutoRemove marks the transaction as removal of unused packages
func (*Transaction) DistUpgrade ¶
func (tx *Transaction) DistUpgrade() error
DistUpgrade marks the transaction as a system upgrade
func (*Transaction) Execute ¶
func (tx *Transaction) Execute(handler ProgressHandler, downloadOnly bool) error
Execute executes the transaction
func (*Transaction) Install ¶
func (tx *Transaction) Install(names []string) error
Install adds packages to install
func (*Transaction) Plan ¶
func (tx *Transaction) Plan() (*PackageChanges, error)
Plan simulates the transaction
func (*Transaction) Reinstall ¶
func (tx *Transaction) Reinstall(names []string) error
Reinstall adds packages to reinstall