From 8238e2e3e6ab8deed9dc18ac358c2233fa61a83b Mon Sep 17 00:00:00 2001 From: Julien Cretin Date: Wed, 16 Aug 2023 16:38:05 +0200 Subject: [PATCH] Automatically install rustup during setup --- scripts/setup.sh | 5 ++++- scripts/sync.sh | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/setup.sh b/scripts/setup.sh index 14c67fd0..bcb66af9 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -21,7 +21,10 @@ set -e has_bin() { which $1 >/dev/null 2>&1; } -has_bin rustup || e "Missing rustup. Install from https://rustup.rs" +if ! has_bin rustup; then + i "Installing rustup according to https://rustup.rs" + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh +fi MISSING= add_missing() { diff --git a/scripts/sync.sh b/scripts/sync.sh index 5d05123a..f052995b 100755 --- a/scripts/sync.sh +++ b/scripts/sync.sh @@ -29,3 +29,11 @@ book_example button2 led book_example timer button_abort book_example usb memory_game book_example store store + +RUSTUP_CMD="$(curl -s https://rustup.rs \ + | sed -n '/^
$/'\ +'{s#^ *
\(.*\)
$#\1#p;T;q}' +)" +sed -i '\#^ i ".*https://rustup.rs"$#{n;i\ +'" $RUSTUP_CMD"' +;d}' scripts/setup.sh