alpm

package module
v0.0.0-...-a3feea4 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2020 License: MIT Imports: 7 Imported by: 7

README

go-alpm

go-alpm is a Go package for binding libalpm. With go-alpm, it becomes possible to manipulate the Pacman databases and packages just as Pacman would.

This project is MIT Licensed. See LICENSE for details.

Getting started

  1. Import the go-alpm repository in your go script

    import "github.com/jguer/go-alpm"

  2. Copy the library to your GOPATH

    mkdir /go export GOPATH=/go go get github.com/jguer/go-alpm

  3. Try the included examples

    cd $GOPATH/src/github.com/jguer/go-alpm/examples go run installed.go

Current Maintainers

  • Morganamilo
  • Jguer

Original Contributors

  • Mike Rosset
  • Dave Reisner
  • Rémy Oudompheng
  • Jesus Alvarez

Documentation

Overview

Package alpm implements Go bindings to the libalpm library used by Pacman, the Arch Linux package manager. Libalpm allows the creation of custom front ends to the Arch Linux package ecosystem.

Libalpm does not include support for the Arch User Repository (AUR).

Index

Examples

Constants

This section is empty.

Variables

View Source
var DefaultLogLevel = LogWarning

Functions

func DefaultLogCallback

func DefaultLogCallback(lvl LogLevel, s string)

func VerCmp

func VerCmp(v1, v2 string) int

VerCmp performs version comparison according to Pacman conventions. Return value is <0 if and only if v1 is older than v2.

Example
fmt.Println(VerCmp("1.0-2", "2.0-1") < 0)
fmt.Println(VerCmp("1:1.0-2", "2.0-1") > 0)
fmt.Println(VerCmp("2.0.2-2", "2.0.2-2") == 0)
Output:

true
true
true

func Version

func Version() string

Version returns libalpm version string.

Types

type BackupFile

type BackupFile struct {
	Name string
	Hash string
}

type BackupList

type BackupList struct {
	// contains filtered or unexported fields
}

func (BackupList) Empty

func (l BackupList) Empty() bool

func (BackupList) ForEach

func (l BackupList) ForEach(f func(BackupFile) error) error

func (BackupList) Len

func (l BackupList) Len() int

func (BackupList) Slice

func (l BackupList) Slice() (slice []BackupFile)

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB structure representing a alpm database.

func (*DB) AddServer

func (db *DB) AddServer(server string)

AddServers adds a string to the server list.

func (*DB) Name

func (db *DB) Name() string

Name returns name of the db

func (*DB) Pkg

func (db *DB) Pkg(name string) *Package

Name searches a package in db.

func (*DB) PkgCache

func (db *DB) PkgCache() PackageList

PkgCache returns the list of packages of the database

func (*DB) Search

func (db *DB) Search(targets []string) PackageList

func (*DB) Servers

func (db *DB) Servers() []string

Servers returns host server URL.

func (*DB) SetServers

func (db *DB) SetServers(servers []string)

SetServers sets server list to use.

func (*DB) SetUsage

func (db *DB) SetUsage(usage Usage)

SetUsage sets the Usage of the database

func (*DB) Unregister

func (db *DB) Unregister() error

type DBList

type DBList struct {
	// contains filtered or unexported fields
}

DBList structure representing a alpm database list.

func (DBList) Empty

func (l DBList) Empty() bool

func (DBList) FindGroupPkgs

func (l DBList) FindGroupPkgs(name string) PackageList

PkgCachebyGroup returns a PackageList of packages belonging to a group

func (DBList) FindSatisfier

func (l DBList) FindSatisfier(depstring string) (*Package, error)

FindSatisfier searches a DBList for a package that satisfies depstring Example "glibc>=2.12"

func (DBList) ForEach

func (l DBList) ForEach(f func(DB) error) error

ForEach executes an action on each DB.

func (DBList) Len

func (l DBList) Len() int

func (DBList) Slice

func (l DBList) Slice() []DB

Slice converst DB list to DB slice.

type DepMod

type DepMod uint

Dependency constraint types.

const (
	DepModAny DepMod = iota + 1 // Any version.
	DepModEq                    // Specific version.
	DepModGE                    // Test for >= some version.
	DepModLE                    // Test for <= some version.
	DepModGT                    // Test for > some version.
	DepModLT                    // Test for < some version.
)

func (DepMod) String

func (mod DepMod) String() string

type Depend

type Depend struct {
	Name        string
	Version     string
	Description string
	NameHash    uint
	Mod         DepMod
}

