Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,7 @@ endif

$(srcdir)/%/.git:
cd $(srcdir) && \
flock `git rev-parse --git-dir`/config git submodule init $(dir $@) && \
flock `git rev-parse --git-dir`/config git submodule update --progress $(dir $@)
flock `git rev-parse --git-dir`/config $(srcdir)/scripts/clone-submodule.sh $(dir $@) $(srcdir)

stamps/install-host-gcc: $(GCC_SRCDIR) $(GCC_SRC_GIT)
if test -f $</contrib/download_prerequisites && test "@NEED_GCC_EXTERNAL_LIBRARIES@" = "true"; then cd $< && ./contrib/download_prerequisites; fi
Expand Down
30 changes: 30 additions & 0 deletions scripts/clone-submodule.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

REPO_PATH=$1
SRCDIR=$2

# Convert REPO_PATH to a relative path with respect to SRCDIR
RELATIVE_PATH=$(realpath --relative-to="$SRCDIR" "$REPO_PATH")

echo "Attempting shallow submodule update..."
if git submodule update --init --depth 1 --progress $RELATIVE_PATH; then
echo "Shallow submodule update succeeded!"
else
echo "Shallow submodule update failed. Cleaning up and retrying with full submodule update..."

# Deinitialize the submodule
git submodule deinit -f -- $RELATIVE_PATH
rm -rf .git/modules/$RELATIVE_PATH
git prune

# Perform a fresh submodule update
git submodule update --init --progress $RELATIVE_PATH

# Check if the full update succeeded
if [ $? -eq 0 ]; then
echo "Full submodule update succeeded after cleanup!"
else
echo "Full submodule update failed even after cleanup."
exit 1
fi
fi