# `NBPR.Pack`
[🔗](https://github.com/jimsynz/nbpr/blob/v0.7.0/lib/nbpr/pack.ex#L1)

Produces a canonical NBPR artefact tarball from a directory of built files.

Given the build inputs (package, version, system, system-version,
build-opts) plus paths to one or more of `target/`, `staging/`,
`legal-info/`, and `rootfs/` source directories, this module assembles
them into a single top-level directory matching `NBPR.Artifact.dir_name/1`,
drops a `manifest.json` next to them, and tarballs into a file named per
`NBPR.Artifact.tarball_name/1`.

The four sources are routed differently at install time:

- `target/` → installed into the package's `priv/` (binaries, libraries,
  package-specific configs)
- `staging/` → installed into the build sysroot for NIF cross-compilation
  (currently unused by the installer)
- `rootfs/` → installed into Nerves' `build_rootfs_overlay` so the files
  end up at standard rootfs paths in the firmware (kernel modules,
  daemons that hardcode `/etc/foo.conf`, etc.)
- `legal-info/` → licence aggregation

Pure I/O on the local filesystem; no network, no Buildroot. Source-build
drivers (eventual `mix nbpr.build` and friends) call into this once they
have a directory of installed files.

# `sources`

```elixir
@type sources() :: %{
  optional(:target) =&gt; Path.t(),
  optional(:staging) =&gt; Path.t(),
  optional(:rootfs) =&gt; Path.t(),
  optional(:legal_info) =&gt; Path.t()
}
```

# `pack!`

```elixir
@spec pack!(NBPR.Artifact.build_inputs(), sources(), Path.t()) :: Path.t()
```

Builds the canonical tarball for `inputs`, drawing files from `sources`.

Returns the absolute path to the produced tarball.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
