From 7248155cae5fe4e92e398ecc31a722cec9086115 Mon Sep 17 00:00:00 2001 From: Kamil Godzwon Date: Thu, 5 May 2022 10:05:01 -0400 Subject: [PATCH] pkgdep/git: update git -C commands while adding submodule Changed 'git -C' to 'git --git-dir' when adding submodules to cloned spdk repo. Both commands are not equivalent. 'git -C' does not override the GIT_DIR environment variable and some systems may have set the spdk repository location incorrectly (not visible by OS). Using 'git --git-dir' allows to set repo options remotely (without being inside). Changed the ownership of the spdk repo (Linux only) to the actual $USER while checking if repo exists. That prevents from unsafe directory detection run by GIT. Such issues happend on Ubuntu 18.04 and 20.04 Signed-off-by: Kamil Godzwon Change-Id: I61dceddebde7e3c66e4b37990e205c513fe38414 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12551 Tested-by: SPDK CI Jenkins Community-CI: Broadcom CI Reviewed-by: Michal Berger Reviewed-by: Jim Harris Reviewed-by: Tomasz Zawadzki --- test/common/config/pkgdep/git | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/common/config/pkgdep/git b/test/common/config/pkgdep/git index f6aca96d8..ce1265df6 100644 --- a/test/common/config/pkgdep/git +++ b/test/common/config/pkgdep/git @@ -1,13 +1,16 @@ function install_spdk() { mkdir -p "$GIT_REPOS/spdk_repo/output" || echo "Can not create spdk_repo/output directory." - if [[ -d $GIT_REPOS/spdk_repo/spdk ]]; then + if [[ -d $GIT_REPOS/spdk_repo/spdk/.git ]]; then echo "spdk source already present, not cloning" + if [[ $OSID != freebsd ]]; then + chown -R "$USER:$USER" "$GIT_REPOS/spdk_repo/spdk" + fi else git -C "$GIT_REPOS/spdk_repo" clone "${GIT_REPO_SPDK}" fi - git -C "$GIT_REPOS/spdk_repo/spdk" config submodule.dpdk.url "${GIT_REPO_DPDK}" - git -C "$GIT_REPOS/spdk_repo/spdk" config submodule.intel-ipsec-mb.url "${GIT_REPO_INTEL_IPSEC_MB}" + git --git-dir=$GIT_REPOS/spdk_repo/spdk/.git config submodule.dpdk.url ${GIT_REPO_DPDK} + git --git-dir=$GIT_REPOS/spdk_repo/spdk/.git config submodule.intel-ipsec-mb.url ${GIT_REPO_INTEL_IPSEC_MB} git -C "$GIT_REPOS/spdk_repo/spdk" submodule update --init --recursive }