Documentation
¶
Overview ¶
Package binpkg manages binary package storage and queries.
Index ¶
- func GenerateIndex(pkgDir, arch string) (int, error)
- func MergePackagesIndexes(previous, current []byte, arch string, timestamp time.Time) ([]byte, error)
- type Package
- type QueryRequest
- type QueryResponse
- type Store
- func (s *Store) Add(pkg *Package) error
- func (s *Store) BasePath() string
- func (s *Store) GetPath(pkg *Package) string
- func (s *Store) LoadPackagesIndex(document []byte, arch string) (int, error)
- func (s *Store) PromoteStaged(stagingRoot string, rels []string, arch string) ([]string, error)
- func (s *Store) Query(req *QueryRequest) (*Package, bool)
- func (s *Store) RegenerateIndex(arch string) (int, error)
- func (s *Store) Snapshot() []*Package
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateIndex ¶
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 ¶
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) BasePath ¶
BasePath returns the on-disk PKGDIR this store manages. It is served to emerge clients as a binhost.
func (*Store) GetPath ¶
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 ¶
LoadPackagesIndex refreshes the query/search projection from a trusted, digest-verified object generation without materializing every package.
func (*Store) PromoteStaged ¶
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 ¶
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.