2
1

cargo-post-process 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env bash
  2. set -e
  3. set -o pipefail
  4. . "${0%/*}/helpers"
  5. while getopts "n:o:" OPT; do
  6. case "${OPT}" in
  7. o) output="${OPTARG}";;
  8. n) base_name="${OPTARG}";;
  9. :) error "option '%s' expects a mandatory argument\n" "${OPTARG}";;
  10. \?) error "unknown option '%s'\n" "${OPTARG}";;
  11. esac
  12. done
  13. # Already vendored tarball, nothing to do
  14. if tar tf "${output}" | grep -q "^[^/]*/VENDOR" ; then
  15. exit 0
  16. fi
  17. post_process_unpack "${base_name}" "${output}"
  18. # Do the Cargo vendoring
  19. pushd "${base_name}" > /dev/null
  20. # Create the local .cargo/config with vendor info
  21. #
  22. # The first line of the output to stdout is empty.
  23. # So skip it to have the file start with the vendoring
  24. # configuration (`tail --lines=+2`).
  25. #
  26. # NOTE:
  27. # There is a patch for cargo to remove the first empty line:
  28. # See: https://github.com/rust-lang/cargo/pull/11273
  29. #
  30. # The patch already landed in +nightly and will end up
  31. # in +stable soon.
  32. #
  33. # -> When updating rust/cargo, the call to `tail` must be removed.
  34. #
  35. mkdir -p .cargo/
  36. cargo vendor \
  37. --manifest-path ${BR_CARGO_MANIFEST_PATH-Cargo.toml} \
  38. --locked VENDOR \
  39. | tail --lines=+2 | tee .cargo/config
  40. popd > /dev/null
  41. post_process_repack "$(pwd)" "${base_name}" "${output}"