Depend provides a description of a dependency.

func (Depend) String

func (dep Depend) String() string

type DependList

type DependList struct {
	// contains filtered or unexported fields
}

DependList describes a linkedlist of dependency type packages.

func (DependList) Empty

func (l DependList) Empty() bool

func (DependList) ForEach

func (l DependList) ForEach(f func(Depend) error) error

ForEach executes an action on each package of the DependList.

func (DependList) Len

func (l DependList) Len() int

func (DependList) Slice

func (l DependList) Slice() []Depend

Slice converts the DependList to a Depend Slice.

type Error

type Error C.alpm_errno_t

The Error type represents error codes from libalpm.

func (Error) Error

func (er Error) Error() string

The string representation of an error is given by C function alpm_strerror().

type File

type File struct {
	Name string
	Size int64
	Mode uint32
}

File provides a description of package files.

type Handle

type Handle struct {
	// contains filtered or unexported fields
}

Handle contains the pointer to the alpm handle

func Initialize

func Initialize(root, dbpath string) (*Handle, error)

Init initializes alpm handle

func (*Handle) AddAssumeInstalled

func (h *Handle) AddAssumeInstalled(dep Depend) error

func (*Handle) AddCacheDir

func (h *Handle) AddCacheDir(hookDir string) error

func (*Handle) AddHookDir

func (h *Handle) AddHookDir(hookDir string) error

func (*Handle) AddIgnoreGroup

func (h *Handle) AddIgnoreGroup(hookDir string) error

func (*Handle) AddIgnorePkg

func (h *Handle) AddIgnorePkg(hookDir string) error

func (*Handle) AddNoExtract

func (h *Handle) AddNoExtract(hookDir string) error

func (*Handle) AddNoUpgrade

func (h *Handle) AddNoUpgrade(hookDir string) error

func (*Handle) Arch

func (h *Handle) Arch() (string, error)

func (*Handle) AssumeInstalled

func (h *Handle) AssumeInstalled() (DependList, error)

use alpm_depend_t

func (*Handle) CacheDirs

func (h *Handle) CacheDirs() (StringList, error)

func (*Handle) CheckSpace

func (h *Handle) CheckSpace() (bool, error)

func (*Handle) DBExt

func (h *Handle) DBExt() (string, error)

func (*Handle) DBPath

func (h *Handle) DBPath() (string, error)

func (*Handle) GPGDir

func (h *Handle) GPGDir() (string, error)

func (*Handle) GetDefaultSigLevel

func (h *Handle) GetDefaultSigLevel() (SigLevel, error)

func (*Handle) GetLocalFileSigLevel

func (h *Handle) GetLocalFileSigLevel() (SigLevel, error)

func (*Handle) GetRemoteFileSigLevel

func (h *Handle) GetRemoteFileSigLevel() (SigLevel, error)

func (*Handle) HookDirs

func (h *Handle) HookDirs() (StringList, error)

func (*Handle) IgnoreGroups

func (h *Handle) IgnoreGroups() (StringList, error)

func (*Handle) IgnorePkgs

func (h *Handle) IgnorePkgs() (StringList, error)

func (*Handle) LastError

func (h *Handle) LastError() error

LastError gets the last pm_error

func (*Handle) LocalDB

func (h *Handle) LocalDB() (*DB, error)

LocalDB returns the local database relative to the given handle.

func (*Handle) Lockfile

func (h *Handle) Lockfile() (string, error)

func (*Handle) LogFile

func (h *Handle) LogFile() (string, error)

func (*Handle) MatchNoExtract

func (h *Handle) MatchNoExtract(dir string) (bool, error)

func (*Handle) MatchNoUpgrade

func (h *Handle) MatchNoUpgrade(dir string) (bool, error)

func (*Handle) NoExtracts

func (h *Handle) NoExtracts() (StringList, error)

func (*Handle) NoUpgrades

func (h *Handle) NoUpgrades() (StringList, error)

func (*Handle) RegisterSyncDB

func (h *Handle) RegisterSyncDB(dbname string, siglevel SigLevel) (*DB, error)

RegisterSyncDB Loads a sync database with given name and signature check level.

func (*Handle) Release

func (h *Handle) Release() error

Release releases the alpm handle

func (*Handle) RemoveCacheDir

func (h *Handle) RemoveCacheDir(dir string) (bool, error)

func (*Handle) RemoveHookDir

func (h *Handle) RemoveHookDir(dir string) (bool, error)

func (*Handle) RemoveIgnoreGroup

