From 7cd6a88638be390e0a7a13210e837afc36e1c18c Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Fri, 31 Dec 2021 19:29:38 -0800 Subject: [PATCH] fix setup scripts if git isn't installed --- tools/mac_setup.sh | 9 +++++---- tools/ubuntu_setup.sh | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/tools/mac_setup.sh b/tools/mac_setup.sh index 0e260e715e..be5fc55a9f 100755 --- a/tools/mac_setup.sh +++ b/tools/mac_setup.sh @@ -1,6 +1,7 @@ #!/bin/bash -e -OP_ROOT=$(git rev-parse --show-toplevel) +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" +ROOT="$(cd $DIR/../ && pwd)" # Install brew if required if [[ $(command -v brew) == "" ]]; then @@ -54,14 +55,14 @@ export PATH="$PATH:/usr/local/bin" # OpenPilot environment variables if [ -z "$OPENPILOT_ENV" ] && [ -n "$RC_FILE" ] && [ -z "$CI" ]; then echo "export PATH=\"\$PATH:$HOME/.cargo/bin\"" >> $RC_FILE - echo "source $OP_ROOT/tools/openpilot_env.sh" >> $RC_FILE + echo "source $ROOT/tools/openpilot_env.sh" >> $RC_FILE export PATH="$PATH:\"\$HOME/.cargo/bin\"" - source "$OP_ROOT/tools/openpilot_env.sh" + source "$ROOT/tools/openpilot_env.sh" echo "Added openpilot_env to RC file: $RC_FILE" fi # install python -PYENV_PYTHON_VERSION=$(cat $OP_ROOT/.python-version) +PYENV_PYTHON_VERSION=$(cat $ROOT/.python-version) PATH=$HOME/.pyenv/bin:$HOME/.pyenv/shims:$PATH pyenv install -s ${PYENV_PYTHON_VERSION} pyenv rehash diff --git a/tools/ubuntu_setup.sh b/tools/ubuntu_setup.sh index 6ad7931b56..0e1c0bc657 100755 --- a/tools/ubuntu_setup.sh +++ b/tools/ubuntu_setup.sh @@ -1,6 +1,7 @@ #!/bin/bash -e -OP_ROOT=$(git rev-parse --show-toplevel) +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" +ROOT="$(cd $DIR/../ && pwd)" # Install packages present in all supported versions of Ubuntu function install_ubuntu_common_requirements() { @@ -123,11 +124,11 @@ if ! command -v "pyenv" > /dev/null 2>&1; then fi # in the openpilot repo -cd $OP_ROOT +cd $ROOT source ~/.bashrc if [ -z "$OPENPILOT_ENV" ]; then - printf "\nsource %s/tools/openpilot_env.sh" "$OP_ROOT" >> ~/.bashrc + printf "\nsource %s/tools/openpilot_env.sh" "$ROOT" >> ~/.bashrc source ~/.bashrc echo "added openpilot_env to bashrc" fi @@ -138,7 +139,7 @@ git submodule init git submodule update # install python -PYENV_PYTHON_VERSION=$(cat $OP_ROOT/.python-version) +PYENV_PYTHON_VERSION=$(cat $ROOT/.python-version) PATH=$HOME/.pyenv/bin:$HOME/.pyenv/shims:$PATH pyenv install -s ${PYENV_PYTHON_VERSION} pyenv rehash