From 04154a6517294dbe11a8fd653557b429a6704466 Mon Sep 17 00:00:00 2001 From: Simon Richter Date: Tue, 25 Oct 2022 12:02:00 +0200 Subject: [PATCH] support/download/cargo-post-process: cargo output for vendor config Use the output of `cargo vendor` to generate the vendor configuration. Fixes the need to patch the generated configuration if there are non-crates.io dependencies. Note: `cargo vendor` currently prints a newline before it prints the needed configuration. This is fixed in +nightly, will end up in +stable soon and must be considered when updating cargo. See: https://github.com/rust-lang/cargo/pull/11273 Until then it is needed to remove this first line to make sure that the contents of .cargo/config will be the same as they were generated with the earlier version of the script. Thus, the hashes of the packages that use this script remain the same. Signed-off-by: Simon Richter [yann.morin.1998@free.fr: add comment in rust-bin.mk and rust.mk] Signed-off-by: Yann E. MORIN --- package/rust-bin/rust-bin.mk | 2 ++ package/rust/rust.mk | 2 ++ support/download/cargo-post-process | 26 +++++++++++++++++++------- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/package/rust-bin/rust-bin.mk b/package/rust-bin/rust-bin.mk index 6560151d99..a356acd3dc 100644 --- a/package/rust-bin/rust-bin.mk +++ b/package/rust-bin/rust-bin.mk @@ -4,6 +4,8 @@ # ################################################################################ +# When updating this version, check whether support/download/cargo-post-process +# still generates the same archives. RUST_BIN_VERSION = 1.64.0 RUST_BIN_SITE = https://static.rust-lang.org/dist RUST_BIN_LICENSE = Apache-2.0 or MIT diff --git a/package/rust/rust.mk b/package/rust/rust.mk index 411dda21c4..4b5e5fac48 100644 --- a/package/rust/rust.mk +++ b/package/rust/rust.mk @@ -4,6 +4,8 @@ # ################################################################################ +# When updating this version, check whether support/download/cargo-post-process +# still generates the same archives. RUST_VERSION = 1.64.0 RUST_SOURCE = rustc-$(RUST_VERSION)-src.tar.xz RUST_SITE = https://static.rust-lang.org/dist diff --git a/support/download/cargo-post-process b/support/download/cargo-post-process index a4a4718a2a..186e9eb69b 100755 --- a/support/download/cargo-post-process +++ b/support/download/cargo-post-process @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -e +set -o pipefail . "${0%/*}/helpers" @@ -22,17 +23,28 @@ post_process_unpack "${base_name}" "${output}" # Do the Cargo vendoring pushd "${base_name}" > /dev/null -cargo vendor --manifest-path ${BR_CARGO_MANIFEST_PATH-Cargo.toml} --locked VENDOR # Create the local .cargo/config with vendor info +# +# The first line of the output to stdout is empty. +# So skip it to have the file start with the vendoring +# configuration (`tail --lines=+2`). +# +# NOTE: +# There is a patch for cargo to remove the first empty line: +# See: https://github.com/rust-lang/cargo/pull/11273 +# +# The patch already landed in +nightly and will end up +# in +stable soon. +# +# -> When updating rust/cargo, the call to `tail` must be removed. +# mkdir -p .cargo/ -cat <.cargo/config -[source.crates-io] -replace-with = "vendored-sources" +cargo vendor \ + --manifest-path ${BR_CARGO_MANIFEST_PATH-Cargo.toml} \ + --locked VENDOR \ + | tail --lines=+2 | tee .cargo/config -[source.vendored-sources] -directory = "VENDOR" -EOF popd > /dev/null post_process_repack "$(pwd)" "${base_name}" "${output}"