Documentation
¶
Overview ¶
Package package manages pre-built runtime packages for unikernel images.
A package is a named, versioned collection of files (typically a language runtime like Node.js or Python) that can be included in a unikernel image during "jerboa build --pkg". Packages are stored locally in ~/.jerboa/packages/<name>/<version>/ and are downloaded from a remote index.
Index ¶
- Variables
- func ArchSlug() string
- func FromDocker(image, containerPath string, extraLibs []string) ([]string, error)
- func Ldd(binaryPath string) ([]string, error)
- func ManifestNeedsUpdate(localPath string) bool
- func MissingFiles(binaryPath string) ([]string, error)
- type File
- type Index
- type OpsPackage
- type OpsPackageIdentifier
- type OpsPackageList
- type OpsPackageManifestConfig
- type OpsStore
- func (s *OpsStore) Download(namespace, name, version string, expectedSHA256 string) error
- func (s *OpsStore) Extract(namespace, name, version string) error
- func (s *OpsStore) ExtractedFiles(namespace, name, version string) ([]File, error)
- func (s *OpsStore) FetchManifestCached() (*OpsPackageList, error)
- func (s *OpsStore) FindBinary(namespace, name, version string) (string, error)
- func (s *OpsStore) IsDownloaded(namespace, name, version string) bool
- func (s *OpsStore) IsExtracted(namespace, name, version string) bool
- func (s *OpsStore) List() ([]OpsPackage, error)
- func (s *OpsStore) LoadCachedManifest() (*OpsPackageList, error)
- func (s *OpsStore) LoadPackageManifest(namespace, name, version string) (*OpsPackageManifestConfig, error)
- func (s *OpsStore) PackageDir(namespace, name, version string) string
- func (s *OpsStore) Remove(namespace, name, version string) error
- func (s *OpsStore) SaveManifest(data []byte) error
- type Package
- type Store
- func (s *Store) Create(name, version, binaryPath string, extraFiles []string, ...) error
- func (s *Store) Download(pkg Package) error
- func (s *Store) Extract(pkg Package) error
- func (s *Store) ExtractedFiles(name, version string) ([]string, error)
- func (s *Store) IsDownloaded(name, version string) bool
- func (s *Store) IsExtracted(name, version string) bool
- func (s *Store) List() ([]Package, error)
- func (s *Store) PackageDir(name, version string) string
- func (s *Store) Push(name, version string, indexURL string) error
- func (s *Store) Remove(name, version string) error
- func (s *Store) RemoveAll(name string) error
- func (s *Store) SaveMeta(pkg Package) error
Constants ¶
This section is empty.
Variables ¶
var IndexURL = "https://github.com/AitorConS/jerboa/releases/download/pkg-index/packages.json"
IndexURL is the base URL for the package index. Can be overridden in tests to point to a local server.
var OpsPackageBaseURL = "https://repo.ops.city/v2/packages"
OpsPackageBaseURL is the base URL for downloading ops packages.
var OpsPackageManifestURL = "https://repo.ops.city/v2/manifest.json"
OpsPackageManifestURL stores info about all ops packages.
var OpsPkghubBaseURL = "https://repo.ops.city"
OpsPkghubBaseURL is the base URL of the ops package hub.
Functions ¶
func ArchSlug ¶
func ArchSlug() string
ArchSlug returns the architecture suffix used by ops packages.
func FromDocker ¶
FromDocker extracts a binary and its shared library dependencies from a Docker image, returning the local file paths. It uses "docker run --rm sh -c cat" to read files directly from the container filesystem, which follows symlinks automatically without creating them on the host — making it work on all platforms including Windows (where docker cp fails with symlinks).
func Ldd ¶
Ldd analyses a binary with ldd and returns its shared library dependencies. Returns the library paths as reported by ldd.
func ManifestNeedsUpdate ¶
ManifestNeedsUpdate checks if the remote manifest has changed by comparing Content-Length via HTTP HEAD. Returns true if update is needed or if check fails (safe default: refresh on error).
func MissingFiles ¶
MissingFiles analyses a binary with ldd and returns library paths that are not present on the local filesystem. Useful for identifying which shared libraries need to be bundled in a package alongside the binary.
Types ¶
type File ¶
File represents a file to be included in a unikernel image, with both its host path (on the build machine) and its guest path (inside the image).
type Index ¶
type Index struct {
// Packages maps package name to its available versions.
Packages map[string][]Package `json:"packages"`
}
Index is the top-level package index structure.
func FetchIndex ¶
FetchIndex downloads and parses the remote package index.
type OpsPackage ¶
type OpsPackage struct {
Version string `json:"version"`
Language string `json:"language"`
Description string `json:"description,omitempty"`
SHA256 string `json:"sha256"`
Name string `json:"name"`
Namespace string `json:"namespace"`
Arch string `json:"arch"`
}
OpsPackage mirrors the ops (nanovms/ops) Package struct from lepton/package.go.
type OpsPackageIdentifier ¶
OpsPackageIdentifier represents a parsed ops package identifier in the format <namespace>/<name>:<version>.
func ParseOpsIdentifier ¶
func ParseOpsIdentifier(identifier string) (OpsPackageIdentifier, error)
ParseOpsIdentifier parses an ops package identifier of the form "<namespace>/<name>:<version>" or "<namespace>/<name>".
func (OpsPackageIdentifier) String ¶
func (id OpsPackageIdentifier) String() string
String returns the canonical identifier string.
type OpsPackageList ¶
type OpsPackageList struct {
Version int `json:"Version"`
Packages []OpsPackage `json:"Packages"`
}
OpsPackageList mirrors the ops PackageList struct — flat array with schema version.
func FetchOpsManifest ¶
func FetchOpsManifest() (*OpsPackageList, error)
FetchOpsManifest downloads and parses the ops package manifest.
func SearchOpsPackages ¶
func SearchOpsPackages(query string) (*OpsPackageList, error)
SearchOpsPackages performs a server-side search against the ops package hub.
func (*OpsPackageList) Lookup ¶
func (l *OpsPackageList) Lookup(namespace, name, version string) *OpsPackage
Lookup finds a package in the manifest by namespace, name, and optional version. If version is empty or "latest", returns the first match for namespace+name. Version matching normalizes "v" prefixes and supports major/minor prefix matching (e.g., "11" matches "v11.5.0", "3.10" matches "3.10.6").
func (*OpsPackageList) Search ¶
func (l *OpsPackageList) Search(query string) []OpsPackage
Search returns packages from the manifest matching the query.
type OpsPackageManifestConfig ¶
type OpsPackageManifestConfig struct {
Program string `json:"Program"`
Args []string `json:"Args"`
Version string `json:"Version"`
Env map[string]string `json:"Env"`
}
OpsPackageManifestConfig represents the package.manifest JSON from an ops package.
type OpsStore ¶
type OpsStore struct {
// contains filtered or unexported fields
}
OpsStore manages locally cached ops packages under a root directory. Ops packages preserve their native format: package.manifest + sysroot/ + top-level binary, stored at root/<namespace>/<name>_<version>/.
func DefaultOpsStore ¶
DefaultOpsStore returns an OpsStore at the default path.
func NewOpsStore ¶
NewOpsStore creates an OpsStore rooted at dir, creating it if needed.
func (*OpsStore) Download ¶
Download fetches an ops package from repo.ops.city and stores it locally. The URL is constructed from OpsPackageBaseURL + /<namespace>/<name>/<version>.tar.gz.
func (*OpsStore) Extract ¶
Extract decompresses the ops package archive into its directory. Ops packages may contain:
- package.manifest (JSON config for ops)
- A top-level binary (the program itself)
- sysroot/ (shared libraries and filesystem layout)
Symlinks are handled on Linux; silently skipped on other platforms.
func (*OpsStore) ExtractedFiles ¶
ExtractedFiles returns the files inside an extracted ops package as File entries with proper guest paths. Files inside sysroot/ get their sysroot- relative path as the guest path; top-level files use their basename. Build-only subtrees (static libs, test suites, etc.) are excluded to keep the image lean — see opsRuntimeBloatDir for the full list.
func (*OpsStore) FetchManifestCached ¶
func (s *OpsStore) FetchManifestCached() (*OpsPackageList, error)
FetchManifestCached downloads the ops manifest only if it has changed since the last fetch, using Content-Length comparison.
func (*OpsStore) FindBinary ¶
FindBinary attempts to find the main binary inside an extracted ops package. It checks the package.manifest for the Program field, then falls back to looking for ELF files at the top level.
func (*OpsStore) IsDownloaded ¶
IsDownloaded returns true if the ops package archive exists locally.
func (*OpsStore) IsExtracted ¶
IsExtracted returns true if the ops package has been extracted and its main binary is present. Checking the binary guards against partial extractions where directory entries were created but the binary was removed (e.g. by AV quarantine) after extraction completed.
func (*OpsStore) List ¶
func (s *OpsStore) List() ([]OpsPackage, error)
List returns all locally cached ops packages.
func (*OpsStore) LoadCachedManifest ¶
func (s *OpsStore) LoadCachedManifest() (*OpsPackageList, error)
LoadCachedManifest reads the locally cached ops manifest.
func (*OpsStore) LoadPackageManifest ¶
func (s *OpsStore) LoadPackageManifest(namespace, name, version string) (*OpsPackageManifestConfig, error)
LoadPackageManifest reads and parses the package.manifest from an extracted ops package directory.
func (*OpsStore) PackageDir ¶
PackageDir returns the local directory for an ops package.
func (*OpsStore) SaveManifest ¶
SaveManifest caches the ops manifest locally.
type Package ¶
type Package struct {
// Name is the package name (e.g. "node", "python", "redis", "nginx").
Name string `json:"name"`
// Version is the semantic version (e.g. "20.11.0").
Version string `json:"version"`
// Description is a short human-readable summary.
Description string `json:"description"`
// Runtime is the runtime family (e.g. "node", "python").
Runtime string `json:"runtime"`
// SHA256 is the expected hex-encoded SHA-256 digest of the archive.
SHA256 string `json:"sha256"`
// Size is the archive size in bytes.
Size int64 `json:"size"`
// URL is the download URL for the package archive.
URL string `json:"url"`
// Created is the publication timestamp.
Created time.Time `json:"created"`
}
Package describes a downloadable runtime package.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages locally cached packages under a root directory.
func (*Store) Create ¶
func (s *Store) Create(name, version, binaryPath string, extraFiles []string, description, runtimeName string) error
Create builds a local package archive from the given binary and optional extra files. It produces files.tar.gz and meta.json in the package store.
func (*Store) Download ¶
Download fetches the package archive from its URL and stores it locally. Verifies size and SHA-256 digest after download.
func (*Store) Extract ¶
Extract decompresses the package archive into a files subdirectory. After extraction the individual files can be listed with ExtractedFiles.
func (*Store) ExtractedFiles ¶
ExtractedFiles returns the absolute paths of all regular files inside the package's extracted files directory.
func (*Store) IsDownloaded ¶
IsDownloaded returns true if the package archive exists locally.
func (*Store) IsExtracted ¶
IsExtracted returns true if the package has been extracted and its files directory is non-empty.
func (*Store) PackageDir ¶
PackageDir returns the local directory for a package version.
func (*Store) Push ¶
Push uploads a local package archive and metadata to a remote package index. The index must accept POST /packages with multipart form data (archive + metadata).