| 1 | #!/bin/sh |
| 2 | # Since Meson invokes this script as |
| 3 | # "/bin/sh .../dist-vendor.sh DIST SOURCE_ROOT" we can't rely on bash features |
| 4 | set -eu |
| 5 | export DIST="$1" |
| 6 | export SOURCE_ROOT="$2" |
| 7 | |
| 8 | cd "$SOURCE_ROOT" |
| 9 | mkdir "$DIST"/.cargo |
| 10 | # cargo-vendor-filterer can be found at https://github.com/coreos/cargo-vendor-filterer |
| 11 | # It is also part of the Rust SDK extension. |
| 12 | cargo vendor-filterer --platform=x86_64-unknown-linux-gnu --platform=aarch64-unknown-linux-gnu > "$DIST"/.cargo/config.toml |
| 13 | set -- vendor/gettext-sys/gettext-*.tar.* |
| 14 | TARBALL_PATH=$1 |
| 15 | TARBALL_NAME=$(basename "$TARBALL_PATH") |
| 16 | rm -f "$TARBALL_PATH" |
| 17 | # remove the tarball from checksums |
| 18 | cargo_checksum='vendor/gettext-sys/.cargo-checksum.json' |
| 19 | tmp_f=$(mktemp --tmpdir='vendor/gettext-sys' -t) |
| 20 | jq -c "del(.files[\"$TARBALL_NAME\"])" "$cargo_checksum" > "$tmp_f" |
| 21 | mv -f "$tmp_f" "$cargo_checksum" |
| 22 | # Don't combine the previous and this line with a pipe because we can't catch |
| 23 | # errors with "set -o pipefail" |
| 24 | sed -i 's/^directory = ".*"/directory = "vendor"/g' "$DIST/.cargo/config.toml" |
| 25 | # Move vendor into dist tarball directory |
| 26 | mv vendor "$DIST" |