From fefa7db98f5d5f86ce6c0d1c3dedaa7e096a106f Mon Sep 17 00:00:00 2001 From: Christopher Clark Date: Wed, 5 Apr 2017 18:01:11 -0700 Subject: [PATCH 1/3] OXT-1073 : setup.sh: Add upstream layer repositories to mirror Finds the submodules of the master branch of openxt.git and adds them to the local git mirror alongside the OpenXT repos. Signed-off-by: Christopher Clark --- build-scripts/setup.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/build-scripts/setup.sh b/build-scripts/setup.sh index 95cb9f430..2ae6c5a0c 100755 --- a/build-scripts/setup.sh +++ b/build-scripts/setup.sh @@ -273,7 +273,17 @@ 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..." + TMP_CLONE_DIR=$(mktemp -d /tmp/setup-openxt.XXXXX) + ( cd ${TMP_CLONE_DIR} ; + git clone --quiet file://${GIT_ROOT_PATH}/${BUILD_USER}/openxt.git ) + for repo_url in $(sed -ne 's/^\W*url = //p' <${TMP_CLONE_DIR}/openxt/.gitmodules) + 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 From 880d09b70ec880687fd0247986dccde7b3257d7a Mon Sep 17 00:00:00 2001 From: Christopher Clark Date: Tue, 11 Apr 2017 14:28:56 -0700 Subject: [PATCH 2/3] OXT-1073 : Clone upstream layers from the local git mirror if available Signed-off-by: Christopher Clark --- build-scripts/oe/build.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/build-scripts/oe/build.sh b/build-scripts/oe/build.sh index afe374cb8..32684da38 100755 --- a/build-scripts/oe/build.sh +++ b/build-scripts/oe/build.sh @@ -167,8 +167,23 @@ 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 submodule status | cut -f2 -d' ') + do + REPONAME=$(echo $SUBMODULE | sed 's/.*\///') + # Detect presence in the mirror with git's ls-remote command: + if git ls-remote git://${HOST_IP}/${BUILD_USER}/${REPONAME} \ + >/dev/null 2>/dev/null ; + then + sed -e 's/\(^\W*url\W\?=\W\?git:\/\/\).*\(\/'"${REPONAME}"'\(.git\)\?\)$/\1'"${HOST_IP}"'\/'"${BUILD_USER}"'\2/' \ + -i .git/config + fi + done + # Clone the submodules, using their saved HEAD git submodule update --checkout # Update the submodules that follow a branch (update != none) From 18246e0d21a611fba31378e18e3707cf0e7bd5ed Mon Sep 17 00:00:00 2001 From: Christopher Clark Date: Wed, 12 Apr 2017 13:10:54 -0700 Subject: [PATCH 3/3] OXT-1073: Simplify upstream layer mirroring code Improve the prior two commits by removing use of "sed", add further intermediate variables with explanatory names and use git to access its configuration files. Signed-off-by: Christopher Clark --- build-scripts/oe/build.sh | 13 ++++++------- build-scripts/setup.sh | 8 +++++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/build-scripts/oe/build.sh b/build-scripts/oe/build.sh index 32684da38..d9de83620 100755 --- a/build-scripts/oe/build.sh +++ b/build-scripts/oe/build.sh @@ -172,15 +172,14 @@ if [ ! -d openxt ] ; then # 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 submodule status | cut -f2 -d' ') + for SUBMODULE in $(git config -f .gitmodules --get-regexp path | cut -f2 -d' ') do - REPONAME=$(echo $SUBMODULE | sed 's/.*\///') - # Detect presence in the mirror with git's ls-remote command: - if git ls-remote git://${HOST_IP}/${BUILD_USER}/${REPONAME} \ - >/dev/null 2>/dev/null ; + 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 - sed -e 's/\(^\W*url\W\?=\W\?git:\/\/\).*\(\/'"${REPONAME}"'\(.git\)\?\)$/\1'"${HOST_IP}"'\/'"${BUILD_USER}"'\2/' \ - -i .git/config + git config -f .git/config --replace-all submodule."${SUBMODULE}".url "${MIRROR_URL}" fi done diff --git a/build-scripts/setup.sh b/build-scripts/setup.sh index 2ae6c5a0c..e332c6149 100755 --- a/build-scripts/setup.sh +++ b/build-scripts/setup.sh @@ -274,10 +274,12 @@ if [ ! -d ${GIT_ROOT_PATH}/${BUILD_USER} ]; then 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) - ( cd ${TMP_CLONE_DIR} ; - git clone --quiet file://${GIT_ROOT_PATH}/${BUILD_USER}/openxt.git ) - for repo_url in $(sed -ne 's/^\W*url = //p' <${TMP_CLONE_DIR}/openxt/.gitmodules) + 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