pacman

package
v0.0.0-...-0376054 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

README

Go pacman

This library aims to provide concurrent, stable and extensible interface to interact with arch package manager - pacman. Library is top-level wrapper and making direct calls to pacman, so it has to be installed on host machine.

Some of the default options for functions can contain sudo, if you don't need it you can manually disable it.

Functions:

  • Sync - syncronize packages
import "fmnx.su/dancheg97/pacman"

func main() {
	err := pacman.Sync("nano")
	fmt.Println(err)
}
  • Search - search for packages in pacman databases
import "fmnx.su/dancheg97/pacman"

func main() {
	r, err := pacman.Search("vim")
	fmt.Println(r)
	fmt.Println(err)
}
  • Upgrade - install packages from local files
import "fmnx.su/dancheg97/pacman"

func main() {
	err := pacman.Upgrade("nvim-1-1-any.pkg.tar.zst")
	fmt.Println(err)
}
  • Query - list installed packages
import "fmnx.su/dancheg97/pacman"

func main() {
	r, err := pacman.Query()
	fmt.Println(r)
	fmt.Println(err)
}
  • Makepkg - build package
import "fmnx.su/dancheg97/pacman"

func main() {
	err := pacman.Makepkg()
	fmt.Println(err)
}
  • Remove - remove installed packages
import "fmnx.su/dancheg97/pacman"

func main() {
	err := pacman.Remove("emacs")
	fmt.Println(err)
}
  • RepoAdd - add package to local database
import "fmnx.su/dancheg97/pacman"

