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 <kamilx.godzwon@intel.com>
Change-Id: I61dceddebde7e3c66e4b37990e205c513fe38414
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12551
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: Michal Berger <michallinuxstuff@gmail.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Kamil Godzwon 2022-05-05 10:05:01 -04:00 committed by Tomasz Zawadzki
parent 70b31195ee
commit 7248155cae

View File

@ -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
}