From 173a633a75692ae104fa9c6e99501fec4df9ebb7 Mon Sep 17 00:00:00 2001 From: Maxime Desroches Date: Thu, 25 Jul 2024 14:28:41 -0700 Subject: [PATCH] curl pc installer (#33072) * setup * curl * usable right now * op sim * cleanup * show cmd --- tools/op.sh | 24 ++++++++++++++- tools/setup.sh | 68 ++++++++++++++++++++++++++++--------------- tools/ubuntu_setup.sh | 5 ---- 3 files changed, 68 insertions(+), 29 deletions(-) diff --git a/tools/op.sh b/tools/op.sh index 7ad9697185..42bbb1973d 100755 --- a/tools/op.sh +++ b/tools/op.sh @@ -161,14 +161,23 @@ function op_install() { op_check_os op_check_python + echo "Installing dependencies..." if [[ "$OSTYPE" == "linux-gnu"* ]]; then op_run_command $OPENPILOT_ROOT/tools/ubuntu_setup.sh elif [[ "$OSTYPE" == "darwin"* ]]; then op_run_command $OPENPILOT_ROOT/tools/mac_setup.sh fi + echo -e " ↳ [${GREEN}✔${NC}] Dependencies installed successfully.\n" + echo "Getting git submodules..." op_run_command git submodule update --init --recursive + echo -e " ↳ [${GREEN}✔${NC}] Submodules installed successfully.\n" + + echo "Pulling git lfs files..." op_run_command git lfs pull + echo -e " ↳ [${GREEN}✔${NC}] Files pulled successfully.\n" + + op_check ) } @@ -199,7 +208,7 @@ function op_run() { (set -e op_before_cmd - op_run_command $OPENPILOT_ROOT/launch_openpilot.sh + op_run_command $OPENPILOT_ROOT/launch_openpilot.sh $@ ) } @@ -249,6 +258,16 @@ function op_cabana() { ) } +function op_sim() { + (set -e + + op_before_cmd + op_run_command exec $OPENPILOT_ROOT/tools/sim/run_bridge.py & + op_run_command exec $OPENPILOT_ROOT/tools/sim/launch_openpilot.sh + + ) +} + function op_default() { echo "An openpilot helper" echo "" @@ -270,6 +289,7 @@ function op_default() { echo -e " ${BOLD}install${NC} Install requirements to use openpilot" echo -e " ${BOLD}build${NC} Build openpilot" echo -e " ${BOLD}run${NC} Run openpilot" + echo -e " ${BOLD}sim${NC} Run openpilot in a simulator" echo -e " ${BOLD}juggle${NC} Run Plotjuggler" echo -e " ${BOLD}replay${NC} Run replay" echo -e " ${BOLD}cabana${NC} Run cabana" @@ -318,6 +338,7 @@ function _op() { cabana ) shift 1; op_cabana "$@" ;; linter ) shift 1; op_linter "$@" ;; replay ) shift 1; op_replay "$@" ;; + sim ) shift 1; op_sim "$@" ;; --install ) shift 1; op_first_install "$@" ;; * ) op_default "$@" ;; esac @@ -345,6 +366,7 @@ unset -f op_replay unset -f op_cabana unset -f op_check_venv unset -f op_before_cmd +unset -f op_sim unset DRY unset OPENPILOT_ROOT unset NO_VERIFY diff --git a/tools/setup.sh b/tools/setup.sh index 22d10be80b..42b8d6fd4c 100755 --- a/tools/setup.sh +++ b/tools/setup.sh @@ -1,32 +1,54 @@ #!/usr/bin/env bash -set -e +RED='\033[0;31m' +GREEN='\033[0;32m' +NC='\033[0m' -if [ ! -f launch_openpilot.sh ]; then - if [ ! -d openpilot ]; then - git clone --single-branch --recurse-submodules https://github.com/commaai/openpilot.git +if [ -z "$OPENPILOT_ROOT" ]; then + # default to current directory for installation + OPENPILOT_ROOT="$(pwd)/openpilot" +fi + +function check_dir() { + echo "Checking for installation directory..." + if [ -d "$OPENPILOT_ROOT" ]; then + echo -e " ↳ [${RED}✗${NC}] can't install openpilot in $OPENPILOT_ROOT !" + return 1 fi - cd openpilot -fi -if [[ "$OSTYPE" == "darwin"* ]]; then - tools/mac_setup.sh -else - tools/ubuntu_setup.sh -fi + echo -e " ↳ [${GREEN}✔${NC}] Successfully chosen $OPENPILOT_ROOT as installation directory\n" +} -git lfs pull +function check_git() { + echo "Checking for git..." + if ! command -v "git" > /dev/null 2>&1; then + echo -e " ↳ [${RED}✗${NC}] git not found on your system, can't continue!" + return 1 + else + echo -e " ↳ [${GREEN}✔${NC}] git found.\n" + fi +} -source .venv/bin/activate +function git_clone() { + echo "Cloning openpilot..." + if $(git clone --depth=1 https://github.com/commaai/openpilot.git "$OPENPILOT_ROOT"); then + if [[ -f $OPENPILOT_ROOT/launch_openpilot.sh ]]; then + echo -e " ↳ [${GREEN}✔${NC}] Successfully cloned openpilot.\n" + return 0 + fi + fi -echo "Building openpilot" -scons -u -j$(nproc) + echo -e " ↳ [${RED}✗${NC}] failed to clone openpilot!" + return 1 +} -echo -echo "---- OPENPILOT BUILDING DONE ----" -echo "To push changes to your fork, run the following commands:" -echo "git remote remove origin" -echo "git remote add origin git@github.com:/openpilot.git" -echo "git fetch" -echo "git commit -m \"first commit\"" -echo "git push" +function install_with_op() { + cd $OPENPILOT_ROOT + $OPENPILOT_ROOT/tools/op.sh --install + $OPENPILOT_ROOT/tools/op.sh install + + # make op usable right now + alias op="source $OPENPILOT_ROOT/tools/op.sh \"\$@\"" +} + +check_dir && check_git && git_clone && install_with_op diff --git a/tools/ubuntu_setup.sh b/tools/ubuntu_setup.sh index 1bdeb50e0d..f425e14cf2 100755 --- a/tools/ubuntu_setup.sh +++ b/tools/ubuntu_setup.sh @@ -8,8 +8,3 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" $DIR/install_ubuntu_dependencies.sh $DIR/install_python_dependencies.sh - -echo -echo "---- OPENPILOT SETUP DONE ----" -echo "Open a new shell or configure your active shell env by running:" -echo "source ~/.bashrc"