cargo-post-process 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env bash
  2. set -e
  3. . "${0%/*}/helpers"
  4. while getopts "n:o:" OPT; do
  5. case "${OPT}" in
  6. o) output="${OPTARG}";;
  7. n) base_name="${OPTARG}";;
  8. :) error "option '%s' expects a mandatory argument\n" "${OPTARG}";;
  9. \?) error "unknown option '%s'\n" "${OPTARG}";;
  10. esac
  11. done
  12. # Already vendored tarball, nothing to do
  13. if tar tf "${output}" | grep -q "^[^/]*/VENDOR" ; then
  14. exit 0
  15. fi
  16. post_process_unpack "${base_name}" "${output}"
  17. # Do the Cargo vendoring
  18. pushd "${base_name}" > /dev/null
  19. # Create the local .cargo/config with vendor info
  20. mkdir -p .cargo/
  21. mkdir -p "${CARGO_HOME}"
  22. flock "${CARGO_HOME}"/.br-lock \
  23. cargo vendor \
  24. --manifest-path ${BR_CARGO_MANIFEST_PATH-Cargo.toml} \
  25. --locked VENDOR \
  26. > .cargo/config
  27. # "cargo vendor' outputs on stderr a message directing to add some data
  28. # to the project's .cargo/config.toml, data that it outputs on stdout.
  29. # Since we redirect stdout to .cargo/config.toml, the message on stderr
  30. # gets confusing, so instruct the user that it's been handled.
  31. printf '(note: .cargo/config.toml automatically updated by Buildroot)\n\n'
  32. popd > /dev/null
  33. post_process_repack "$(pwd)" "${base_name}" "${output}"