2022-12-29 12:56:54 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# shellcheck disable=SC2016
|
|
|
|
# shellcheck disable=SC2129
|
|
|
|
|
2023-04-21 23:57:35 -04:00
|
|
|
# https://doc.rust-lang.org/rustc/platform-support.html
|
|
|
|
|
2022-12-29 12:56:54 -05:00
|
|
|
set -euo pipefail
|
|
|
|
|
2023-04-21 23:57:35 -04:00
|
|
|
case $TARGETARCH in
|
|
|
|
amd64)
|
|
|
|
target=x86_64
|
|
|
|
;;
|
|
|
|
arm64)
|
|
|
|
target=aarch64
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "$TARGETARCH is not supported"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2022-12-29 12:56:54 -05:00
|
|
|
ln -s /usr/bin/rustup-init /usr/bin/rustup
|
2023-04-21 23:57:35 -04:00
|
|
|
rustup toolchain install stable-${target}-unknown-linux-musl
|
|
|
|
rustup component add rustfmt --toolchain=stable-${target}-unknown-linux-musl
|
|
|
|
rustup component add clippy --toolchain=stable-${target}-unknown-linux-musl
|
2022-12-29 12:56:54 -05:00
|
|
|
mv /root/.rustup /usr/lib/.rustup
|
2023-04-21 23:57:35 -04:00
|
|
|
ln -fsv /usr/lib/.rustup/toolchains/stable-${target}-unknown-linux-musl/bin/rustfmt /usr/bin/rustfmt
|
|
|
|
ln -fsv /usr/lib/.rustup/toolchains/stable-${target}-unknown-linux-musl/bin/rustc /usr/bin/rustc
|
|
|
|
ln -fsv /usr/lib/.rustup/toolchains/stable-${target}-unknown-linux-musl/bin/cargo /usr/bin/cargo
|
|
|
|
ln -fsv /usr/lib/.rustup/toolchains/stable-${target}-unknown-linux-musl/bin/cargo-clippy /usr/bin/cargo-clippy
|
2022-12-29 12:56:54 -05:00
|
|
|
|
|
|
|
echo '#!/usr/bin/env bash' >/usr/bin/clippy
|
|
|
|
echo 'pushd $(dirname $1)' >>/usr/bin/clippy
|
|
|
|
echo 'cargo-clippy' >>/usr/bin/clippy
|
|
|
|
echo 'rc=$?' >>/usr/bin/clippy
|
|
|
|
echo 'popd' >>/usr/bin/clippy
|
|
|
|
echo 'exit $rc' >>/usr/bin/clippy
|
|
|
|
chmod +x /usr/bin/clippy
|