func main() {
	err := pacman.RepoAdd("localhost.db.tar.gz", "vscodium-1-1-x86_64.pkg.tar.zst")
	fmt.Println(err)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Makepkg

func Makepkg(opts ...MakepkgParameters) error

This command will build a package in directory provided in options. Function is safe for concurrent usage. Can be called from multiple goruotines, when options Install or SyncDeps are false.

func Query

func Query(pkgs []string, opts ...QueryParameters) error

Get information about installed packages.

func RawFileInfo

func RawFileInfo(filepath string) (string, error)

Get raw file infor for provided package using `pacman -Qp`.

func Remove

func Remove(pkgs string, opts ...RemoveParameters) error

Remove packages from system.

func RemoveList

func RemoveList(pkgs []string, opts ...RemoveParameters) error

Remove packages from system.

func RepoAdd

func RepoAdd(dbfile, pkgfile string, opts ...RepoAddParameters) error

This function will add new packages to database. You should provide valid path for database file and path to package you want to add.

func Sync

func Sync(pkgs string, opts ...SyncParameters) error

Executes pacman sync command. This command will read sync options and form command based on first elements from the array.

func SyncList

func SyncList(pkgs []string, opts ...SyncParameters) error

Sync command for package string list.

func Upgrade

func Upgrade(files string, opts ...UpgradeParameters) error

Install packages from files.

func UpgradeList

func UpgradeList(files []string, opts ...UpgradeParameters) error

Install packages from files.

Types

type MakepkgParameters

type MakepkgParameters struct {
	Stdout io.Writer
	Stderr io.Writer
	Stdin  io.Reader

	// Additional parameters, that will be appended to command as arguements.
	AdditionalParams []string
	// Directory where process will be executed.
	Dir string
	// Specify a key to use for gpg signing instead of the default. [--key <key>]
	GpgKey string
	// Use an alternate build script (not 'PKGBUILD'). [-p <file>]
	File string
	// Ignore incomplete arch field in PKGBUILD. [--ignorearch]
	IgnoreEach bool
	// Clean up work files after build. [--clean]
	Clean bool
	// Remove $srcdir/ dir before building the package. [--cleanbuild]
	CleanBuild bool
	// Skip all dependency checks. [--nodeps]
	NoDeps bool
	// Do not extract source files (use existing $srcdir/ dir). [--noextract]
	NoExtract bool
	// Overwrite existing package. [--force]
	Force bool
	// Generate integrity checks for source files. [--geninteg]
	Geinteg bool
	// Install package after successful build. [--install]
	Install bool
	// Log package build process. [--log]
	Log bool
	// Disable colorized output messages. [--nocolor]
	NoColor bool
	// Download and extract files only. [--nobuild]
	NpBuild bool
	// Remove installed dependencies after a successful build. [--rmdeps]
	RmDeps bool
	// Repackage contents of the package without rebuilding. [--repackage]
	Repackage bool
	// Install missing dependencies with pacman. [--syncdeps]
	SyncDeps bool
	// Use an alternate config file (not '/etc/makepkg.conf'). [--config <file>]
	Config string
	// Do not update VCS sources. [--holdver]
	HoldVer bool
	// Do not create package archive. [--noarchive]
	NoArchive bool
	// Do not run the check() function in the PKGBUILD. [--nocheck]
	NoCheck bool
	// Do not run the prepare() function in the PKGBUILD. [--noprepare]
	NoPrepare bool
	// Do not create a signature for the package. [--nosign]
	NoSign bool
	// Sign the resulting package with gpg. [--sign]
	Sign bool
	// Do not verify checksums of the source files. [--skipchecksums]
	SkipCheckSums bool
	// Do not perform any verification checks on source files. [--skipinteg]
	SkipIntegrityChecks bool
	// Do not verify source files with GPG signatures. [--skippgpcheck]
	SkipPgpCheck bool
	// Do not reinstall up to date packages. [--needed]
	Needed bool
	// Do not ask for any confirmation. [--noconfirm]
	NoConfirm bool
	// Do not show a progress bar when downloading files. [--noprogressbar]
	NoProgressBar bool
	// Install packages as non-explicitly installed. [--asdeps]
	AsDeps bool
}

Options for building packages.

type OutdatedPackage

type OutdatedPackage struct {
	Name           string
	CurrentVersion string
	NewVersion     string
}

Outdated package.

func Outdated

func Outdated() ([]OutdatedPackage, error)

Get information about outdated packages.

type PackageInfo

type PackageInfo struct {
	Name    string
	Version string
}

type PackageInfoFull

type PackageInfoFull struct {
	Name          string
	Version       string
	Description   string
	Architecture  string
	URL           string
	Licenses      string
	Groups        string
	Provides      string
	DependsOn     string
	OptionalDeps  string
	RequiredBy    string
	OptionalFor   string
	ConflictsWith string
	Replaces      string
	InstalledSize string
	Packager      string
	BuildDate     string
	InstallDate   string
	InstallReason string
	InstallScript string
	ValidatedBy   string
}

func Info

func Info(pkg string) (*PackageInfoFull, error)

Get info about package.

type QueryParameters

type QueryParameters struct {
	Stdout io.Writer
	Stderr io.Writer
	Stdin  io.Reader

	// List packages explicitly installed.
	Explicit bool
	// List packages installed as dependencies.
	Deps bool
	// Query only for packages installed from official repositories.
	Native bool
	// Query for packages installed from other sources.
	Foreign bool
	// Unrequired packages (not a dependency for other one).
	Unrequired bool
	// View all members of a package group.
	Groups bool
	// View package information (-ii for backup files).
	Info []bool
	// Check that package files exist (-kk for file properties).
	Check []bool
	// List the files owned by the queried package.
	List []bool
	// Query a package file instead of the database.
	File string
	// List packages to upgrade. [-u]
	Upgrade bool
	// Additional queue parameters.
	AdditionalParams []string
}

Query parameters for pacman packages.

func QueryDefault

func QueryDefault() *QueryParameters

type RemoveParameters

type RemoveParameters struct {
	Stdout io.Writer
	Stderr io.Writer
	Stdin  io.Reader

	// Run with sudo priveleges. [sudo]
	Sudo bool
	// Do not ask for any confirmation. [--noconfirm]
	NoConfirm bool
	// Remove with all unnecessary packages. [--recursive]
	Recursive bool
	// Remove with all explicitly installed deps. [-ss]
	ForceRecursive bool
	// Use cascade when removing packages. [--cascade]
	Cascade bool
	// Remove configuration files aswell. [--nosave]
	WithConfigs bool
	// Additional parameters, that will be appended to command as arguements.
	AdditionalParams []string
}

Optional parameters for pacman remove command.

func RemoveDefault

func RemoveDefault() *RemoveParameters

type RepoAddParameters

type RepoAddParameters struct {
	Stdout io.Writer
	Stderr io.Writer
	Stdin  io.Reader

	// Additional parameters, that will be appended to command as arguements.
	AdditionalParams []string
	// Run with sudo priveleges. [sudo]
	Dir string
	// Use the specified key to sign the database. [--key <file>]
	Key string
	// Skip existing and add only new packages. [--new]
	Sudo bool
	// Directory where process will be executed.
	New bool
	// Remove old package file from disk after updating database. [--remove]
	Remove bool
	// Do not add package if newer version exists. [--prevent-downgrade]
	PreventDowngrade bool
	// Turn off color in output. [--nocolor]
	NoColor bool
	// Sign database with GnuPG after update. [--sign]
	Sign bool
	// Verify database signature before update. [--verify]
	Verify bool
}

Parameters for adding packages to pacman repo.

func RepoAddDefaultOptions

func RepoAddDefaultOptions() *RepoAddParameters

type SearchOptions

type SearchOptions struct {
	// Run with sudo priveleges. [sudo]
	Sudo bool
	// Download fresh package databases from the server. [--refresh]
	Refresh bool
	// Stdin from user is command will ask for something.
	Stdin io.Reader
}

Options to apply when searching for some package.

func SearchDefault

func SearchDefault() *SearchOptions

type SearchResult

type SearchResult struct {
	Repo    string
	Name    string
	Version string
	Desc    string
}

Structure to recieve from search result

func Search(re string, opts ...SearchOptions) ([]SearchResult, error)

Search for packages.

type SyncParameters

type SyncParameters struct {
	Stdout io.Writer
	Stderr io.Writer
	Stdin  io.Reader

	// Run with sudo priveleges. [sudo]
	Sudo bool
	// Do not reinstall up to date packages. [--needed]
	Needed bool
	// Do not ask for any confirmation. [--noconfirm]
	NoConfirm bool
	// Do not show a progress bar when downloading files. [--noprogressbar]
	NoProgressBar bool
	// Do not execute the install scriptlet if one exists. [--noscriptlet]
	NoScriptlet bool
	// Use relaxed timout when loading packages. [--disable-download-timeout]
	NoTimeout bool
	// Install packages as non-explicitly installed. [--asdeps]
	AsDeps bool
	// Install packages as explictly installed. [--asexplict]
	AsExplict bool
	// Download fresh package databases from the server. [--refresh]
	Refresh []bool
	// Upgrade programms that are outdated. [--sysupgrade]
	Upgrade []bool
	// View a list of packages in a repo. [--list]
	List []bool
	// Only download, but do not install package. [--downloadonly]
	DownloadOnly bool
	// Clean old packages from cache directory. [--clean]
	Clean bool
	// Clean all packages from cache directory. [-cc]
	CleanAll bool
	// Additional parameters, that will be appended to command as arguements.
	AdditionalParams []string
}

Optional parameters for pacman sync command.

func SyncDefault

func SyncDefault() *SyncParameters

type UpgradeParameters

type UpgradeParameters struct {
	Stdout io.Writer
	Stderr io.Writer
	Stdin  io.Reader

	// Run with sudo priveleges. [sudo]
	Sudo bool
	// Do not reinstall up to date packages. [--needed]
	Needed bool
	// Do not ask for any confirmation. [--noconfirm]
	NoConfirm bool
	// Do not show a progress bar when downloading files. [--noprogressbar]
	NoProgressBar bool
	// Do not execute the install scriptlet if one exists. [--noscriptlet]
	NoScriptlet bool
	// Install packages as non-explicitly installed. [--asdeps]
	AsDeps bool
	// Install packages as explictly installed. [--asexplict]
	AsExplict bool
	// Additional parameters, that will be appended to command as arguements.
	AdditionalParams []string
}

Options to apply when searching for some package.

func UpgradeDefault

func UpgradeDefault() *UpgradeParameters

Jump to

Keyboard shortcuts

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