| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | # Install rust binaries for fontc, diffenator3 and fontspector |
| 3 | # into an active Python virtual environment |
| 4 | |
| 5 | set -e |
| 6 | |
| 7 | if [scip-shell system . . `[`. -z "$VIRTUAL_ENV" ]; then |
| 8 | echoscip-shell system . . echo. "No Python virtual environment detected. Please activate one first." |
| 9 | exit 1 |
| 10 | fi |
| 11 | |
| 12 | BIN_DIR="$VIRTUAL_ENV/bin" |
| 13 | |
| 14 | install_from_tarballscip-shell shell shell-project 0.0.0 install_from_tarball().() { |
| 15 | local url="$1" |
| 16 | echoscip-shell system . . echo. "Installing binaries from $url to $BIN_DIR" |
| 17 | local tmpdir |
| 18 | tmpdir=$(mktempscip-shell system . . mktemp. -d) |
| 19 | curlscip-shell system . . curl. -L "$url" | tarscip-shell system . . tar. -xz -C "$tmpdir" |
| 20 | findscip-shell system . . find. "$tmpdir" -type f -exec mv {} "$BIN_DIR" \; |
| 21 | rmscip-shell system . . rm. -rf "$tmpdir" |
| 22 | } |
| 23 | |
| 24 | # Detect platform and set archive suffix |
| 25 | if [[ "$(uname)" == "Darwin" ]]; then |
| 26 | if [[ "$(uname -m)" == "arm64" ]]; then |
| 27 | SUFFIX="aarch64-apple-darwin.tar.gz" |
| 28 | else |
| 29 | SUFFIX="x86_64-apple-darwin.tar.gz" |
| 30 | fi |
| 31 | elif [[ "$(uname)" == "Linux" ]]; then |
| 32 | SUFFIX="unknown-linux-musl.tar.gz" |
| 33 | else |
| 34 | echoscip-shell system . . echo. "Unsupported OS: $(unamescip-shell system . . uname.)" |
| 35 | exit 1 |
| 36 | fi |
| 37 | |
| 38 | install_from_tarballscip-shell shell shell-project 0.0.0 install_from_tarball(). "https://github.com/googlefonts/diffenator3/releases/download/v0.1.2/diffenator3-v0.1.2-$SUFFIX" |
| 39 | install_from_tarballscip-shell shell shell-project 0.0.0 install_from_tarball(). "https://github.com/fonttools/fontspector/releases/download/fontspector-v1.0.2/fontspector-v1.0.2-$SUFFIX" |
| 40 | install_from_tarballscip-shell shell shell-project 0.0.0 install_from_tarball(). "https://github.com/googlefonts/fontc/releases/download/fontc-v0.2.0/fontc-$SUFFIX" |
| 41 | |
| 42 | chmodscip-shell system . . chmod. +x "$BIN_DIR/diffenator3" "$BIN_DIR/diff3proof" "$BIN_DIR/fontspector" "$BIN_DIR/fontc" |
| 43 | echoscip-shell system . . echo. "Done." |