Fix git submodule update failure in some environments

Submodules of Occlum may have a very big size and under some environments git submodule
update can always fail. Now OCCLUM_GIT_OPTIONS can read from environment. And user can
specify the depth of the submodule like this: OCCLUM_GIT_OPTIONS="--depth 1" make submodule,
which can make it more possible to succeed.
This commit is contained in:
Hui, Chunyang 2020-04-17 02:50:21 +00:00 committed by Tate, Hongliang Tian
parent 5bd5e1bc68
commit 490e45a52e

@ -6,20 +6,21 @@ githooks:
@find .git/hooks -type l -exec rm {} \; && find .githooks -type f -exec ln -sf ../../{} .git/hooks/ \; @find .git/hooks -type l -exec rm {} \; && find .githooks -type f -exec ln -sf ../../{} .git/hooks/ \;
@echo "Add Git hooks that check Rust code format issues before commits and pushes" @echo "Add Git hooks that check Rust code format issues before commits and pushes"
OCCLUM_GIT_OPTIONS ?=
GIT_MIN_VERSION := 2.11.0 GIT_MIN_VERSION := 2.11.0
GIT_CURRENT_VERSION := $(shell git --version | sed 's/[^0-9.]*//g') GIT_CURRENT_VERSION := $(shell git --version | sed 's/[^0-9.]*//g')
GIT_NEED_PROGRESS := $(shell /bin/echo -e "$(GIT_MIN_VERSION)\n$(GIT_CURRENT_VERSION)" \ GIT_NEED_PROGRESS := $(shell /bin/echo -e "$(GIT_MIN_VERSION)\n$(GIT_CURRENT_VERSION)" \
| sort -V | head -n1 | grep -q $(GIT_MIN_VERSION) && echo "true" || echo "false") | sort -V | head -n1 | grep -q $(GIT_MIN_VERSION) && echo "true" || echo "false")
# If git version >= min_version, append the `--progress` option to show progress status # If git version >= min_version, append the `--progress` option to show progress status
ifeq ($(GIT_NEED_PROGRESS), true) ifeq ($(GIT_NEED_PROGRESS), true)
GIT_OPTION := --progress OCCLUM_GIT_OPTIONS += --progress
else else
GIT_OPTION := OCCLUM_GIT_OPTIONS +=
endif endif
submodule: githooks submodule: githooks
git submodule init git submodule init
git submodule update $(GIT_OPTION) git submodule update $(OCCLUM_GIT_OPTIONS)
@# Try to apply the patches. If failed, check if the patches are already applied @# Try to apply the patches. If failed, check if the patches are already applied
cd deps/rust-sgx-sdk && git apply ../rust-sgx-sdk.patch >/dev/null 2>&1 || git apply ../rust-sgx-sdk.patch -R --check cd deps/rust-sgx-sdk && git apply ../rust-sgx-sdk.patch >/dev/null 2>&1 || git apply ../rust-sgx-sdk.patch -R --check
cd deps/serde-json-sgx && git apply ../serde-json-sgx.patch >/dev/null 2>&1 || git apply ../serde-json-sgx.patch -R --check cd deps/serde-json-sgx && git apply ../serde-json-sgx.patch >/dev/null 2>&1 || git apply ../serde-json-sgx.patch -R --check