dpkg.v1: maze.io/x/dpkg.v1 Index | Files

package dpkg

import "maze.io/x/dpkg.v1"

Package dpkg contains routines to parse Debian package information.

Example:

package main

import (
	"fmt"
	"os"

	dpkg "maze.io/dpkg.v1"
)

func main() {
	db, err := dpkg.Open()
	if err != nil {
		fmt.Fprintf(os.Stderr, "dpkg open failed: %v\n", err)
		os.Exit(1)
	}

	fmt.Println("installed packages:")
	for _, pkg := range db.PackagesWithStatus("installed") {
		fmt.Printf("%s-%s\n", pkg.Name, pkg.Version)
	}
}

Index

Package Files

constant.go dpkg.go field.go marhal.go package.go

Constants

const (
    DependancySuggests = iota
    DependancyRecommends
    DependancyDepends
    DependancyPreDepends
    DependancyBreaks
    DependancyConflicts
    DependancyProvides
    DependancyReplaces
    DependancyEnhances
)

dpkg deptype

const (
    PriorityRequired = iota
    PriorityImportant
    PriorityStandard
    PriorityOptional
    PriorityExtra
    PriorityOther
    PriorityUnknown
    PriorityUnset = -1
)

dpkg pkgpriority

const (
    FlagOK = iota
    FlagReinstallRequired
)

dpkg pkgflag

const (
    StatusNotInstalled = iota
    StatusConfigFiles
    StatusHalfInstalled
    StatusUnpacked
    StatusHalfConfigured
    StatusTriggersAwaited
    StatusTriggersPending
    StatusInstalled
)

dpkg pkgstatus

const (
    WantUnknown = iota
    WantInstall
    WantHold
    WantDeinstall
    WantPurge
)

dpkg pkgwant

const (
    Earlier       = 0001
    Later         = 0002
    Strict        = 0010
    OrEqual       = 0020
    BuiltUp       = 0100
    None          = 0200
    EarlierEqual  = BuiltUp | Earlier | OrEqual
    EarlierStrict = BuiltUp | Earlier | Strict
    LaterEqual    = BuiltUp | Later | OrEqual
    LaterStrict   = BuiltUp | Later | Strict
    Exact         = 0400
)

dpkg depverrel

Variables

var (
    // Path is the default location of the dpkg metadata.
    Path = "/var/lib/dpkg"

    // ArchFile is the default name of the dpkg arch file.
    ArchFile = "arch"

    // InfoFile is the default name of the dpkg info file.
    InfoFile = "info"

    // StatusFile is the default name of the dpkg status file.
    StatusFile = "status"
)

func UnmarshalRFC822 Uses

func UnmarshalRFC822(b []byte) (kv map[string]string, err error)

UnmarshalRFC822 maps aRFC822 style "headers" to key-value pairs.

type Conffile Uses

type Conffile struct {
    Name string
    Hash string
}

Conffile is a file with a checksum in the package.

type Conffiles Uses

type Conffiles []Conffile

Conffiles slice of Conffile.

func (*Conffiles) Parse Uses

func (f *Conffiles) Parse(s string) (err error)

Parse conffiles in a package.

func (Conffiles) String Uses

func (f Conffiles) String() string

type DB Uses

type DB struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

DB hold a dpkg database.

func Open Uses

func Open() (*DB, error)

Open the default dpkg database and parse the metadata.

func OpenFile Uses

func OpenFile(name string) (*DB, error)

OpenFile opens a dpkg-style database from a location.

func (*DB) Contains Uses

func (db *DB) Contains(name string) bool

Contains checks if the database contains a package by name.

func (*DB) Package Uses

func (db *DB) Package(name string) (*Package, bool)

Package lookup by name.

func (*DB) Packages Uses

func (db *DB) Packages() []*Package

Packages returns all packages in the database.

func (*DB) PackagesWithStatus Uses

func (db *DB) PackagesWithStatus(status string) []*Package

PackagesWithStatus returns all packages that match a given status.

Example:

for _, pkg := range db.PackagesWithStatus("installed") {
    fmt.Printf("%s-%s\n", pkg.Name, pkg.Version)
}

func (*DB) PackagesWithWant Uses

func (db *DB) PackagesWithWant(want string) []*Package

PackagesWithWant returns all packages that match a given want state.

Example:

for _, pkg := range db.PackagesWithWant("purge") {
    fmt.Printf("%s-%s\n", pkg.Name, pkg.Version)
}

type Dependancies Uses

type Dependancies []Dependancy

Dependancies slice of Dependancy.

func (*Dependancies) Parse Uses

func (f *Dependancies) Parse(s string) (err error)

Parse package dependancies.

func (Dependancies) String Uses

func (f Dependancies) String() string

type Dependancy Uses

type Dependancy struct {
    PackageInfo
    Relation int
    Version  version.Version
    Type     int
}

Dependancy is a relation between two packages.

func (Dependancy) String Uses

func (dep Dependancy) String() string

type Package Uses

type Package struct {
    Name          string
    Essential     bool
    Status        Status
    Priority      string
    Section       string
    InstalledSize int64
    Origin        string
    Maintainer    string
    Bugs          string
    Architecture  string
    Source        string
    Version       string
    Revision      string
    ConfigVersion string
    Replaces      Dependancies
    Provides      Dependancies
    Depends       Dependancies
    PreDepends    Dependancies
    Recommends    Dependancies
    Suggests      Dependancies
    Breaks        Dependancies
    Conflicts     Dependancies
    Enhances      Dependancies
    Conffiles     Conffiles
    Filename      string
    Size          int64
    MD5sum        string
    Description   string
    Extra         map[string]string
}

Package describes a package in the dpkg database. Fields as described in dpkg/lib/dpkg/parse.c

func UnmarshalPackage Uses

func UnmarshalPackage(b []byte) (pkg *Package, err error)

UnmarshalPackage unmarshals a package from an RFC822 style chunk.

func (Package) Changes Uses

func (pkg Package) Changes() (names []string, err error)

Changes lists installed files that don't pass the recorded checksum.

type PackageInfo Uses

type PackageInfo struct {
    Name     string
    Want     int
    Status   int
    Priority int
    Section  string
    Version  string
    Revision string
}

PackageInfo is part of the Dependancy information.

type Parser Uses

type Parser interface {
    Parse(string) error
    String() string
}

Parser can parse fields.

type Status Uses

type Status struct {
    Want   string
    Flag   string
    Status string
}

Status is a package status.

func (*Status) Parse Uses

func (f *Status) Parse(s string) error

Parse package status.

func (*Status) String Uses

func (f *Status) String() string

type Version Uses

type Version version.Version

Version is a package version.

func (*Version) Parse Uses

func (f *Version) Parse(s string) error

Parse package version.

func (Version) String Uses

func (f Version) String() string

Package dpkg imports 14 packages (graph). Updated 2019-02-22. Refresh now. Tools for package owners.