rpm

package
v1.5.48 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package rpm allows for inspecting RPM databases in BerkleyDB, NDB, and SQLite formats.

Index

Constants

View Source
const Version = "10"

Variables

This section is empty.

Functions

func FindDBs

func FindDBs(ctx context.Context, sys fs.FS) (iter.Seq[FoundDB], func() error)

FindDBs walks the passed fs.FS looking for any files that seem to be rpm databases.

The returned iterator closes over the passed fs.FS. The returned FoundDB values are only valid to use with the same fs.FS value.

Types

type Database

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

Database is a handle to an RPM database.

func OpenDB

func OpenDB(ctx context.Context, sys fs.FS, found FoundDB) (*Database, error)

OpenDB attempts to open the database pointed to by "found."

func (*Database) Close

func (db *Database) Close() error

func (*Database) Packages

func (db *Database) Packages(ctx context.Context) iter.Seq2[claircore.Package, error]

Packages creates an iterator over the packages in the RPM database, translated to [claircore.Package]s.

Continuing the sequence after an error is reported skips the current package and processes the next one.

The returned iterator is single-use.

func (*Database) String

func (db *Database) String() string

type FoundDB

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

FoundDB is a pointer to a probable rpm database found in an fs.FS.

func (FoundDB) String

func (f FoundDB) String() string

String implements fmt.Stringer.

type HeaderReader

type HeaderReader interface {
	Headers(context.Context) iter.Seq2[io.ReaderAt, error]
}

HeaderReader is the interface implemented for in-process RPM database handlers.

type Info

type Info struct {
	Name      string
	Version   string
	Release   string
	SourceRPM string
	Module    string
	Arch      string
	Digest    string
	Signature []byte // This is a PGP signature packet.

	DigestAlgo int
	Epoch      int
	// contains filtered or unexported fields
}

Info is the package information extracted from the RPM header.

func (*Info) Filenames

func (i *Info) Filenames() iter.Seq[string]

Filenames returns an iterator over all paths in the Info.

The returned paths are fs.FS-valid.

func (*Info) Hint

func (i *Info) Hint() string

Hint constructs a string suitable to be used as the "RepositoryHint".

func (*Info) InsertIntoSet

func (i *Info) InsertIntoSet(s *PathSet)

InsertIntoSet inserts filtered "relevant" paths into the provided PathSet.

func (*Info) Load

func (i *Info) Load(ctx context.Context, h *rpmdb.Header) error

Load populates the receiver with information extracted from the provided rpmdb.Header.

func (*Info) ModuleStream

func (i *Info) ModuleStream() string

ModuleStream reports the module and stream from the full module version.

It returns the empty string if the Info does not describe a package from a module.

func (*Info) NEVRA

func (i *Info) NEVRA() rpmver.Version

NEVRA constructs a Name-Epoch-Version-Release-Architecture rpmver.Version.

type PathSet

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

PathSet is used to check if a path is an RPM-owned file.

func NewPathSet

func NewPathSet(ctx context.Context, layer *claircore.Layer) (*PathSet, error)

NewPathSet returns a PathSet for the provided layer.

func (*PathSet) Contains

func (s *PathSet) Contains(p string) bool

Contains reports true if the given path exists in the set of paths that are considered to be RPM files in the layer this PathSet was created for.

func (*PathSet) GoString

func (s *PathSet) GoString() string

GoString implements fmt.GoStringer.

Notes

Bugs

  • Can't reliably populate the source: there's no NEVR information, just a filename that (by convention) is the NVRA. There's an in-flight PR to rpm to add this information. This package should be updated when that's merged.

Directories

Path Synopsis
Package bdb provides support for read-only access to an RPM database using the BerkeleyDB "hash" format.
Package bdb provides support for read-only access to an RPM database using the BerkeleyDB "hash" format.
Package ndb provides support for read-only access to an RPM "ndb" database.
Package ndb provides support for read-only access to an RPM "ndb" database.
See the reference material at https://rpm-software-management.github.io/rpm/manual/.
See the reference material at https://rpm-software-management.github.io/rpm/manual/.
Package sqlite extracts RPM package information from SQLite databases.
Package sqlite extracts RPM package information from SQLite databases.

Jump to

Keyboard shortcuts

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