Skip to content

Commit b546829

Browse files
authored
fix(matter): make the script work in different use cases
1 parent 43416b0 commit b546829

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

tools/update-components.sh

+18-16
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,23 @@ echo "Updating CHIP v1.3 repository..."
3131
CHIP_REPO_URL="https://github.com/espressif/connectedhomeip.git"
3232
CHIP_REPO_DIR="$MATTER_REPO_DIR/connectedhomeip/connectedhomeip"
3333
CHIP_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
4052
fi
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
5153
echo "Matter v1.3 component is installed and updated."

0 commit comments

Comments
 (0)