From b2f6beb46ea59ca7a1990724e22ce36f7d24433c Mon Sep 17 00:00:00 2001 From: Tomasz Duda Date: Sat, 15 Oct 2022 11:55:57 +0200 Subject: [PATCH] simplify update scripts --- tools/git-update.sh | 23 ++++++++++ tools/update-components.sh | 93 +++++--------------------------------- 2 files changed, 34 insertions(+), 82 deletions(-) create mode 100755 tools/git-update.sh diff --git a/tools/git-update.sh b/tools/git-update.sh new file mode 100755 index 000000000..d35802eb0 --- /dev/null +++ b/tools/git-update.sh @@ -0,0 +1,23 @@ +set -e + +SUBMODULE=0 + +while getopts "s" opt; do + case ${opt} in + s) + SUBMODULE=1 + ;; + esac +done +shift $((OPTIND-1)) + +DIR=$1 +URL=$2 + +[ -d "$DIR" ] || git clone $URL "$DIR" +git -C "$DIR" fetch +#pull fails if detached +git -C "$DIR" symbolic-ref -q HEAD && git -C "$DIR" pull --ff-only +[ $SUBMODULE -eq 1 ] && git -C "$DIR" submodule update --init --recursive + +exit 0 diff --git a/tools/update-components.sh b/tools/update-components.sh index 41149c000..db8e660e2 100755 --- a/tools/update-components.sh +++ b/tools/update-components.sh @@ -1,5 +1,7 @@ #/bin/bash +set -e + source ./tools/config.sh CAMERA_REPO_URL="https://github.com/espressif/esp32-camera.git" @@ -46,106 +48,33 @@ if [ -z $AR_BRANCH ]; then fi if [ "$AR_BRANCH" ]; then - git -C "$AR_COMPS/arduino" checkout "$AR_BRANCH" && \ - git -C "$AR_COMPS/arduino" fetch && \ + git -C "$AR_COMPS/arduino" checkout "$AR_BRANCH" + git -C "$AR_COMPS/arduino" fetch git -C "$AR_COMPS/arduino" pull --ff-only fi -if [ $? -ne 0 ]; then exit 1; fi -# # CLONE/UPDATE ESP32-CAMERA -# +./tools/git-update.sh "$AR_COMPS/esp32-camera" $CAMERA_REPO_URL -if [ ! -d "$AR_COMPS/esp32-camera" ]; then - git clone $CAMERA_REPO_URL "$AR_COMPS/esp32-camera" -else - git -C "$AR_COMPS/esp32-camera" fetch && \ - git -C "$AR_COMPS/esp32-camera" pull --ff-only -fi #this is a temp measure to fix build issue in recent IDF master if [ -f "$AR_COMPS/esp32-camera/idf_component.yml" ]; then rm -rf "$AR_COMPS/esp32-camera/idf_component.yml" fi -if [ $? -ne 0 ]; then exit 1; fi -# # CLONE/UPDATE ESP-DL -# - -if [ ! -d "$AR_COMPS/esp-dl" ]; then - git clone $DL_REPO_URL "$AR_COMPS/esp-dl" -else - git -C "$AR_COMPS/esp-dl" fetch && \ - git -C "$AR_COMPS/esp-dl" pull --ff-only -fi -if [ $? -ne 0 ]; then exit 1; fi +./tools/git-update.sh "$AR_COMPS/esp-dl" $DL_REPO_URL -# # CLONE/UPDATE ESP-SR -# - -if [ ! -d "$AR_COMPS/esp-sr" ]; then - git clone $SR_REPO_URL "$AR_COMPS/esp-sr" -else - git -C "$AR_COMPS/esp-sr" fetch && \ - git -C "$AR_COMPS/esp-sr" pull --ff-only -fi -if [ $? -ne 0 ]; then exit 1; fi +./tools/git-update.sh "$AR_COMPS/esp-sr" $SR_REPO_URL -# # CLONE/UPDATE ESP-LITTLEFS -# +./tools/git-update.sh -s "$AR_COMPS/esp_littlefs" $LITTLEFS_REPO_URL -if [ ! -d "$AR_COMPS/esp_littlefs" ]; then - git clone $LITTLEFS_REPO_URL "$AR_COMPS/esp_littlefs" && \ - git -C "$AR_COMPS/esp_littlefs" submodule update --init --recursive -else - git -C "$AR_COMPS/esp_littlefs" fetch && \ - git -C "$AR_COMPS/esp_littlefs" pull --ff-only && \ - git -C "$AR_COMPS/esp_littlefs" submodule update --init --recursive -fi -if [ $? -ne 0 ]; then exit 1; fi - -# # CLONE/UPDATE ESP-RAINMAKER -# +./tools/git-update.sh -s "$AR_COMPS/esp-rainmaker" $RMAKER_REPO_URL -if [ ! -d "$AR_COMPS/esp-rainmaker" ]; then - git clone $RMAKER_REPO_URL "$AR_COMPS/esp-rainmaker" && \ - git -C "$AR_COMPS/esp-rainmaker" submodule update --init --recursive - # git -C "$AR_COMPS/esp-rainmaker" checkout f1b82c71c4536ab816d17df016d8afe106bd60e3 -else - git -C "$AR_COMPS/esp-rainmaker" fetch && \ - git -C "$AR_COMPS/esp-rainmaker" pull --ff-only && \ - git -C "$AR_COMPS/esp-rainmaker" submodule update --init --recursive -fi -if [ $? -ne 0 ]; then exit 1; fi - -# # CLONE/UPDATE ESP-DSP -# +./tools/git-update.sh "$AR_COMPS/esp-dsp" $DSP_REPO_URL -if [ ! -d "$AR_COMPS/esp-dsp" ]; then - git clone $DSP_REPO_URL "$AR_COMPS/esp-dsp" - # cml=`cat "$AR_COMPS/esp-dsp/CMakeLists.txt"` - # echo "if(IDF_TARGET STREQUAL \"esp32\" OR IDF_TARGET STREQUAL \"esp32s2\" OR IDF_TARGET STREQUAL \"esp32s3\")" > "$AR_COMPS/esp-dsp/CMakeLists.txt" - # echo "$cml" >> "$AR_COMPS/esp-dsp/CMakeLists.txt" - # echo "endif()" >> "$AR_COMPS/esp-dsp/CMakeLists.txt" -else - git -C "$AR_COMPS/esp-dsp" fetch && \ - git -C "$AR_COMPS/esp-dsp" pull --ff-only -fi -if [ $? -ne 0 ]; then exit 1; fi - -# # CLONE/UPDATE TINYUSB -# - -if [ ! -d "$AR_COMPS/arduino_tinyusb/tinyusb" ]; then - git clone $TINYUSB_REPO_URL "$AR_COMPS/arduino_tinyusb/tinyusb" -else - git -C "$AR_COMPS/arduino_tinyusb/tinyusb" fetch && \ - git -C "$AR_COMPS/arduino_tinyusb/tinyusb" pull --ff-only -fi -if [ $? -ne 0 ]; then exit 1; fi - +./tools/git-update.sh "$AR_COMPS/arduino_tinyusb/tinyusb" $TINYUSB_REPO_URL