public inbox for buildroot@busybox.net
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/2] package/pkg-cargo.mk: add option to vendor crates offline
@ 2026-03-12 17:37 William Sherrer
  2026-03-12 17:37 ` [Buildroot] [PATCH 2/2] docs/manual/adding-packages-cargo.adoc: add instructions for offline vendoring William Sherrer
  0 siblings, 1 reply; 3+ messages in thread
From: William Sherrer @ 2026-03-12 17:37 UTC (permalink / raw)
  To: buildroot

Buildroot packages cargo-packages in a way the allows for offline builds.
However, vendoring the package dependencies requires internet access since
`cargo vendor` defaults to crates.io.

This commit adds the `--respect-source-config` flag to vendor command in
offline builds. This gives the developer the option of adding a custom
.cargo/config.toml in the build directory which points to an offline crates
mirror or registry.

This is particularly useful in airgapped environments where the full build
and/or package development process takes place.

Signed-off-by: William Sherrer <william.sherrer1@gmail.com>
---
 package/pkg-cargo.mk                | 7 +++++++
 support/download/cargo-post-process | 5 ++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/package/pkg-cargo.mk b/package/pkg-cargo.mk
index 47a6353f25..8cf8fe49cf 100644
--- a/package/pkg-cargo.mk
+++ b/package/pkg-cargo.mk
@@ -195,6 +195,13 @@ ifneq ($$($(2)_SUBDIR),)
 $(2)_DOWNLOAD_POST_PROCESS_OPTS += -m$$($(2)_SUBDIR)/Cargo.toml
 endif
 
+# If building offline, and the package needs to vendor offline, 
+# use the -r flag in the post_process_opts to use --respect-source-config.
+# This ensures custom registeries or offline crate mirrors are used.
+ifeq ($(ONLINE),n)
+$(2)_DOWNLOAD_POST_PROCESS_OPTS += -r
+endif
+
 # Because we append vendored info, we can't rely on the values being empty
 # once we eventually get into the generic-package infra. So, we duplicate
 # the heuristics here
diff --git a/support/download/cargo-post-process b/support/download/cargo-post-process
index b0e59ad74d..7047e8e881 100755
--- a/support/download/cargo-post-process
+++ b/support/download/cargo-post-process
@@ -11,11 +11,13 @@ if [ "${BR_CARGO_MANIFEST_PATH}" ]; then
 fi
 
 manifest=Cargo.toml
-while getopts "n:o:m:" OPT; do
+respect_source=""
+while getopts "n:o:m:r" OPT; do
     case "${OPT}" in
     o)  output="${OPTARG}";;
     n)  base_name="${OPTARG}";;
     m)  manifest="${OPTARG}";;
+    r)  respect_source="--respect-source-config";;
     :)  error "option '%s' expects a mandatory argument\n" "${OPTARG}";;
     \?) error "unknown option '%s'\n" "${OPTARG}";;
     esac
@@ -36,6 +38,7 @@ mkdir -p .cargo/
 mkdir -p "${CARGO_HOME}"
 flock "${CARGO_HOME}"/.br-lock \
 cargo vendor \
+    "${respect_source}" \
     --manifest-path "${manifest}" \
     --locked VENDOR \
     > .cargo/config.toml
-- 
2.43.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 3+ messages in thread
* Re: [Buildroot] [PATCH 1/2] package/pkg-cargo.mk: add option to vendor crates offline
@ 2026-03-16 21:00 Will
  0 siblings, 0 replies; 3+ messages in thread
From: Will @ 2026-03-16 21:00 UTC (permalink / raw)
  To: buildroot


Hello All,

> On Mar 12, 2026, at 13:37, William Sherrer <william.sherrer1@gmail.com> wrote:
> This commit adds the `--respect-source-config` flag to vendor command in
> offline builds. This gives the developer the option of adding a custom
> .cargo/config.toml in the build directory which points to an offline crates
> mirror or registry.

Is there feedback for these proposed changes? If rejected, any recommendations for the future?

Thank you,
Will Sherrer
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-16 21:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-12 17:37 [Buildroot] [PATCH 1/2] package/pkg-cargo.mk: add option to vendor crates offline William Sherrer
2026-03-12 17:37 ` [Buildroot] [PATCH 2/2] docs/manual/adding-packages-cargo.adoc: add instructions for offline vendoring William Sherrer
  -- strict thread matches above, loose matches on Subject: below --
2026-03-16 21:00 [Buildroot] [PATCH 1/2] package/pkg-cargo.mk: add option to vendor crates offline Will

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox