pacman

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package pacman provides routines for dealing with Pacman packages.

Index

Constants

This section is empty.

Variables

View Source
var DebugWriter io.Writer = nil

DebugWriter is used to write debugging information from this module. If it is nil, then no debugging messages are printed.

View Source
var PacmanConfPath = "/etc/pacman.conf"

PacmanConfPath contains the path to the pacman configuration. This is provided for those with special needs, such as me ;)

View Source
var PacmanLocalDatabasePath = "/var/lib/pacman/local"

PacmanLocalDatabasePath contains the path to the local pacman library. This is provided for those with special needs to modify at their own risk.

View Source
var PacmanSyncDatabaseFormat = "/var/lib/pacman/sync/%s.db"

PacmanSyncDatabaseFormat is the format that fmt.Sprinf needs to interpolate a repository name into a package database path. This is provided for those with special needs to modify at their own risk.

Functions

func EnabledRepositories

func EnabledRepositories() ([]string, error)

EnabledRepositories returns a list of repository names that are enabled in the `/etc/pacman.conf` system configuration file.

func IsDatabaseLocked

func IsDatabaseLocked(dbpath string) bool

IsDatabaseLocked returns whether the database given at the path is currently locked for writing or not.

func IsRepositoryEnabled

func IsRepositoryEnabled(name string) (bool, error)

IsRepositoryEnabled returns whether the repository named is enabled.

func PkgNewer

func PkgNewer(a, b AnyPackage) bool

PkgNewer returns true if a's version is newer than b's. If b is nil, then true is returned.

func PkgOlder

func PkgOlder(a, b AnyPackage) bool

PkgOlder returns true if a's version is older than b's. If b is nil, then false is returned.

func ReadDirApproxOnlyNames

func ReadDirApproxOnlyNames(h errs.Handler, dirpath string) ([]string, error)

ReadDirApproxOnlyNames returns the names of all packages it finds in a directory.

This does not have the performance issues that ReadEveryFileInDir has.

Types

type AnyPackage

type AnyPackage interface {
	Pkg() *Package
	PkgName() string
	PkgVersion() string
	PkgDepends() []string
	PkgMakeDepends() []string
}

type AnyPackages

type AnyPackages interface {
	Iterate(func(AnyPackage))
	Pkgs() Packages

	Len() int
	Swap(i, j int)
	Less(i, j int) bool
}

type Package

type Package struct {
	// Filename is the file that the package is either read from, or that
	// the package refers to (for example from the database). There is no
	// guarantee over the format of the filename! It could be a partial
	// path or an absolute path.
	Filename string
	Origin   PackageOrigin

	Name            string    // pkgname
	Version         string    // pkgver
	Description     string    // pkgdesc
	Base            string    // pkgbase
	URL             string    // url
	BuildDate       time.Time // builddate
	Packager        string    // packager
	Size            uint64    // size
	Arch            string    // arch: one of any, i686, or x86_64
	License         string    // license
	Backups         []string  // backup
	Replaces        []string  // replaces
	Provides        []string  // provides
	Conflicts       []string  // conflict
	Groups          []string  // group
	Depends         []string  // depend
	OptionalDepends []string  // optdepend
	MakeDepends     []string  // makedepend
	CheckDepends    []string  // checkdepend
	MakeOptions     []string  // makepkgopt
	Xdata           []string  // xdata
}

The Package datatype represents all the information that encompasses a Pacman package, including the filename of the package.

Note: While we could include information from the database or an AUR search, we have decided against it for now. If you feel that this is important, please contact us.

func Read

func Read(filename string) (*Package, error)

Read reads the package information from a pacman package and returns it in the Package datatype.

func (*Package) Equals

func (p *Package) Equals(a *Package) bool

Check if one package is the same as another.

The equality comparisons for the []string attributes are set comparisons.

func (*Package) Newer

func (pkg *Package) Newer(alt *Package) bool

Newer returns true if pkg's version is newer than alt's. If alt is nil, then true is returned. It takes the Epoch value into account.

func (*Package) Older

func (pkg *Package) Older(alt *Package) bool

Older returns true if pkg's version is older than alt's. If alt is nil, then false is returned. It takes the Epoch value into account.

