diff --git a/build-scripts/oe/build.sh b/build-scripts/oe/build.sh index afe374cb8..d9de83620 100755 --- a/build-scripts/oe/build.sh +++ b/build-scripts/oe/build.sh @@ -167,8 +167,22 @@ if [ ! -d openxt ] ; then cd openxt # Fetch the "upstream" layers - # Initialise the submodules using .gitmodules + git submodule init + + # Initialise the submodules from the local git mirror by updating .git/config + # If there is a copy of the submodule in the local git mirror, use it. + for SUBMODULE in $(git config -f .gitmodules --get-regexp path | cut -f2 -d' ') + do + REPONAME=${SUBMODULE##*/} + MIRROR_URL="git://${HOST_IP}/${BUILD_USER}/${REPONAME}" + # Detect presence of a mirror repo by using git's ls-remote command: + if git ls-remote "${MIRROR_URL}" >/dev/null 2>/dev/null + then + git config -f .git/config --replace-all submodule."${SUBMODULE}".url "${MIRROR_URL}" + fi + done + # Clone the submodules, using their saved HEAD git submodule update --checkout # Update the submodules that follow a branch (update != none) diff --git a/build-scripts/setup.sh b/build-scripts/setup.sh index 95cb9f430..e332c6149 100755 --- a/build-scripts/setup.sh +++ b/build-scripts/setup.sh @@ -273,7 +273,19 @@ if [ ! -d ${GIT_ROOT_PATH}/${BUILD_USER} ]; then git clone --quiet --mirror https://github.com/OpenXT/${repo}.git done echo "Done" + echo "Mirroring the upstream layer repositories..." + # Obtain the URLs of the submodule repositories from a temporary clone of openxt.git + TMP_CLONE_DIR=$(mktemp -d /tmp/setup-openxt.XXXXX) + git clone --depth 1 --quiet file://${GIT_ROOT_PATH}/${BUILD_USER}/openxt.git \ + "${TMP_CLONE_DIR}/openxt" + for repo_url in \ + $(git config -f "${TMP_CLONE_DIR}/openxt/.gitmodules" --get-regexp url | cut -f2 -d' ') + do + git clone --quiet --mirror ${repo_url} + done cd - > /dev/null + rm -rf ${TMP_CLONE_DIR} + echo "Done" chown -R ${BUILD_USER}:${BUILD_USER} ${GIT_ROOT_PATH}/${BUILD_USER} fi