NBPR.Buildroot.Package (NBPR v0.2.1)

Copy Markdown View Source

Reads metadata for a Buildroot mainline package from a cached, extracted BR tree. Used by mix nbpr.new so the scaffolded mix.exs and module arrive pre-populated with version, licences, homepage, and a starter description sourced from BR itself rather than left as # TODO stubs.

Inputs

  • br_tree — absolute path to an extracted BR tree (typically the one cached by NBPR.Buildroot.Source).
  • name — Buildroot package name as it appears under package/<name>/, e.g. "iperf3", "dnsmasq", "kernel-modules".

What's read

FieldSource
version<NAME>_VERSION in <name>.mk
licences<NAME>_LICENSE in <name>.mk, comma-split, trimmed
homepageFirst https?:// URL in Config.in help block, else <NAME>_SITE
descriptionFirst sentence of the Config.in help block, capitalised
titleThe bool "..." label in Config.in
helpRaw help block (multi-paragraph)
dependenciesTarget-side BR deps: <NAME>_DEPENDENCIESselect BR2_PACKAGE_*

$(VAR) references in a scalar value (e.g. <NAME>_VERSION = $(<NAME>_VERSION_MAJOR).4) are resolved against assignments in the same .mk. References to vars defined elsewhere (BR globals, $(call ...) functions) are left literal; conditional definitions and computed sites fall back to nil.

Dependency extraction

dependencies lists BR package directory names this package needs at target-build time. It's the union of:

  • The first literal <NAME>_DEPENDENCIES = ... assignment in <name>.mk. Conditional _DEPENDENCIES += foo blocks (gated by ifeq/kconfig) are deliberately ignored — they depend on user kconfig choices, not on intrinsic package wiring, and we have no way to evaluate them statically.
  • Every select BR2_PACKAGE_<X> line in Config.in, lowercased.

Filtered out:

  • host-* deps (build-host tools, never on the target rootfs).
  • $(...) make-variable references (can't be resolved without a full BR config evaluation; e.g. $(TARGET_NLS_DEPENDENCIES)).
  • Duplicates across the two sources.

Summary

Functions

Reads metadata for name from the BR tree at br_tree.

Types

t()

@type t() :: %NBPR.Buildroot.Package{
  dependencies: [String.t()],
  description: String.t() | nil,
  help: String.t() | nil,
  homepage: String.t() | nil,
  licences: [String.t()],
  name: String.t(),
  title: String.t() | nil,
  version: String.t()
}

Functions

read(br_tree, name)

@spec read(Path.t(), String.t()) :: {:ok, t()} | {:error, term()}

Reads metadata for name from the BR tree at br_tree.

Returns {:error, :package_not_found} when package/<name>/ is absent (most likely a misspelt BR package name) and {:error, :mk_not_found} when the package directory exists but lacks a <name>.mk (rare; usually a virtual-package umbrella in BR). Missing _VERSION or _LICENSE keys return {:error, {:missing_var, "<key>"}}.