NBPR.Buildroot.SystemSource (NBPR v0.2.1)

Copy Markdown View Source

Resolves a path to the full source tree of an active Nerves system, fetching from GitHub when the user has the Hex tarball (which deliberately omits Config.in and patches/).

Why

Source-build needs the system's full source tree:

  • Config.in — referenced by nerves_system_br/Config.in
  • nerves_defconfig — the system's BR defconfig
  • patches/buildroot/** — Nerves' BR patches

Hex tarballs of nerves_system_* exclude Config.in and patches/ because Hex consumers use the prebuilt artefact, not source. NBPR users frequently only have the Hex dep — we transparently fetch the equivalent source from GitHub the first time source-build runs for that (system, version) tuple.

Cache

Extracted GitHub source lives at:

<data_dir>/nbpr/system-source/<system_app>-<system_version>/

with a .nbpr-ready marker file once extraction completes successfully. Idempotent across runs.

Summary

Functions

Returns a path to a full source tree for system_app at system_version.

Functions

ensure!(system_app, system_version)

@spec ensure!(atom(), String.t()) :: Path.t()

Returns a path to a full source tree for system_app at system_version.

If the user's deps/<system_app>/ already has Config.in (git/path dep, or Hex with patches), returns that. Otherwise fetches the GitHub tarball for the matching tag, caches it under <data_dir>/nbpr/system-source/, and returns the cache path.

Raises if the GitHub URL can't be discovered from hex_metadata.config or the tarball can't be downloaded.