Skip to content

Allow vendoring build inputs for offline builds - #95

Merged
azenla merged 3 commits into
edera-dev:mainfrom
jades-ant:jades/offline-build-env-hooks
Jul 24, 2026
Merged

Allow vendoring build inputs for offline builds#95
azenla merged 3 commits into
edera-dev:mainfrom
jades-ant:jades/offline-build-env-hooks

Conversation

@jades-ant

Copy link
Copy Markdown
Contributor

With full_bindings enabled, build.rs fetches two things itself: a clone of falcosecurity/libs and a bpftool release archive. In hermetic build environments (Nix, Bazel, air-gapped CI) there's no network at build time, so these make the crate unbuildable.

This adds optional env vars to point those at pre-fetched inputs instead:

  • VENDOR_LIBSCAP_SRC_DIR — an extracted checkout of the pinned commit, copied instead of cloned (no .git needed)
  • VENDOR_BPFTOOL_ARCHIVE — a local bpftool archive, verified against the same pinned sha256 as the download path
  • VENDOR_LIBS_VERSION / VENDOR_DRIVER_VERSION — version strings for .git-less trees, where git describe can't run (default 0.0.0, libscap's own no-git fallback)

Everything is opt-in; unset means the current network behavior, unchanged. The downloads cmake does on its own (zlib/libbpf/uthash, libelf) don't need hooks — cmake already skips a download when the archive is pre-seeded in its build dir, so a hermetic builder can handle those without build.rs getting involved.

Tested: full build with hooks set (no clone/download in logs, regenerated src/ types unchanged), full build with hooks unset (normal network path), and a wrong bpftool archive fails the checksum check.

azenla
azenla previously approved these changes Jul 24, 2026

@azenla azenla left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this is great, and very timely for us too!

We are in the process of making our standard dev process across Edera much faster (hence #93), one small gap I see here is that we don't verify the libscap source hash like we do bpftool. This is fine for this PR but this might be a good follow-up we can do internally. We can file an issue after it is merged.

There is just one minor thing to note that I saw, should be an easy change. Approving otherwise.

Comment thread README.md Outdated
Allow hermetic build environments (Nix, Bazel, air-gapped CI) to supply
pre-fetched inputs for the two fetches build.rs performs itself: the
libscap source tree (VENDOR_LIBSCAP_SRC_DIR replaces the git clone) and
the bpftool release archive (VENDOR_BPFTOOL_ARCHIVE replaces the
download, verified against the same pinned sha256). Unset variables
fall back to the existing network behavior.

The downloads that happen inside cmake (ExternalProject tarballs for
zlib/libbpf/uthash, FetchContent for libelf) need no hooks: cmake
accepts pre-existing archives in its download dirs, so hermetic
builders can seed the build folder directly.

Vendored source trees need no .git: version strings can be supplied via
VENDOR_LIBS_VERSION / VENDOR_DRIVER_VERSION, defaulting to
GetVersionFromGit's own no-git fallback (0.0.0), so nothing new needs
maintaining alongside the pinned checkout. The defines are always
passed for .git-less trees so git can't walk up from OUT_DIR and
describe an enclosing repo. A stamp file keyed on the pin SHA and
source path drops the copied tree whenever either changes; unsetting
the hook drops the tree and the cmake build dir (so cached version
defines don't leak into clone-path builds).
@azenla

azenla commented Jul 24, 2026

Copy link
Copy Markdown
Member

@jades-ant Looks like we have a conflict with main now due to some perf changes

bleggett
bleggett previously approved these changes Jul 24, 2026

@bleggett bleggett left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I believe @antoineco hit this during his nixification and supporting vendored copies was a TODO anyway, thanks!

@antoineco

Copy link
Copy Markdown
Member

Glad I can remove those build-time patches from downstream. Thanks!

@jades-ant

Copy link
Copy Markdown
Contributor Author

MC fixed, and yep, removing build-time patches on my side is exactly why I figured I would just PR

@azenla

azenla commented Jul 24, 2026

Copy link
Copy Markdown
Member

MC fixed, and yep, removing build-time patches on my side is exactly why I figured I would just PR

Awesome! Thank you! Merging!

@azenla
azenla enabled auto-merge (squash) July 24, 2026 17:46
@azenla
azenla merged commit 43c6f58 into edera-dev:main Jul 24, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants