@@ -31,21 +31,23 @@ echo "Updating CHIP v1.3 repository..."
3131CHIP_REPO_URL=" https://github.com/espressif/connectedhomeip.git"
3232CHIP_REPO_DIR=" $MATTER_REPO_DIR /connectedhomeip/connectedhomeip"
3333CHIP_REPO_BRANCH=" v1.3-branch"
34- if [ ! -d " $CHIP_REPO_DIR " ]; then
35- git clone --depth 1 -b " $CHIP_REPO_BRANCH " " $CHIP_REPO_URL " " $CHIP_REPO_DIR "
36- $CHIP_REPO_DIR /scripts/checkout_submodules.py --platform esp32 darwin --shallow
37- else
38- git -C " $MATTER_REPO_DIR " fetch && \
39- git -C " $MATTER_REPO_DIR " pull --ff-only
34+ if [ -d " $CHIP_REPO_DIR " ]; then
35+ # Check if directory is empty
36+ if [ -z " $( ls -A " $CHIP_REPO_DIR " ) " ]; then
37+ rm -rf " $CHIP_REPO_DIR "
38+ git clone --depth 1 -b " $CHIP_REPO_BRANCH " " $CHIP_REPO_URL " " $CHIP_REPO_DIR "
39+ if [ $? -ne 0 ]; then exit 1; fi
40+ $CHIP_REPO_DIR /scripts/checkout_submodules.py --platform esp32 darwin --shallow
41+ if [ $? -ne 0 ]; then exit 1; fi
42+ echo " Patching CHIP v1.3 repository..."
43+ CHIP_BAD_FILE=" $CHIP_REPO_DIR /src/platform/ESP32/bluedroid/ChipDeviceScanner.cpp"
44+ CHIP_PATCH=" $AR_PATCHES /matter_chip_ChipDeviceScanner.diff"
45+ if [ -f " $CHIP_BAD_FILE " ]; then
46+ patch $CHIP_BAD_FILE $CHIP_PATCH
47+ else
48+ echo " Error: $CHIP_BAD_FILE not found. Check the script."
49+ exit 1
50+ fi
51+ fi
4052fi
41- if [ $? -ne 0 ]; then exit 1; fi
42- echo " Patching CHIP v1.3 repository..."
43- CHIP_BAD_FILE=" $CHIP_REPO_DIR /src/platform/ESP32/bluedroid/ChipDeviceScanner.cpp"
44- CHIP_PATCH=" $AR_PATCHES /matter_chip_ChipDeviceScanner.diff"
45- if [ ! -e " $CHIP_BAD_FILE " ]; then
46- patch $CHIP_BAD_FILE $CHIP_PATCH
47- else
48- echo " Error: $CHIP_BAD_FILE not found. Check the script."
49- fi
50- if [ $? -ne 0 ]; then exit 1; fi
5153echo " Matter v1.3 component is installed and updated."
0 commit comments