NBPR.Buildroot.FilesList (NBPR v0.2.1)

Copy Markdown View Source

Reads Buildroot's per-package .files-list.txt / .files-list-staging.txt and copies only the listed files (with a runtime-only filter) out of a per-package merged sysroot.

Why

In BR2_PER_PACKAGE_DIRECTORIES=y mode, <O>/per-package/<pkg>/target/ is the merged result of the BR target skeleton, every transitive dep, AND the package itself — copying it wholesale ships ~36MB of toolchain libs (libc.so.6, libstdc++.so.6, ...) plus skeleton config (/etc/passwd, THIS_IS_NOT_YOUR_ROOT_FILESYSTEM, ...) in every artefact.

Buildroot writes a per-package files-list to the package's build dir during make <pkg> (NOT <pkg>-rebuild — that skips the before-snapshot, leaving the lists empty). Each line is <pkg>,./<path> relative to target/ (or staging/).

Runtime filter

Even within the package's own contribution, NBPR artefacts are runtime-only — dev/docs paths are dropped:

  • usr/include/** (headers)
  • usr/lib/pkgconfig/** (pkg-config)
  • usr/share/{doc,man,info}/** (docs, manpages)
  • *.la (libtool archives)

Summary

Functions

Reads files_list_path and copies each listed file from src_root to dst_root, preserving the relative path layout, attributes, and symlinks.

Functions

copy!(src_root, dst_root, files_list_path, opts \\ [])

@spec copy!(Path.t(), Path.t(), Path.t(), keyword()) :: :ok

Reads files_list_path and copies each listed file from src_root to dst_root, preserving the relative path layout, attributes, and symlinks.

Skips dev/docs paths. Missing source files are silently skipped (BR's files-list can include staging-only entries that don't exist in target/).

Creates dst_root and any needed intermediate directories. Returns :ok. Raises only on actual filesystem errors during copy.

When the files-list doesn't exist, returns :ok without copying anything — caller decides whether that's an error.