binpkg

package
v0.0.0-...-6f7ae65 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package binpkg manages binary package storage and queries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateIndex

func GenerateIndex(pkgDir, arch string) (int, error)

GenerateIndex scans pkgDir for binary packages and writes a valid Packages index at pkgDir/Packages. arch is the default ARCH advertised in the preamble (e.g. "amd64"); it may be empty. It returns the number of packages indexed.

func MergePackagesIndexes

func MergePackagesIndexes(
	previous, current []byte,
	arch string,
	timestamp time.Time,
) ([]byte, error)

MergePackagesIndexes creates a complete Packages index by overlaying current job stanzas on the previously published generation. PATH is the immutable package identity, so an exact-path rebuild replaces only that stanza.

Types

type Package

type Package struct {
	Name         string            `json:"name"`
	Version      string            `json:"version"`
	Arch         string            `json:"arch"`
	UseFlags     []string          `json:"use_flags"`
	Dependencies []string          `json:"dependencies"`
	Path         string            `json:"path"`
	Checksum     string            `json:"checksum"`
	Metadata     map[string]string `json:"metadata"`
}

Package represents a binary package.

type QueryRequest

type QueryRequest struct {
	Name      string   `json:"name"`
	Version   string   `json:"version"`
	Arch      string   `json:"arch"`
	UseFlags  []string `json:"use_flags"`
	ProfileID string   `json:"profile_id,omitempty"`
}

QueryRequest represents a package query request.

type QueryResponse

type QueryResponse struct {
	Found       bool     `json:"found"`
	Package     *Package `json:"package,omitempty"`
	ProfileID   string   `json:"profile_id,omitempty"`
	BinhostPath string   `json:"binhost_path,omitempty"`
}

QueryResponse represents a package query response.

type Store

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

Store manages an in-memory queryable view of the binary packages on disk (the PKGDIR served as a binhost). It is populated and kept fresh by RegenerateIndex, which scans the PKGDIR while (re)writing the Portage Packages index — one scan feeds both emerge clients and the JSON query API.

func NewStore

func NewStore(basePath string) *Store

NewStore creates a new package store. The in-memory view starts empty and is filled by the first RegenerateIndex call (the server does this at startup and on a refresh interval).

func (*Store) Add

func (s *Store) Add(pkg *Package) error

Add adds (or replaces) a package in the store.

func (*Store) BasePath

func (s *Store) BasePath() string

BasePath returns the on-disk PKGDIR this store manages. It is served to emerge clients as a binhost.

func (*Store) GetPath

func (s *Store) GetPath(pkg *Package) string

GetPath returns the on-disk path for a package. Packages ingested from the index carry their real relative path; the legacy layout is kept as a fallback for hand-constructed Package values.

func (*Store) LoadPackagesIndex

func (s *Store) LoadPackagesIndex(document []byte, arch string) (int, error)

LoadPackagesIndex refreshes the query/search projection from a trusted, digest-verified object generation without materializing every package.

func (*Store) PromoteStaged

func (s *Store) PromoteStaged(stagingRoot string, rels []string, arch string) ([]string, error)

PromoteStaged atomically copies a verified set of package files from a staging directory. Keeping the source until the durable publish-phase commit makes crash replay possible. Exact existing destinations are idempotent; different content at an immutable location is rejected.

func (*Store) Query

func (s *Store) Query(req *QueryRequest) (*Package, bool)

Query searches for a package matching the request. Version may be empty ("is any version of this package available?" — the natural binhost query), in which case the newest matching version is returned. Arch may be empty to match any architecture.

func (*Store) RegenerateIndex

func (s *Store) RegenerateIndex(arch string) (int, error)

RegenerateIndex rebuilds the Portage "Packages" index from the binary packages currently on disk so that `emerge --getbinpkg` can consume this server as a binhost, and refreshes the in-memory query view from the same scan. arch is the default ARCH advertised in the index and assigned to scanned packages. Returns the number of packages indexed.

func (*Store) Snapshot

func (s *Store) Snapshot() []*Package

Snapshot returns a detached view of every package currently advertised by this store. Callers can safely sort and filter the result without holding a store lock or mutating the query index.

Jump to

Keyboard shortcuts

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