Help us shape the future of Go! Take the 2026 Go Developer Survey

pkgdb

package
v0.37.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package pkgdb reads Portage's installed-package database (/var/db/pkg): one directory per installed package at <root>/<CATEGORY>/<PF>/, holding a SLOT file and, for packages installed from a named repository, a repository file.

Index

Constants

View Source
const DefaultRoot = "/var/db/pkg"

DefaultRoot is where Portage keeps the installed-package database.

Variables

This section is empty.

Functions

This section is empty.

Types

type Package

type Package struct {
	Category string
	Name     string
	// Version keeps the revision (e.g. "1.0-r3") so ebuild.CompareVersions
	// can order it.
	Version string
	// Slot is the part of the SLOT record before "/" (the subslot is dropped).
	Slot string
	// Repo is the repository record, or empty when the package has none
	// (such a package is not installed from any named repository).
	Repo string
}

Package is one installed package.

func Read

func Read(ctx context.Context, root string) (pkgs []Package, skipped int, err error)

Read returns every installed package under root, in directory order (category, then PF, both sorted by name).

An entry that cannot be read — an unreadable category directory, or a package directory whose SLOT or repository record cannot be read — is skipped and counted in skipped, never fatal, so one bad entry does not hide the rest. Entries that are not packages (stray files, directory names without a version part) are ignored without being counted. A missing repository record yields an empty Repo.

err is non-nil only when root itself cannot be listed or ctx is done; it wraps the cause with %w and names root.

type Reader

type Reader struct {
	Root string
}

Reader is the InstalledReader adapter: Installed reads the database at Root.

func (Reader) Installed

func (r Reader) Installed(ctx context.Context) (pkgs []Package, skipped int, err error)

Installed returns what Read returns for r.Root.

Jump to

Keyboard shortcuts

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