cargo-post-process 873 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. cargo vendor --manifest-path ${BR_CARGO_MANIFEST_PATH-Cargo.toml} --locked VENDOR
  20. # Create the local .cargo/config with vendor info
  21. mkdir -p .cargo/
  22. cat <<EOF >.cargo/config
  23. [source.crates-io]
  24. replace-with = "vendored-sources"
  25. [source.vendored-sources]
  26. directory = "VENDOR"
  27. EOF
  28. popd > /dev/null
  29. post_process_repack "$(pwd)" "${base_name}" "${output}"