Documentation
¶
Index ¶
- func ActiveStoreDirs(pkgs map[string]string, storeRoot string) []string
- func ActiveVersions(pkgs map[string]string, storeRoot string) map[string]string
- func Build(pkgs map[string]string, galeDir, storeRoot string) error
- func Current(galeDir string) (int, error)
- func CurrentVersions(galeDir, storeRoot string) (map[string]string, error)
- func FarmStoreDirs(pkgs map[string]string, storeRoot string) []string
- func PruneOldGenerations(galeDir, storeRoot string, keep int) ([]int, error)
- func Resolve(galeDir string) (int, string, error)
- func Rollback(galeDir, storeRoot string, target int) error
- type GenDiff
- type GenInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActiveStoreDirs ¶ added in v0.13.1
ActiveStoreDirs resolves each (name, version) in pkgs to its on-disk store dir. Returned in an arbitrary order. Seeds FarmStoreDirs, which Build and `gale doctor` use for the shared dylib farm.
func ActiveVersions ¶ added in v0.16.3
ActiveVersions resolves each (name, version) in pkgs to the store-dir basename ("<version>-<revision>", or a bare "<version>" for legacy pre-revision installs) that a fresh Build would link against. Used by `gale doctor` to compare against CurrentVersions — which reads the active gen's actual symlink targets — and surface revision drift when the gen carries a stale link to an older revision.
func Build ¶
Build creates a new generation from the package map and atomically swaps the current symlink. Packages whose store dir is missing are silently skipped with a warning on stderr: gale.toml legitimately lists packages that aren't installed locally (`gale add` without sync, a fresh clone on a new host, an unsupported-platform skip), and erroring the rebuild would desync PATH from config (gh#68). The missing package is reported on stderr so the user learns which package fell off PATH. Previous generations are retained for history and rollback.
func Current ¶
Current returns the active generation number by resolving the current symlink. Returns 0 if no current generation exists.
func CurrentVersions ¶ added in v0.16.3
CurrentVersions returns the package name → version map of the active generation by reading its symlinks. Returns an empty map (no error) when no generation is active yet. Used by sync to detect whether gale.toml has drifted from the active generation — drift means the rebuild must run even if no installs happened, so removed packages drop off PATH.
func FarmStoreDirs ¶ added in v0.17.0
FarmStoreDirs returns the store dirs whose versioned dylibs belong in the shared farm: the resolved dir for every package in pkgs plus the transitive dep closure recorded in each dir's .gale-deps.toml. Runtime deps are farmed at install time but never appear in gale.toml, so rebuilding the farm from the config set alone deletes the entries dependents' rpaths resolve through (gh#43). Dep dirs missing from the store are skipped — the farm can only link what's on disk. Visited dirs are not re-expanded, so dep cycles terminate.
func PruneOldGenerations ¶ added in v0.16.3
PruneOldGenerations removes generation directories older than (curGen - keep + 1), preserving the most recent `keep` gens (including the current one). Anything at or above curGen — including any in-flight gen/curGen+1 a concurrent Build may have created — is preserved. Holds the store-rooted gen lock for its critical section so it serializes with Build.
Returns the removed gen numbers in ascending order so the caller can report them. keep<=0 or no current symlink is a no-op (returns nil).
Intended as an auto-gc hook after Build: callers pass the user-configured retention (default 10) so per-install gen accumulation can't drown the filesystem in inodes (the dev- host incident with ~3M gen/ inodes across 33 untouched gens).
func Resolve ¶ added in v0.16.3
Resolve is Current plus a target-existence check. It returns (gen, relTarget, nil) when the current symlink points at an extant gen directory, (0, "", nil) when no current symlink exists yet, and a descriptive error when the symlink dangles (target gen directory absent) or its name doesn't parse. `gale doctor` uses this to flag a corrupted current pointer — the case where the active generation has been deleted out from under us by rm -rf, a partial gc, or a half-restored backup — which Current alone cannot detect because it only Readlinks the symlink.