From 40828fec785885636f3c6119bccadae74d009aaf Mon Sep 17 00:00:00 2001 From: neo Date: Mon, 6 Mar 2023 14:43:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96mx=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install-origin.sh | 53 ++++++++++++++++++----------- install.sh | 85 +++++++++++++++++++++++++++-------------------- 2 files changed, 82 insertions(+), 56 deletions(-) diff --git a/install-origin.sh b/install-origin.sh index 928c80f..ca4f7ba 100755 --- a/install-origin.sh +++ b/install-origin.sh @@ -447,7 +447,8 @@ fi cd "/usr" || exit 1 ####################################################################### script -if ! command -v git >/dev/null +USABLE_GIT="$(command -v git)" +if [[ -z "${USABLE_GIT}" ]] then abort "$( cat </dev/null || return # we do it in four steps to avoid merge errors when reinstalling - execute "git" "-c" "init.defaultBranch=master" "init" "--quiet" + execute "${USABLE_GIT}" "-c" "init.defaultBranch=master" "init" "--quiet" # "git remote add" will fail if the remote is defined in the global config - execute "git" "config" "remote.origin.url" "${HOMEBREW_BREW_GIT_REMOTE}" - execute "git" "config" "remote.origin.fetch" "+refs/heads/*:refs/remotes/origin/*" + execute "${USABLE_GIT}" "config" "remote.origin.url" "${HOMEBREW_BREW_GIT_REMOTE}" + execute "${USABLE_GIT}" "config" "remote.origin.fetch" "+refs/heads/*:refs/remotes/origin/*" # ensure we don't munge line endings on checkout - execute "git" "config" "--bool" "core.autocrlf" "false" + execute "${USABLE_GIT}" "config" "--bool" "core.autocrlf" "false" # make sure symlinks are saved as-is - execute "git" "config" "--bool" "core.symlinks" "true" + execute "${USABLE_GIT}" "config" "--bool" "core.symlinks" "true" - execute "git" "fetch" "--force" "origin" - execute "git" "fetch" "--force" "--tags" "origin" + execute "${USABLE_GIT}" "fetch" "--force" "origin" + execute "${USABLE_GIT}" "fetch" "--force" "--tags" "origin" - execute "git" "reset" "--hard" "origin/master" + execute "${USABLE_GIT}" "reset" "--hard" "origin/master" if [[ "${HOMEBREW_REPOSITORY}" != "${HOMEBREW_PREFIX}" ]] then @@ -923,14 +924,14 @@ ohai "Downloading and installing Homebrew..." execute "${MKDIR[@]}" "${HOMEBREW_CORE}" cd "${HOMEBREW_CORE}" >/dev/null || return - execute "git" "-c" "init.defaultBranch=master" "init" "--quiet" - execute "git" "config" "remote.origin.url" "${HOMEBREW_CORE_GIT_REMOTE}" - execute "git" "config" "remote.origin.fetch" "+refs/heads/*:refs/remotes/origin/*" - execute "git" "config" "--bool" "core.autocrlf" "false" - execute "git" "config" "--bool" "core.symlinks" "true" - execute "git" "fetch" "--force" "origin" "refs/heads/master:refs/remotes/origin/master" - execute "git" "remote" "set-head" "origin" "--auto" >/dev/null - execute "git" "reset" "--hard" "origin/master" + execute "${USABLE_GIT}" "-c" "init.defaultBranch=master" "init" "--quiet" + execute "${USABLE_GIT}" "config" "remote.origin.url" "${HOMEBREW_CORE_GIT_REMOTE}" + execute "${USABLE_GIT}" "config" "remote.origin.fetch" "+refs/heads/*:refs/remotes/origin/*" + execute "${USABLE_GIT}" "config" "--bool" "core.autocrlf" "false" + execute "${USABLE_GIT}" "config" "--bool" "core.symlinks" "true" + execute "${USABLE_GIT}" "fetch" "--force" "origin" "refs/heads/master:refs/remotes/origin/master" + execute "${USABLE_GIT}" "remote" "set-head" "origin" "--auto" >/dev/null + execute "${USABLE_GIT}" "reset" "--hard" "origin/master" cd "${HOMEBREW_REPOSITORY}" >/dev/null || return ) || exit 1 @@ -972,8 +973,8 @@ EOS ( cd "${HOMEBREW_REPOSITORY}" >/dev/null || return - execute "git" "config" "--replace-all" "homebrew.analyticsmessage" "true" - execute "git" "config" "--replace-all" "homebrew.caskanalyticsmessage" "true" + execute "${USABLE_GIT}" "config" "--replace-all" "homebrew.analyticsmessage" "true" + execute "${USABLE_GIT}" "config" "--replace-all" "homebrew.caskanalyticsmessage" "true" ) || exit 1 ohai "Next steps:" @@ -994,11 +995,23 @@ case "${SHELL}" in ;; esac -cat <> ${shell_profile} eval "\$(${HOMEBREW_PREFIX}/bin/brew shellenv)" EOS +fi + if [[ -n "${non_default_repos}" ]] then plural="" diff --git a/install.sh b/install.sh index fb4020b..ba4be93 100755 --- a/install.sh +++ b/install.sh @@ -479,7 +479,8 @@ fi cd "/usr" || exit 1 ####################################################################### script -if ! command -v git >/dev/null +USABLE_GIT="$(command -v git)" +if [[ -z "${USABLE_GIT}" ]] then abort "$( cat </dev/null || return # we do it in four steps to avoid merge errors when reinstalling - execute "git" "init" "-q" + execute "${USABLE_GIT}" "-c" "init.defaultBranch=master" "init" "--quiet" # "git remote add" will fail if the remote is defined in the global config - execute "git" "config" "remote.origin.url" "${HOMEBREW_BREW_GIT_REMOTE}" - execute "git" "config" "remote.origin.fetch" "+refs/heads/*:refs/remotes/origin/*" + execute "${USABLE_GIT}" "config" "remote.origin.url" "${HOMEBREW_BREW_GIT_REMOTE}" + execute "${USABLE_GIT}" "config" "remote.origin.fetch" "+refs/heads/*:refs/remotes/origin/*" # ensure we don't munge line endings on checkout - execute "git" "config" "--bool" "core.autocrlf" "false" + execute "${USABLE_GIT}" "config" "--bool" "core.autocrlf" "false" # make sure symlinks are saved as-is - execute "git" "config" "--bool" "core.symlinks" "true" + execute "${USABLE_GIT}" "config" "--bool" "core.symlinks" "true" - execute "git" "fetch" "--force" "origin" - execute "git" "fetch" "--force" "--tags" "origin" + execute "${USABLE_GIT}" "fetch" "--force" "origin" + execute "${USABLE_GIT}" "fetch" "--force" "--tags" "origin" - execute "git" "reset" "--hard" "origin/master" + execute "${USABLE_GIT}" "reset" "--hard" "origin/master" if [[ "${HOMEBREW_REPOSITORY}" != "${HOMEBREW_PREFIX}" ]] then @@ -989,14 +990,14 @@ ohai "Downloading and installing Homebrew..." execute "${MKDIR[@]}" "${HOMEBREW_CORE}" cd "${HOMEBREW_CORE}" >/dev/null || return - execute "git" "-c" "init.defaultBranch=master" "init" "--quiet" - execute "git" "config" "remote.origin.url" "${HOMEBREW_CORE_GIT_REMOTE}" - execute "git" "config" "remote.origin.fetch" "+refs/heads/*:refs/remotes/origin/*" - execute "git" "config" "--bool" "core.autocrlf" "false" - execute "git" "config" "--bool" "core.symlinks" "true" - execute "git" "fetch" "--force" "origin" "refs/heads/master:refs/remotes/origin/master" - execute "git" "remote" "set-head" "origin" "--auto" >/dev/null - execute "git" "reset" "--hard" "origin/master" + execute "${USABLE_GIT}" "-c" "init.defaultBranch=master" "init" "--quiet" + execute "${USABLE_GIT}" "config" "remote.origin.url" "${HOMEBREW_CORE_GIT_REMOTE}" + execute "${USABLE_GIT}" "config" "remote.origin.fetch" "+refs/heads/*:refs/remotes/origin/*" + execute "${USABLE_GIT}" "config" "--bool" "core.autocrlf" "false" + execute "${USABLE_GIT}" "config" "--bool" "core.symlinks" "true" + execute "${USABLE_GIT}" "fetch" "--force" "origin" "refs/heads/master:refs/remotes/origin/master" + execute "${USABLE_GIT}" "remote" "set-head" "origin" "--auto" >/dev/null + execute "${USABLE_GIT}" "reset" "--hard" "origin/master" cd "${HOMEBREW_REPOSITORY}" >/dev/null || return ) || exit 1 @@ -1011,14 +1012,14 @@ ohai "Downloading and installing Homebrew..." execute "${MKDIR[@]}" "${HOMEBREW_CASK}" cd "${HOMEBREW_CASK}" >/dev/null || return - execute "git" "-c" "init.defaultBranch=master" "init" "--quiet" - execute "git" "config" "remote.origin.url" "${HOMEBREW_CASK_GIT_REMOTE}" - execute "git" "config" "remote.origin.fetch" "+refs/heads/*:refs/remotes/origin/*" - execute "git" "config" "--bool" "core.autocrlf" "false" - execute "git" "config" "--bool" "core.symlinks" "true" - execute "git" "fetch" "--force" "origin" "refs/heads/master:refs/remotes/origin/master" - execute "git" "remote" "set-head" "origin" "--auto" >/dev/null - execute "git" "reset" "--hard" "origin/master" + execute "${USABLE_GIT}" "-c" "init.defaultBranch=master" "init" "--quiet" + execute "${USABLE_GIT}" "config" "remote.origin.url" "${HOMEBREW_CASK_GIT_REMOTE}" + execute "${USABLE_GIT}" "config" "remote.origin.fetch" "+refs/heads/*:refs/remotes/origin/*" + execute "${USABLE_GIT}" "config" "--bool" "core.autocrlf" "false" + execute "${USABLE_GIT}" "config" "--bool" "core.symlinks" "true" + execute "${USABLE_GIT}" "fetch" "--force" "origin" "refs/heads/master:refs/remotes/origin/master" + execute "${USABLE_GIT}" "remote" "set-head" "origin" "--auto" >/dev/null + execute "${USABLE_GIT}" "reset" "--hard" "origin/master" cd "${HOMEBREW_REPOSITORY}" >/dev/null || return ) || exit 1 @@ -1033,14 +1034,14 @@ ohai "Downloading and installing Homebrew..." execute "${MKDIR[@]}" "${HOMEBREW_SERVICES}" cd "${HOMEBREW_SERVICES}" >/dev/null || return - execute "git" "-c" "init.defaultBranch=master" "init" "--quiet" - execute "git" "config" "remote.origin.url" "${HOMEBREW_SERVICES_DEFAULT_GIT_REMOTE}" - execute "git" "config" "remote.origin.fetch" "+refs/heads/*:refs/remotes/origin/*" - execute "git" "config" "--bool" "core.autocrlf" "false" - execute "git" "config" "--bool" "core.symlinks" "true" - execute "git" "fetch" "--force" "origin" "refs/heads/master:refs/remotes/origin/master" - execute "git" "remote" "set-head" "origin" "--auto" >/dev/null - execute "git" "reset" "--hard" "origin/master" + execute "${USABLE_GIT}" "-c" "init.defaultBranch=master" "init" "--quiet" + execute "${USABLE_GIT}" "config" "remote.origin.url" "${HOMEBREW_SERVICES_DEFAULT_GIT_REMOTE}" + execute "${USABLE_GIT}" "config" "remote.origin.fetch" "+refs/heads/*:refs/remotes/origin/*" + execute "${USABLE_GIT}" "config" "--bool" "core.autocrlf" "false" + execute "${USABLE_GIT}" "config" "--bool" "core.symlinks" "true" + execute "${USABLE_GIT}" "fetch" "--force" "origin" "refs/heads/master:refs/remotes/origin/master" + execute "${USABLE_GIT}" "remote" "set-head" "origin" "--auto" >/dev/null + execute "${USABLE_GIT}" "reset" "--hard" "origin/master" cd "${HOMEBREW_REPOSITORY}" >/dev/null || return ) || exit 1 @@ -1063,8 +1064,8 @@ EOS ( cd "${HOMEBREW_REPOSITORY}" >/dev/null || return - execute "git" "config" "--replace-all" "homebrew.analyticsmessage" "true" - execute "git" "config" "--replace-all" "homebrew.caskanalyticsmessage" "true" + execute "${USABLE_GIT}" "config" "--replace-all" "homebrew.analyticsmessage" "true" + execute "${USABLE_GIT}" "config" "--replace-all" "homebrew.caskanalyticsmessage" "true" ) || exit 1 ohai "Next steps:" @@ -1126,6 +1127,18 @@ EOS " fi +if [[ ":${PATH}:" != *":${HOMEBREW_PREFIX}/bin:"* ]] +then + eval "\$(${HOMEBREW_PREFIX}/bin/brew shellenv)" + + echo "" + warn "!!!!!!!!!!! 重要 !!!!!!!!!!!!!!!" + cat <