36e8743da1
In most pure Rust packages, the Cargo.toml manifest is at the root directory, which is why we could call "cargo vendor" without specifying the path of the manifest. However, other packages, such as python-cryptography, which have parts implemented in Rust, have their Cargo.toml located in a specific subdirectory. This commit extends the cargo-post-process download script to understand a BR_CARGO_MANIFEST_PATH environment variable, which allows a package to pass the location of the Cargo.toml file. If not passed, "Cargo.toml" is used, preserving the existing behavior for other packages. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
39 lines
873 B
Bash
Executable File
39 lines
873 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
. "${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
|
|
cargo vendor --manifest-path ${BR_CARGO_MANIFEST_PATH-Cargo.toml} --locked VENDOR
|
|
|
|
# Create the local .cargo/config with vendor info
|
|
mkdir -p .cargo/
|
|
cat <<EOF >.cargo/config
|
|
[source.crates-io]
|
|
replace-with = "vendored-sources"
|
|
|
|
[source.vendored-sources]
|
|
directory = "VENDOR"
|
|
EOF
|
|
popd > /dev/null
|
|
|
|
post_process_repack "$(pwd)" "${base_name}" "${output}"
|