yapdb

package
v2.1.5 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package yapdb provides a state tracker for packages installed by YAP.

It maintains a SQLite database of installed packages, their files, and capabilities (provides, requires, conflicts, obsoletes). This allows YAP to track installations across builds without modifying the system rpmdb, apk database, or dpkg status file.

The database is stored at <rootDir>/var/lib/yap/installed.db by default. It is used by pkg/dnfinstall, pkg/aptinstall, and pkg/apkindex to record what was installed and enable conflict detection and uninstall tracking.

Schema version 1 is the current stable version.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = stderrors.New("yapdb: package not found")

ErrNotFound is returned by lookup methods when the requested record does not exist in the database.

Functions

func DefaultPath

func DefaultPath(rootDir string) string

DefaultPath returns the canonical state DB path for a given rootDir. If rootDir is empty or "/", uses /var/lib/yap/installed.db. Otherwise uses <rootDir>/var/lib/yap/installed.db.

Types

type Capability

type Capability struct {
	Kind    string // "provide" | "require" | "obsolete" | "conflict"
	Name    string
	Flags   int
	Version string
}

Capability represents a provides/requires/conflicts/obsoletes entry.

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB wraps the sqlc-generated queries and provides a high-level API for managing the YAP installed package registry.

func Open

func Open(ctx context.Context, path string) (*DB, error)

Open opens or creates the state DB at the given path. If path is empty, uses DefaultPath(""). Auto-creates parent directories and initializes schema if needed.

func (*DB) Close

func (d *DB) Close() error

Close releases the DB handle.

func (*DB) Insert

func (d *DB) Insert(ctx context.Context, p *Package) error

Insert adds or replaces an installed package record. If a package with the same name+arch already exists, it is replaced atomically (old files and caps are deleted via CASCADE).

func (*DB) IsInstalled

func (d *DB) IsInstalled(ctx context.Context, name string) (bool, error)

IsInstalled reports whether a package is recorded by name.

func (*DB) List

func (d *DB) List(ctx context.Context) ([]Package, error)

List returns all installed packages (without files/caps to keep it cheap).

func (*DB) LookupByName

func (d *DB) LookupByName(ctx context.Context, name, arch string) (*Package, error)

LookupByName returns the package record with files and caps. Returns (nil, ErrNotFound) if no package matches name+arch.

func (*DB) ProvidersOf

func (d *DB) ProvidersOf(ctx context.Context, capName string) ([]string, error)

ProvidersOf returns package names that provide the given capability.

func (*DB) Remove

func (d *DB) Remove(ctx context.Context, name, arch string) error

Remove deletes a package record by name and arch (cascades to files and caps).

type File

type File struct {
	Path       string
	Mode       os.FileMode
	IsDir      bool
	IsSymlink  bool
	LinkTarget string
	SHA256     string
}

File represents a file placed on disk by a package.

type Package

type Package struct {
	Name        string
	Epoch       string
	Version     string
	Release     string
	Arch        string
	Format      string // "rpm" | "deb" | "apk" | "pacman"
	Summary     string
	InstallTime time.Time
	Files       []File
	Caps        []Capability
}

Package represents an installed package record.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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