2020-12-19 16:35:20 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
2022-10-25 12:02:00 +02:00
|
|
|
set -o pipefail
|
2020-12-19 16:35:20 +01:00
|
|
|
|
|
|
|
. "${0%/*}/helpers"
|
|
|
|
|
|
|
|
while getopts "n:o:" OPT; do
|
|
|
|
case "${OPT}" in
|
|
|
|
o) output="${OPTARG}";;
|
|
|
|
n) base_name="${OPTARG}";;
|
|
|
|
:) error "option '%s' expects a mandatory argument\n" "${OPTARG}";;
|
|
|
|
\?) error "unknown option '%s'\n" "${OPTARG}";;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# Already vendored tarball, nothing to do
|
|
|
|
if tar tf "${output}" | grep -q "^[^/]*/VENDOR" ; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
post_process_unpack "${base_name}" "${output}"
|
|
|
|
|
|
|
|
# Do the Cargo vendoring
|
|
|
|
pushd "${base_name}" > /dev/null
|
|
|
|
|
|
|
|
# Create the local .cargo/config with vendor info
|
2022-10-25 12:02:00 +02:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
2020-12-19 16:35:20 +01:00
|
|
|
mkdir -p .cargo/
|
2022-10-25 12:02:00 +02:00
|
|
|
cargo vendor \
|
|
|
|
--manifest-path ${BR_CARGO_MANIFEST_PATH-Cargo.toml} \
|
|
|
|
--locked VENDOR \
|
|
|
|
| tail --lines=+2 | tee .cargo/config
|
2020-12-19 16:35:20 +01:00
|
|
|
|
|
|
|
popd > /dev/null
|
|
|
|
|
|
|
|
post_process_repack "$(pwd)" "${base_name}" "${output}"
|