packagekit

package
v0.0.0-...-2561dba Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: GPL-3.0 Imports: 8 Imported by: 4

Documentation

Overview

Package packagekit provides an interface to interact with packagekit. See: https://www.freedesktop.org/software/PackageKit/gtk-doc/index.html for more information.

Index

Constants

View Source
const (
	// FIXME: if PkBufferSize is too low, install seems to drop signals
	PkBufferSize = 1000
	// TODO: the PkSignalTimeout value might be too low
	PkSignalPackageTimeout = 60 // 60 seconds, arbitrary
	PkSignalDestroyTimeout = 15 // 15 seconds, arbitrary
	PkPath                 = "/org/freedesktop/PackageKit"
	PkIface                = "org.freedesktop.PackageKit"
	PkIfaceTransaction     = PkIface + ".Transaction"
)

constants which might need to be tweaked or which contain special dbus strings.

View Source
const (
	PkFilterEnumUnknown        uint64 = 1 << iota // "unknown"
	PkFilterEnumNone                              // "none"
	PkFilterEnumInstalled                         // "installed"
	PkFilterEnumNotInstalled                      // "~installed"
	PkFilterEnumDevelopment                       // "devel"
	PkFilterEnumNotDevelopment                    // "~devel"
	PkFilterEnumGui                               // "gui"
	PkFilterEnumNotGui                            // "~gui"
	PkFilterEnumFree                              // "free"
	PkFilterEnumNotFree                           // "~free"
	PkFilterEnumVisible                           // "visible"
	PkFilterEnumNotVisible                        // "~visible"
	PkFilterEnumSupported                         // "supported"
	PkFilterEnumNotSupported                      // "~supported"
	PkFilterEnumBasename                          // "basename"
	PkFilterEnumNotBasename                       // "~basename"
	PkFilterEnumNewest                            // "newest"
	PkFilterEnumNotNewest                         // "~newest"
	PkFilterEnumArch                              // "arch"
	PkFilterEnumNotArch                           // "~arch"
	PkFilterEnumSource                            // "source"
	PkFilterEnumNotSource                         // "~source"
	PkFilterEnumCollections                       // "collections"
	PkFilterEnumNotCollections                    // "~collections"
	PkFilterEnumApplication                       // "application"
	PkFilterEnumNotApplication                    // "~application"
	PkFilterEnumDownloaded                        // "downloaded"
	PkFilterEnumNotDownloaded                     // "~downloaded"
)

type enum_filter uint64 https://github.com/hughsie/PackageKit/blob/master/lib/packagekit-glib2/pk-enum.c

View Source
const (
	PkTransactionFlagEnumNone           uint64 = 1 << iota // "none"
	PkTransactionFlagEnumOnlyTrusted                       // "only-trusted"
	PkTransactionFlagEnumSimulate                          // "simulate"
	PkTransactionFlagEnumOnlyDownload                      // "only-download"
	PkTransactionFlagEnumAllowReinstall                    // "allow-reinstall"
	PkTransactionFlagEnumJustReinstall                     // "just-reinstall"
	PkTransactionFlagEnumAllowDowngrade                    // "allow-downgrade"
)

constants from packagekit c library.

View Source
const (
	PkInfoEnumUnknown uint64 = 1 << iota
	PkInfoEnumInstalled
	PkInfoEnumAvailable
	PkInfoEnumLow
	PkInfoEnumEnhancement
	PkInfoEnumNormal
	PkInfoEnumBugfix
	PkInfoEnumImportant
	PkInfoEnumSecurity
	PkInfoEnumBlocked
	PkInfoEnumDownloading
	PkInfoEnumUpdating
	PkInfoEnumInstalling
	PkInfoEnumRemoving
	PkInfoEnumCleanup
	PkInfoEnumObsoleting
	PkInfoEnumCollectionInstalled
	PkInfoEnumCollectionAvailable
	PkInfoEnumFinished
	PkInfoEnumReinstalling
	PkInfoEnumDowngrading
	PkInfoEnumPreparing
	PkInfoEnumDecompressing
	PkInfoEnumUntrusted
	PkInfoEnumTrusted
	PkInfoEnumUnavailable
	PkInfoEnumLast
)

