From e0161ef6967b19f0f5bb85b6a947e85ef6354454 Mon Sep 17 00:00:00 2001 From: John Zhao Date: Wed, 24 Oct 2018 11:06:31 +0800 Subject: [PATCH] Update init & makefile --- Makefile | 6 ++++-- scripts/init.sh | 1 + scripts/init_tools.sh | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d53de50..17bd6fa 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,8 @@ MKFILE_DIR := $(patsubst %/,%,$(dir $(MKFILE_PATH))) # UNIX: /usr/local # Windows: c:/Program Files/${PROJECT_NAME} +SUDO ?= sudo + .DEFAULT_GOAL := help help: @@ -77,7 +79,7 @@ submodules: init: submodules @$(call echo,Make $@) - @$(SH) ./scripts/init.sh + @$(SH) ./scripts/init.sh $(INIT_OPTIONS) .PHONY: init @@ -125,7 +127,7 @@ else endif else ifeq ($(HOST_OS),Linux) - @cd ./_build; sudo make install + @cd ./_build; $(SUDO) make install else @cd ./_build; make install endif diff --git a/scripts/init.sh b/scripts/init.sh index ce193c2..c75a70f 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -16,6 +16,7 @@ # _VERBOSE_=1 # _INIT_LINTER_=1 # _FORCE_INSRALL_=1 +_INSTALL_OPTIONS_=$@ BASE_DIR=$(cd "$(dirname "$0")" && pwd) diff --git a/scripts/init_tools.sh b/scripts/init_tools.sh index 232b536..0078271 100644 --- a/scripts/init_tools.sh +++ b/scripts/init_tools.sh @@ -16,6 +16,7 @@ _INIT_BUILD_=1 # _INIT_LINTER_=1 # _FORCE_INSRALL_=1 +# _INSTALL_OPTIONS_=-y BASE_DIR=$(cd "$(dirname "$0")" && pwd) @@ -42,6 +43,9 @@ fi _install_deps() { _cmd="$1"; shift; _deps_all=($@) + if [ -n "${_INSTALL_OPTIONS_}" ]; then + _cmd="$_cmd $_INSTALL_OPTIONS_" + fi _echo "Install cmd: $_cmd" _echo "Install deps: ${_deps_all[*]}" if [ -n "${_FORCE_INSRALL_}" ]; then @@ -68,6 +72,7 @@ _echo_s "Init tools" if [ "$HOST_OS" = "Linux" ]; then # sudo SUDO="sudo" + _detect_cmd $SUDO || SUDO= # detect apt-get _detect apt-get # apt-get install