Source-builds an NBPR package artefact tarball end-to-end.
Driven from both Mix.Tasks.Nbpr.Build (CLI) and Mix.Tasks.Nbpr.Fetch's
fallback path (when no prebuilt artefact is published for the active
(system, system_version, build_opts) tuple).
Pipeline:
- Discover
deps/nerves_system_br/and read the pinned BR version. - Ensure the patched BR source tree at
$NERVES_DATA_DIR/nbpr/buildroot/<version>/. - Render a defconfig that layers the package + its
build_optson top of the active system'snerves_defconfig. - Run BR (
<pkg>-dirclean && <pkg>) against a stable per-(system, BR-version) output dir, in Docker on non-Linux hosts. - Filter per-package output via BR's files-list (runtime-only).
- Pack into the canonical artefact tarball at
output_dir/.
Returns the absolute path to the produced tarball.
Summary
Functions
Builds the artefact for pkg against inputs.system_app/system_version,
with inputs.build_opts applied. Writes the tarball into output_dir and
returns its absolute path.
Raises when pkg declares the system's libc unsupported.
The C library a system's toolchain targets, read from its nerves_defconfig.
Returns the stable per-(system, BR-version) BR output dir. Reusing across
builds keeps the toolchain extraction, host-skeleton, and unchanged packages
cached; make olddefconfig reconciles defconfig drift.
Functions
@spec build!(NBPR.Package.t(), NBPR.Artifact.build_inputs(), Path.t()) :: Path.t()
Builds the artefact for pkg against inputs.system_app/system_version,
with inputs.build_opts applied. Writes the tarball into output_dir and
returns its absolute path.
inputs is the standard NBPR.Artifact.build_inputs/0 map (the same one
used for cache-key/manifest computation in the fetch path).
@spec ensure_libc_supported!(NBPR.Package.t(), Path.t(), atom()) :: :ok
Raises when pkg declares the system's libc unsupported.
Refuses the combination before Buildroot spends ten minutes proving it in a
compile error. The prebuild matrix already leaves these out of CI, so this
guard is for a consumer whose mix firmware falls through to a source
build.
@spec libc_of_system(Path.t()) :: NBPR.Package.libc()
The C library a system's toolchain targets, read from its nerves_defconfig.
Buildroot's own kconfig is the source of truth here rather than the
toolchain's name, since that's what decides which libc the package is
actually compiled against. Anything that isn't explicitly musl is treated as
glibc, which is every Nerves system bar x86_64.
Returns the stable per-(system, BR-version) BR output dir. Reusing across
builds keeps the toolchain extraction, host-skeleton, and unchanged packages
cached; make olddefconfig reconciles defconfig drift.