func (h *Handle) RemoveIgnoreGroup(dir string) (bool, error)

func (*Handle) RemoveIgnorePkg

func (h *Handle) RemoveIgnorePkg(dir string) (bool, error)

func (*Handle) RemoveNoExtract

func (h *Handle) RemoveNoExtract(dir string) (bool, error)

func (*Handle) RemoveNoUpgrade

func (h *Handle) RemoveNoUpgrade(dir string) (bool, error)

func (*Handle) Root

func (h *Handle) Root() (string, error)

func (*Handle) SetArch

func (h *Handle) SetArch(str string) error

func (*Handle) SetCacheDirs

func (h *Handle) SetCacheDirs(hookDirs []string) error

func (*Handle) SetCheckSpace

func (h *Handle) SetCheckSpace(value bool) error

func (*Handle) SetDBExt

func (h *Handle) SetDBExt(str string) error

func (*Handle) SetDefaultSigLevel

func (h *Handle) SetDefaultSigLevel(siglevel SigLevel) error

func (*Handle) SetGPGDir

func (h *Handle) SetGPGDir(str string) error

func (*Handle) SetHookDirs

func (h *Handle) SetHookDirs(hookDirs []string) error

func (*Handle) SetIgnoreGroups

func (h *Handle) SetIgnoreGroups(hookDirs []string) error

func (*Handle) SetIgnorePkgs

func (h *Handle) SetIgnorePkgs(hookDirs []string) error

func (*Handle) SetLocalFileSigLevel

func (h *Handle) SetLocalFileSigLevel(siglevel SigLevel) error

func (*Handle) SetLogCallback

func (h *Handle) SetLogCallback(cb logCallbackSig)

func (*Handle) SetLogFile

func (h *Handle) SetLogFile(str string) error

func (*Handle) SetNoExtracts

func (h *Handle) SetNoExtracts(hookDirs []string) error

func (*Handle) SetNoUpgrades

func (h *Handle) SetNoUpgrades(hookDirs []string) error

func (*Handle) SetQuestionCallback

func (h *Handle) SetQuestionCallback(cb questionCallbackSig)

func (*Handle) SetRemoteFileSigLevel

func (h *Handle) SetRemoteFileSigLevel(siglevel SigLevel) error

func (*Handle) SetUseSyslog

func (h *Handle) SetUseSyslog(value bool) error

func (*Handle) SyncDBByName

func (h *Handle) SyncDBByName(name string) (db *DB, err error)

SyncDBByName finds a registered database by name.

func (*Handle) SyncDBs

func (h *Handle) SyncDBs() (DBList, error)

SyncDBs returns list of Synced DBs.

func (*Handle) SyncSysupgrade

func (h *Handle) SyncSysupgrade(enableDowngrade bool) error

func (*Handle) TransGetAdd

func (h *Handle) TransGetAdd() PackageList

func (*Handle) TransGetFlags

func (h *Handle) TransGetFlags() (TransFlag, error)

func (*Handle) TransGetRemove

func (h *Handle) TransGetRemove() PackageList

func (*Handle) TransInit

func (h *Handle) TransInit(flags TransFlag) error

func (*Handle) TransRelease

func (h *Handle) TransRelease() error

func (*Handle) UnregisterAllSyncDBs

func (h *Handle) UnregisterAllSyncDBs() error

func (*Handle) UseSyslog

func (h *Handle) UseSyslog() (bool, error)

type LogLevel

type LogLevel uint16
const (
	LogError LogLevel = 1 << iota
	LogWarning
	LogDebug
	LogFunction
)

Logging levels.

type Package

type Package struct {
	// contains filtered or unexported fields
}

Package describes a single package and associated handle.

func (*Package) Architecture

func (pkg *Package) Architecture() string

Architecture returns the package target Architecture.

func (*Package) Backup

func (pkg *Package) Backup() BackupList

Backup returns a list of package backups.

func (*Package) Base

func (pkg *Package) Base() string

func (*Package) Base64Signature

func (pkg *Package) Base64Signature() string

func (*Package) BuildDate

func (pkg *Package) BuildDate() time.Time

BuildDate returns the BuildDate of the package.

func (*Package) CheckDepends

func (pkg *Package) CheckDepends() DependList

Depends returns the package's check dependency list.

func (*Package) ComputeOptionalFor

func (pkg *Package) ComputeOptionalFor() []string

ComputeOptionalFor returns the names of packages that optionally require the given package

func (*Package) ComputeRequiredBy

func (pkg *Package) ComputeRequiredBy() []string