func (*Package) Pkg

func (p *Package) Pkg() *Package

func (*Package) PkgDepends

func (p *Package) PkgDepends() []string

func (*Package) PkgMakeDepends

func (p *Package) PkgMakeDepends() []string

func (*Package) PkgName

func (p *Package) PkgName() string

func (*Package) PkgVersion

func (p *Package) PkgVersion() string

type PackageOrigin

type PackageOrigin int

PackageOrigin exists to document which fields in the Package type can be expected to be filled with data. Note that some fields may be blank because there is nothing to specify, such as MakeDepends.

const (
	// UnknownOrigin specifies unknown origin. No assumption may be made as
	// to what fields are filled.
	UnknownOrigin PackageOrigin = iota

	// FileOrigin specifies package file origin. All fields are filled in as
	// available.
	FileOrigin

	// DatabaseOrigin specifies database origin. All fields are filled in as
	// available.
	DatabaseOrigin

	// LocalOrigin specifies local origin. Not sure what fields are filled in.
	LocalOrigin

	// AUROrigin specifies AUR search origin. Only the following fields are
	// touched:
	//
	// 	Name
	//  Base
	// 	Version
	// 	Description
	// 	URL
	// 	License
	AUROrigin
)

type Packages

type Packages []*Package

Packages is merely a list of packages

func ReadAllSyncDatabases

func ReadAllSyncDatabases() (Packages, error)

ReadAllSyncDatabases reads all locally synced databases, using /etc/pacman.conf to determine which ones to read.

func ReadDatabase

func ReadDatabase(dbpath string) (Packages, error)

ReadDatabase reads all the packages from a database file.

func ReadDir

func ReadDir(h errs.Handler, dirpath, dbpath string) (Packages, error)

ReadDir reads all packages that are found in the repository directory.

func ReadEveryFileInDir

func ReadEveryFileInDir(h errs.Handler, dirpath string) (Packages, error)

ReadEveryFileInDir reads all the packages it finds in a directory.

Note: this will try to read each package, and currently it does this in an inefficient manner, decompressing the entire package in memory. Even a directory with only a few files will take a while to process.

func ReadFiles

func ReadFiles(h errs.Handler, pkgfiles ...string) (Packages, error)

ReadFiles reads all the given package files.

func ReadLocalDatabase

func ReadLocalDatabase(eh errs.Handler) (Packages, error)

ReadLocalDatabase reads the database of locally installed packages.

Note: Even if an error occurs, all successfully read packages will be returned.

Note: Errors that occur are passed to the error handler eh, and it is highly recommended that eh always return nil; else reading the local database will be aborted during reading.

func ReadNames

func ReadNames(h errs.Handler, dirpath string, pkgnames ...string) (Packages, error)

ReadNames reads all packages with one of the given names in a directory.

func ReadSyncDatabase

func ReadSyncDatabase(name string) (Packages, error)

ReadSyncDatabase reads one of the package databases synced by pacman, such as "core", "extra", "community", and so on.

It also reads "/etc/pacman.conf" to make sure that the repository is enabled.

func (Packages) Iterate

func (pkgs Packages) Iterate(f func(AnyPackage))

func (Packages) Len

func (pkgs Packages) Len() int

func (Packages) Less

func (pkgs Packages) Less(i, j int) bool

func (Packages) Pkgs

func (pkgs Packages) Pkgs() Packages

func (Packages) Swap

func (pkgs Packages) Swap(i, j int)

func (Packages) ToMap

func (pkgs Packages) ToMap() map[string]*Package

Directories

Path Synopsis
Package alpm works with parts of Arch Linux packages.
Package alpm works with parts of Arch Linux packages.
Package aur lets you query the Arch Linux User Repository (AUR).
Package aur lets you query the Arch Linux User Repository (AUR).
Package graph provides dependency resolution for AUR packages.
Package graph provides dependency resolution for AUR packages.
Package meta binds together the three places a package can reside: filesystem, database, and internet.
Package meta binds together the three places a package can reside: filesystem, database, and internet.
Package pkgutil provides useful functions for working with packages.
Package pkgutil provides useful functions for working with packages.

Jump to

Keyboard shortcuts

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