All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Devoogdt <thomas@devoogdt.com>
To: thomas@devoogdt.com
Cc: buildroot@buildroot.org, eric.le.bihan.dev@free.fr,
	fontaine.fabrice@gmail.com, guillaume.chaye@zeetim.com
Subject: [Buildroot] [PATCH v6 1/3] package/pkg-cargo: add support to bundle a custom Cargo.lock file
Date: Sun, 19 Oct 2025 08:45:01 +0200	[thread overview]
Message-ID: <20251019064503.2583945-1-thomas@devoogdt.com> (raw)
In-Reply-To: <CACXRmJitiNM=oBYeGc2C40vP=wRYaaYJjiGMN7siwTWJ=vWPwQ@mail.gmail.com>

E.g. https://github.com/lu-zero/cargo-c/releases/tag/v0.10.15

Cargo-c releases a separate Cargo.lock file, but doesn't bundle
one in its normal .tar.gz code source target.

We can't use extra downloads/patches/... as cargo is a vendored
package, which is done quite early in the chain.

This patch allows us to define a custom Cargo.lock source.
Both a local bundled file and remote (only wget) file can be linked.

Usage:

<PKG>_CARGO_LOCK_FILE = <PKG>_PKGDIR/Cargo.lock

<PKG>_CARGO_LOCK_FILE = https://.../Cargo.lock

Signed-off-by: Thomas Devoogdt <thomas@devoogdt.com>
Superseeds https://patchwork.ozlabs.org/project/buildroot/patch/20250324173246.100112-1-guillaume.chaye@zeetim.com/.
v2: no change
v3: no change
v4: no change
v5: no change
v6: fixed 'rm -f Cargo.lock'
---
 package/pkg-cargo.mk                |  5 +++++
 support/download/cargo-post-process | 14 +++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/package/pkg-cargo.mk b/package/pkg-cargo.mk
index 47a6353f25..626e5ea472 100644
--- a/package/pkg-cargo.mk
+++ b/package/pkg-cargo.mk
@@ -195,6 +195,11 @@ ifneq ($$($(2)_SUBDIR),)
 $(2)_DOWNLOAD_POST_PROCESS_OPTS += -m$$($(2)_SUBDIR)/Cargo.toml
 endif
 
+# Allow to download a custom Cargo.lock file.
+ifneq ($$($(3)_CARGO_LOCK_FILE),)
+$(2)_DOWNLOAD_POST_PROCESS_OPTS += -l$$($(3)_CARGO_LOCK_FILE)
+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..f7e0d8b73b 100755
--- a/support/download/cargo-post-process
+++ b/support/download/cargo-post-process
@@ -11,11 +11,12 @@ if [ "${BR_CARGO_MANIFEST_PATH}" ]; then
 fi
 
 manifest=Cargo.toml
-while getopts "n:o:m:" OPT; do
+while getopts "n:o:m:l:" OPT; do
     case "${OPT}" in
     o)  output="${OPTARG}";;
     n)  base_name="${OPTARG}";;
     m)  manifest="${OPTARG}";;
+    l)  lockfile="${OPTARG}";;
     :)  error "option '%s' expects a mandatory argument\n" "${OPTARG}";;
     \?) error "unknown option '%s'\n" "${OPTARG}";;
     esac
@@ -31,6 +32,17 @@ post_process_unpack "${base_name}" "${output}"
 # Do the Cargo vendoring
 pushd "${base_name}" > /dev/null
 
+# Copy the custom lockfile path if given
+# TODO: use --lockfile-path once stable
+if [ -n "${lockfile}" ] ; then
+    rm -f Cargo.lock
+    if [ -f "${lockfile}" ] ; then
+        cp "${lockfile}" Cargo.lock
+    else
+        ${WGET} "${lockfile}" -O Cargo.lock
+    fi
+fi
+
 # Create the local .cargo/config.toml with vendor info
 mkdir -p .cargo/
 mkdir -p "${CARGO_HOME}"
-- 
2.43.0

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

  reply	other threads:[~2025-10-19  6:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-30  8:07 [Buildroot] [PATCH v5 1/3] package/pkg-cargo: add support to bundle a custom Cargo.lock file Thomas Devoogdt
2025-09-30  8:07 ` [Buildroot] [PATCH v5 2/3] package/cargo-c: add new package Thomas Devoogdt
2025-09-30  8:07 ` [Buildroot] [PATCH v5 3/3] package/librsvg: bump version to 2.61.1 Thomas Devoogdt
2025-10-11  8:56 ` [Buildroot] [PATCH v5 1/3] package/pkg-cargo: add support to bundle a custom Cargo.lock file Thomas Devoogdt
2025-10-19  6:45   ` Thomas Devoogdt [this message]
2025-10-19  6:45     ` [Buildroot] [PATCH v6 2/3] package/cargo-c: add new package Thomas Devoogdt
2025-10-19  6:45     ` [Buildroot] [PATCH v6] package/librsvg: bump version to 2.61.1 Thomas Devoogdt
2026-01-01 17:00       ` Thomas Petazzoni via buildroot
2026-01-03 11:20         ` Thomas Devoogdt
2026-01-01 16:36     ` [Buildroot] [PATCH v6 1/3] package/pkg-cargo: add support to bundle a custom Cargo.lock file Thomas Petazzoni via buildroot
2026-02-04 14:10       ` [Buildroot] [PATCH v7 1/2] package/pkg-cargo: add support for prevendored Cargo.lock Thomas Devoogdt
2026-02-04 14:10         ` [Buildroot] [PATCH v7 2/2] package/cargo-c: add new package Thomas Devoogdt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251019064503.2583945-1-thomas@devoogdt.com \
    --to=thomas@devoogdt.com \
    --cc=buildroot@buildroot.org \
    --cc=eric.le.bihan.dev@free.fr \
    --cc=fontaine.fabrice@gmail.com \
    --cc=guillaume.chaye@zeetim.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.