ComputeRequiredBy returns the names of reverse dependencies of a package

func (*Package) Conflicts

func (pkg *Package) Conflicts() DependList

Conflicts returns the conflicts of the package as a DependList.

func (*Package) ContainsFile

func (pkg *Package) ContainsFile(path string) (File, error)

ContainsFile checks if the path is in the package filelist

func (*Package) DB

func (pkg *Package) DB() *DB

DB returns the package's origin database.

func (*Package) Depends

func (pkg *Package) Depends() DependList

Depends returns the package's dependency list.

func (*Package) Description

func (pkg *Package) Description() string

Description returns the package's description.

func (*Package) FileName

func (pkg *Package) FileName() string

func (*Package) Files

func (pkg *Package) Files() []File

Files returns the file list of the package.

func (*Package) Groups

func (pkg *Package) Groups() StringList

Groups returns the groups the package belongs to.

func (*Package) ISize

func (pkg *Package) ISize() int64

ISize returns the package installed size.

func (*Package) InstallDate

func (pkg *Package) InstallDate() time.Time

InstallDate returns the package install date.

func (*Package) Licenses

func (pkg *Package) Licenses() StringList

Licenses returns the package license list.

func (*Package) MD5Sum

func (pkg *Package) MD5Sum() string

MD5Sum returns package MD5Sum.

func (*Package) MakeDepends

func (pkg *Package) MakeDepends() DependList

Depends returns the package's make dependency list.

func (*Package) Name

func (pkg *Package) Name() string

Name returns package name.

func (*Package) OptionalDepends

func (pkg *Package) OptionalDepends() DependList

Depends returns the package's optional dependency list.

func (*Package) Origin

func (pkg *Package) Origin() PkgFrom

Origin returns package origin.

func (*Package) Packager

func (pkg *Package) Packager() string

Packager returns package packager name.

func (*Package) Provides

func (pkg *Package) Provides() DependList

Provides returns DependList of packages provides by package.

func (*Package) Reason

func (pkg *Package) Reason() PkgReason

Reason returns package install reason.

func (*Package) Replaces

func (pkg *Package) Replaces() DependList

Replaces returns a DependList with the packages this package replaces.

func (*Package) SHA256Sum

func (pkg *Package) SHA256Sum() string

SHA256Sum returns package SHA256Sum.

func (*Package) ShouldIgnore

func (pkg *Package) ShouldIgnore() bool

func (*Package) Size

func (pkg *Package) Size() int64

Size returns the packed package size.

func (*Package) SyncNewVersion

func (pkg *Package) SyncNewVersion(l DBList) *Package

NewVersion checks if there is a new version of the package in a given DBlist.

func (*Package) URL

func (pkg *Package) URL() string

URL returns the upstream URL of the package.

func (*Package) Validation

func (pkg *Package) Validation() Validation

func (*Package) Version

func (pkg *Package) Version() string

Version returns the package version.

type PackageList

type PackageList struct {
	// contains filtered or unexported fields
}

PackageList describes a linked list of packages and associated handle.

func (PackageList) Empty

func (l PackageList) Empty() bool

func (PackageList) FindSatisfier

func (l PackageList) FindSatisfier(depstring string) (*Package, error)

FindSatisfier finds a package that satisfies depstring from PkgList

func (PackageList) ForEach

func (l PackageList) ForEach(f func(Package) error) error

ForEach executes an action on each package of the PackageList.

func (PackageList) Len

func (l PackageList) Len() int

func (PackageList) Slice

func (l PackageList) Slice() []Package

Slice converts the PackageList to a Package Slice.

func (PackageList) SortBySize

func (l PackageList) SortBySize() PackageList

SortBySize returns a PackageList sorted by size.

type PkgFrom

type PkgFrom uint

Source of a package structure.

const (
	FromFile PkgFrom = iota + 1
	FromLocalDB
	FromSyncDB
)

type PkgReason

type PkgReason uint

Install reason of a package.

const (
	PkgReasonExplicit PkgReason = 0
	PkgReasonDepend   PkgReason = 1
)

func (PkgReason) String

func (r PkgReason) String() string

type QuestionAny

type QuestionAny struct {
	// contains filtered or unexported fields
}

func (QuestionAny) Answer

func (question QuestionAny) Answer() bool

func (QuestionAny) QuestionInstallIgnorepkg

func (question QuestionAny) QuestionInstallIgnorepkg() (QuestionInstallIgnorepkg, error)

func (QuestionAny) QuestionReplace

func (question QuestionAny) QuestionReplace() (QuestionReplace, error)

