From b14c678a749c5e980987fbd8a8237f07bfff0f59 Mon Sep 17 00:00:00 2001 From: Mason Tran Date: Fri, 21 Jun 2024 14:48:59 -0400 Subject: [PATCH] [script] allow passing in `toolchain_dir` as an arg for `install_arm_toolchain()` --- script/bootstrap | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/script/bootstrap b/script/bootstrap index e2694c2c..de6f511c 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -124,13 +124,15 @@ install_arm_toolchain() { local url=${1-"https://developer.arm.com/-/media/Files/downloads/gnu/12.2.rel1/binrel/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi.tar.xz"} local extract_dir=${2-"arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi"} - - local toolchain_dir - # Link if root - if [ "$EUID" -eq 0 ]; then - toolchain_dir=/opt - else - toolchain_dir="${HOME}/.local" + local toolchain_dir=${3-""} + + # If toolchain_dir is not provided, use /opt if root, else use ~/.local + if [ -z "${toolchain_dir}" ]; then + if [ "$EUID" -eq 0 ]; then + toolchain_dir=/opt + else + toolchain_dir="${HOME}/.local" + fi fi # Check if the toolchain is already present at the desired location