From 68c29c684266d38e30763614a5557d80d326f6c3 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 29 Apr 2024 00:23:31 -0500 Subject: [PATCH] wip --- launch_chffrplus.sh | 1 + system/clearpilot/configure/provision.sh | 14 ++++++--- system/clearpilot/startup_logo/set_logo.sh | 3 +- system/clearpilot/tools/start_networking.sh | 2 ++ system/clearpilot/update.sh | 13 +++++++++ system/clearpilot/update_subshell.sh | 32 +++++++++++++++++++++ update.sh | 16 +++++------ 7 files changed, 67 insertions(+), 14 deletions(-) create mode 100644 system/clearpilot/tools/start_networking.sh create mode 100644 system/clearpilot/update.sh create mode 100644 system/clearpilot/update_subshell.sh diff --git a/launch_chffrplus.sh b/launch_chffrplus.sh index b66870d..52689a8 100755 --- a/launch_chffrplus.sh +++ b/launch_chffrplus.sh @@ -44,6 +44,7 @@ function launch { # 2. The FINALIZED consistent file has to exist, indicating there's an update # that completed successfully and synced to disk. + # CLEARPILOT # if [ -f "${BASEDIR}/.overlay_init" ]; then # find ${BASEDIR}/.git -newer ${BASEDIR}/.overlay_init | grep -q '.' 2> /dev/null # if [ $? -eq 0 ]; then diff --git a/system/clearpilot/configure/provision.sh b/system/clearpilot/configure/provision.sh index cb87af1..41b1367 100644 --- a/system/clearpilot/configure/provision.sh +++ b/system/clearpilot/configure/provision.sh @@ -13,12 +13,18 @@ # sudo apt-get install -y nodejs # fi -apt-get update -apt-get install -y nodejs npm python3-pyqt5 pywayland python3-pyqt5.qtwebengine imagemagick -pip3 install termqt +# Todo: update the crash screen to have an option to restore previous version if one exists. (/data/openpilot_failsafe) +# If no previous version, present an option to check out updated release. +# Todo: Detect if provisioned for current version. If not, start qt_shell subshell for provision. + +apt-get update +apt-get install -y nodejs npm python3-pyqt5 pywayland imagemagick +# apt-get install -y python3-pyqt5.qtwebengine + +# Detect if libyuv is installed. If it is, nothing to do. cd /data/openpilot/third_party/libyuv bash build.sh cd libyuv && make && make install -pip install PyQt5-sip \ No newline at end of file +# pip install PyQt5-sip \ No newline at end of file diff --git a/system/clearpilot/startup_logo/set_logo.sh b/system/clearpilot/startup_logo/set_logo.sh index 1b04635..fecbbec 100644 --- a/system/clearpilot/startup_logo/set_logo.sh +++ b/system/clearpilot/startup_logo/set_logo.sh @@ -2,7 +2,8 @@ set -x -# Test: sudo mount -o remount,rw /; cp /usr/comma/bg.org /usr/comma/bg.jpg; bash shell/set_logo.sh +# Todo: Put stock image in the repo, so we can reset the stock with it if some other +# fork changed it and failed to restore it on uninstall # Check if md5sum of /usr/comma/bg.jpg is not equal to md5sum of /data/openpilot/system/clearpilot/startup_logo/bg.jpg if [ "$(md5sum /usr/comma/bg.jpg | awk '{print $1}')" != "$(md5sum /data/openpilot/system/clearpilot/startup_logo/bg.jpg | awk '{print $1}')" ]; then diff --git a/system/clearpilot/tools/start_networking.sh b/system/clearpilot/tools/start_networking.sh new file mode 100644 index 0000000..58a0c98 --- /dev/null +++ b/system/clearpilot/tools/start_networking.sh @@ -0,0 +1,2 @@ + +# Starts networking. Prompts user to connect to network if networking offline. \ No newline at end of file diff --git a/system/clearpilot/update.sh b/system/clearpilot/update.sh new file mode 100644 index 0000000..8ee8f85 --- /dev/null +++ b/system/clearpilot/update.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Start update_subshell.sh + +# Terminate openpilot +pkill -f 'manager.py' + +/data/openpilot/system/clearpilot/tools/qt_shell \ + "bash /data/openpilot/system/clearpilot/update_subshell.sh"\ + --title="Updating ClearPilot to new version" + +# We shouldn't get here +reboot \ No newline at end of file diff --git a/system/clearpilot/update_subshell.sh b/system/clearpilot/update_subshell.sh new file mode 100644 index 0000000..9dbd008 --- /dev/null +++ b/system/clearpilot/update_subshell.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +echo Bringing up networking... +bash /data/openpilot/system/clearpilot/tools/start_networking.sh +echo Done. +echo + +echo Backing up current release... +cd /data +sudo rm -rf openpilot_failsafe +sudo chmod -R 777 openpilot +cp -r openpilot openpilot_failsafe +cd /data/openpilot +echo Done. + +bash update.sh +echo + +if bash update.sh ; then + echo "Update succeeded, rebooting..." + reboot + sleep 30; +else + echo "Update failed, reverting to last version..." + cd /data + rm -rf openpilot + mv openpilot_failsafe openpilot + /data/openpilot/system/clearpilot/tools/prompt "Updating ClearPilot failed. The previous version has been restored." "Restart" + echo "Update succeeded, rebooting..." + reboot + sleep 30; +fi diff --git a/update.sh b/update.sh index bfbec47..1700a75 100644 --- a/update.sh +++ b/update.sh @@ -1,23 +1,20 @@ +#!/bin/bash + +set -e + sudo chmod -R 777 /data/openpilot -# Set branch to your target branch branch="clearpilot" -# Fetch the latest changes from the remote repository for the target branch git fetch origin "$branch" -# Check if the local branch is behind the remote branch -LOCAL=$(git rev-parse "@{0}") +LOCAL=$(git rev-parse "@{0}") REMOTE=$(git rev-parse "origin/$branch") if [ "$LOCAL" != "$REMOTE" ]; then echo "Local branch is behind; updating." - # Checkout the target branch forcefully, ignoring submodules as in the Python example git checkout --force --no-recurse-submodules -B "$branch" "origin/$branch" - - # Reset the local changes hard, clean the directory including untracked files and directories, - # and ensure submodules are in sync, updated, and also reset hard git reset --hard git clean -xdff git submodule sync @@ -26,7 +23,6 @@ if [ "$LOCAL" != "$REMOTE" ]; then echo "Repository and submodules have been updated and cleaned." - # Run git cleanup in the repository directory git gc git lfs prune @@ -34,3 +30,5 @@ if [ "$LOCAL" != "$REMOTE" ]; then else echo "Already at the latest version; no update needed." fi + +exit 0