constants from packagekit c library.

View Source
const (
	Paranoid = false // enable if you see any ghosts
)

global tweaks of verbosity and code path

Variables

This section is empty.

Functions

func FilterPackageIDs

func FilterPackageIDs(m map[string]*PkPackageIDActionData, packages []string) ([]string, error)

FilterPackageIDs returns a list of packageIDs which match the set of package names in packages.

func FilterPackageState

func FilterPackageState(m map[string]*PkPackageIDActionData, packages []string, state string) (result []string, err error)

FilterPackageState returns all packages that are in package and match the specific state.

func FilterState

func FilterState(m map[string]*PkPackageIDActionData, packages []string, state string) (result map[string]bool, err error)

FilterState returns a map of whether each package queried matches the particular state.

func FlagInData

func FlagInData(flag, data string) bool

FlagInData asks whether a flag exists inside the data portion of a packageID field?

func FmtTransactionMethod

func FmtTransactionMethod(method string) string

FmtTransactionMethod builds the transaction method string properly.

func IsMyArch

func IsMyArch(arch string) (bool, error)

IsMyArch determines if a PackageKit architecture matches the current os arch.

Types

type Conn

type Conn struct {
	Debug bool
	Logf  func(format string, v ...interface{})
	// contains filtered or unexported fields
}

Conn is a wrapper struct so we can pass bus connection around in the struct.

func NewBus

func NewBus() *Conn

NewBus returns a new bus connection.

func (*Conn) Close

func (obj *Conn) Close() error

Close closes the dbus connection object.

func (*Conn) CreateTransaction

func (obj *Conn) CreateTransaction() (dbus.ObjectPath, error)

CreateTransaction creates and returns a transaction path.

func (*Conn) GetBus

func (obj *Conn) GetBus() *dbus.Conn

GetBus gets the dbus connection object.

func (*Conn) GetFilesByPackageID

func (obj *Conn) GetFilesByPackageID(packageIDs []string) (files map[string][]string, err error)

GetFilesByPackageID gets the list of files that are contained inside a list of packageIDs.

func (*Conn) GetUpdates

func (obj *Conn) GetUpdates(filter uint64) ([]string, error)

GetUpdates gets a list of packages that are installed and which can be updated, mod filter.

func (*Conn) InstallPackages

func (obj *Conn) InstallPackages(packageIDs []string, transactionFlags uint64) error

InstallPackages installs a list of packages by packageID.

func (*Conn) IsInstalled

func (obj *Conn) IsInstalled(pkg string) (bool, error)

IsInstalled returns if a package is installed. TODO: this could be optimized by making the resolve call directly

func (*Conn) IsInstalledList

func (obj *Conn) IsInstalledList(packages []string) ([]bool, error)

IsInstalledList queries a list of packages to see if they are installed.

func (*Conn) PackagesToPackageIDs

func (obj *Conn) PackagesToPackageIDs(packageMap map[string]string, filter uint64) (map[string]*PkPackageIDActionData, error)

PackagesToPackageIDs is a helper function that *might* be generally useful outside mgmt. The packageMap input has the package names as keys and requested states as values. These states can be: installed, uninstalled, newest or a requested version str.

func (*Conn) RemovePackages

func (obj *Conn) RemovePackages(packageIDs []string, transactionFlags uint64) error

RemovePackages removes a list of packages by packageID.

func (*Conn) ResolvePackages

func (obj *Conn) ResolvePackages(packages []string, filter uint64) ([]string, error)

ResolvePackages runs the PackageKit Resolve method and returns the result.

func (*Conn) UpdatePackages

func (obj *Conn) UpdatePackages(packageIDs []string, transactionFlags uint64) error

UpdatePackages updates a list of packages to versions that are specified.

func (*Conn) WatchChanges

func (obj *Conn) WatchChanges() (chan *dbus.Signal, error)

WatchChanges gets a signal anytime an event happens.

type PkPackageIDActionData

type PkPackageIDActionData struct {
	Found     bool
	Installed bool
	Version   string
	PackageID string
	Newest    bool
}

PkPackageIDActionData is a struct that is returned by PackagesToPackageIDs in the map values.

Jump to

Keyboard shortcuts

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