func (QuestionAny) QuestionSelectProvider

func (question QuestionAny) QuestionSelectProvider() (QuestionSelectProvider, error)

func (QuestionAny) SetAnswer

func (question QuestionAny) SetAnswer(answer bool)

func (QuestionAny) Type

func (question QuestionAny) Type() QuestionType

type QuestionInstallIgnorepkg

type QuestionInstallIgnorepkg struct {
	// contains filtered or unexported fields
}

func (QuestionInstallIgnorepkg) Install

func (question QuestionInstallIgnorepkg) Install() bool

func (QuestionInstallIgnorepkg) Pkg

func (question QuestionInstallIgnorepkg) Pkg(h *Handle) Package

func (QuestionInstallIgnorepkg) SetInstall

func (question QuestionInstallIgnorepkg) SetInstall(install bool)

func (QuestionInstallIgnorepkg) Type

func (question QuestionInstallIgnorepkg) Type() QuestionType

type QuestionReplace

type QuestionReplace struct {
	// contains filtered or unexported fields
}

func (QuestionReplace) NewPkg

func (question QuestionReplace) NewPkg(h *Handle) *Package

func (QuestionReplace) OldPkg

func (question QuestionReplace) OldPkg(h *Handle) *Package

func (QuestionReplace) Replace

func (question QuestionReplace) Replace() bool

func (QuestionReplace) SetReplace

func (question QuestionReplace) SetReplace(replace bool)

func (QuestionReplace) Type

func (question QuestionReplace) Type() QuestionType

type QuestionSelectProvider

type QuestionSelectProvider struct {
	// contains filtered or unexported fields
}

func (QuestionSelectProvider) Dep

func (question QuestionSelectProvider) Dep() Depend

func (QuestionSelectProvider) Providers

func (question QuestionSelectProvider) Providers(h *Handle) PackageList

func (QuestionSelectProvider) SetUseIndex

func (question QuestionSelectProvider) SetUseIndex(index int)

func (QuestionSelectProvider) Type

func (question QuestionSelectProvider) Type() QuestionType

func (QuestionSelectProvider) UseIndex

func (question QuestionSelectProvider) UseIndex() int

type QuestionType

type QuestionType uint
const (
	QuestionTypeInstallIgnorepkg QuestionType = 1 << iota
	QuestionTypeReplacePkg
	QuestionTypeConflictPkg
	QuestionTypeCorruptedPkg
	QuestionTypeRemovePkgs
	QuestionTypeSelectProvider
	QuestionTypeImportKey
)

type SigLevel

type SigLevel int

Signature checking level.

const (
	SigPackage SigLevel = 1 << iota
	SigPackageOptional
	SigPackageMarginalOk
	SigPackageUnknownOk
)
const (
	SigDatabase SigLevel = 1 << (10 + iota)
	SigDatabaseOptional
	SigDatabaseMarginalOk
	SigDatabaseUnknownOk
)
const SigUseDefault SigLevel = 1 << 30

type SigStatus

type SigStatus int

Signature status

const (
	SigStatusValid SigStatus = iota
	SigStatusKeyExpired
	SigStatusSigExpired
	SigStatusKeyUnknown
	SigStatusKeyDisabled
)

type StringList

type StringList struct {
	// contains filtered or unexported fields
}

func (StringList) Empty

func (l StringList) Empty() bool

func (StringList) ForEach

func (l StringList) ForEach(f func(string) error) error

func (StringList) Len

func (l StringList) Len() int

func (StringList) Slice

func (l StringList) Slice() []string

type TransFlag

type TransFlag int
const (
	TransFlagNoDeps TransFlag = 1 << iota
	TransFlagForce
	TransFlagNoSave
	TransFlagNoDepVersion
	TransFlagCascade
	TransFlagRecurse

	TransFlagDBOnly
	TransFlagAllDeps
	TransFlagDownloadOnly
	TransFlagNoScriptlets

	TransFlagNoConflicts
	TransFlagNeeded
	TransFlagAllExplicit
	TransFlagUnneeded
	TransFlagRecurseAll
	TransFlagNoLock
)

type Usage

type Usage int
const (
	UsageSync Usage = 1 << iota
	UsageSearch
	UsageInstall
	UsageUpgrade
	UsageAll = (1 << 4) - 1
)

type Validation

type Validation int
const (
	ValidationNone Validation = 1 << iota
	ValidationMD5Sum
	ValidationSHA256Sum
	ValidationSignature
	ValidationUnkown Validation = 0
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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