Remove zshlib as submodule
This commit is contained in:
committed by
T. R. Bernstein
parent
cf459b84bd
commit
4fa98ea9a5
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +0,0 @@
|
|||||||
[submodule "zshlib"]
|
|
||||||
path = zshlib
|
|
||||||
url = https://github.com/astzweig/zshlib
|
|
||||||
96
bootstrap.sh
96
bootstrap.sh
@@ -1,6 +1,39 @@
|
|||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
# vi: set ft=zsh tw=80 ts=2
|
# vi: set ft=zsh tw=80 ts=2
|
||||||
|
|
||||||
|
# =================
|
||||||
|
# Utility Functions
|
||||||
|
# =================
|
||||||
|
|
||||||
|
function isDebug() {
|
||||||
|
[[ ${DEBUG} == true || ${DEBUG} == 1 ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
function printSuccess() {
|
||||||
|
printOrLog "${colors[green]}${*}${colors[reset]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function printError() {
|
||||||
|
printOrLog "${errColors[red]}${*}${errColors[reset]}" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
function printFailedWithError() {
|
||||||
|
printOrLog "${colors[red]}failed.${colors[reset]}"
|
||||||
|
printOrLog "$*" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
function printOrLog() {
|
||||||
|
if [[ -t 1 ]]; then
|
||||||
|
print "$@"
|
||||||
|
else
|
||||||
|
logger -t zshlib_bootstrap_sh "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# ==========================
|
||||||
|
# Install Command Line Tools
|
||||||
|
# ==========================
|
||||||
|
|
||||||
function versionGT() {
|
function versionGT() {
|
||||||
[[ "${1%.*}" -gt "${2%.*}" ]] || [[ "${1%.*}" -eq "${2%.*}" && "${1#*.}" -gt "${2#*.}" ]]
|
[[ "${1%.*}" -gt "${2%.*}" ]] || [[ "${1%.*}" -eq "${2%.*}" && "${1#*.}" -gt "${2#*.}" ]]
|
||||||
}
|
}
|
||||||
@@ -9,6 +42,10 @@ function majorMinor() {
|
|||||||
echo "${1%%.*}.$(x="${1#*.}" echo "${x%%.*}")"
|
echo "${1%%.*}.$(x="${1#*.}" echo "${x%%.*}")"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isOnMacOS() {
|
||||||
|
[[ $(uname) == Darwin ]]
|
||||||
|
}
|
||||||
|
|
||||||
function shouldInstallCommandLineTools() {
|
function shouldInstallCommandLineTools() {
|
||||||
local macosVersion=$(majorMinor $(/usr/bin/sw_vers -productVersion))
|
local macosVersion=$(majorMinor $(/usr/bin/sw_vers -productVersion))
|
||||||
if versionGT "${macosVersion}" "10.13"
|
if versionGT "${macosVersion}" "10.13"
|
||||||
@@ -25,7 +62,7 @@ function removeNewlines() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function acceptXcodeLicense() {
|
function acceptXcodeLicense() {
|
||||||
xcodebuild -license accept
|
xcodebuild -license accept 2> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
function installCommandLineTools() {
|
function installCommandLineTools() {
|
||||||
@@ -50,10 +87,15 @@ function installCommandLineTools() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function ensureCommandLineTools() {
|
function ensureCommandLineTools() {
|
||||||
|
isOnMacOS || return
|
||||||
installCommandLineTools
|
installCommandLineTools
|
||||||
acceptXcodeLicense
|
acceptXcodeLicense
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ==================
|
||||||
|
# Download Resources
|
||||||
|
# ==================
|
||||||
|
|
||||||
function ensureDocopts() {
|
function ensureDocopts() {
|
||||||
which docopts > /dev/null && return
|
which docopts > /dev/null && return
|
||||||
local fileURL="${DOCOPTS_URL:-https://github.com/astzweig/docopts/releases/download/v.0.7.0/docopts_darwin_amd64}"
|
local fileURL="${DOCOPTS_URL:-https://github.com/astzweig/docopts/releases/download/v.0.7.0/docopts_darwin_amd64}"
|
||||||
@@ -76,22 +118,15 @@ function cloneZSHLibRepo() {
|
|||||||
git submodule -q update --depth 1 --init --recursive --remote 2> /dev/null || return 10
|
git submodule -q update --depth 1 --init --recursive --remote 2> /dev/null || return 10
|
||||||
}
|
}
|
||||||
|
|
||||||
function isDebug() {
|
function downloadZSHLibWordCodeFromGithub() {
|
||||||
test "${DEBUG}" = true -o "${DEBUG}" = 1
|
local apiURL=${ZSHLIB_RELEASE_API_URL:-https://api.github.com/repos/astzweig/zshlib/releases/latest}
|
||||||
|
local zwcURL=`curl -s $apiURL | python3 -c 'import json,sys;print(json.load(sys.stdin)["assets"][0]["browser_download_url"])' 2> /dev/null`
|
||||||
|
curl --output ./zshlib.zwc -fsSL "${zwcURL}" || return 10
|
||||||
}
|
}
|
||||||
|
|
||||||
function printSuccess() {
|
# ====
|
||||||
print "${colors[green]}${*}${colors[reset]}"
|
# Main
|
||||||
}
|
# ====
|
||||||
|
|
||||||
function printError() {
|
|
||||||
print "${errColors[red]}${*}${errColors[reset]}" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
function printFailedWithError() {
|
|
||||||
print "${colors[red]}failed.${colors[reset]}"
|
|
||||||
print "$*" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
function defineColors() {
|
function defineColors() {
|
||||||
local -A colorCodes=(red "`tput setaf 9`" green "`tput setaf 10`" reset "`tput sgr0`")
|
local -A colorCodes=(red "`tput setaf 9`" green "`tput setaf 10`" reset "`tput sgr0`")
|
||||||
@@ -99,20 +134,6 @@ function defineColors() {
|
|||||||
[ -t 2 ] && errColors=( ${(kv)colorCodes} )
|
[ -t 2 ] && errColors=( ${(kv)colorCodes} )
|
||||||
}
|
}
|
||||||
|
|
||||||
function ensureRepo() {
|
|
||||||
local repoName="$1" cmdName="${2}"
|
|
||||||
print -n "Installing ${1}..."
|
|
||||||
$cmdName || { printFailedWithError "This script requires $repoName but was not able to clone it. Please ensure access to the $repoName repository."; return 10}
|
|
||||||
printSuccess 'done'
|
|
||||||
}
|
|
||||||
|
|
||||||
function ensureBinary() {
|
|
||||||
local binaryName="$1" cmdName="${2}"
|
|
||||||
print -n "Ensure ${1} is installed..."
|
|
||||||
$cmdName || { printFailedWithError "This script requires $binaryName but was neither able to locate and install it. Please install $binaryName and add it to one of the PATH directories."; return 10}
|
|
||||||
printSuccess 'done'
|
|
||||||
}
|
|
||||||
|
|
||||||
function configureTerminal() {
|
function configureTerminal() {
|
||||||
if [ -t 0 ]; then
|
if [ -t 0 ]; then
|
||||||
traps+=("stty $(stty -g)")
|
traps+=("stty $(stty -g)")
|
||||||
@@ -126,6 +147,17 @@ function configureTerminal() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ensure() {
|
||||||
|
local itemType=$1 itemName=$2 itemCmd=$3
|
||||||
|
print -n "Installing ${itemName}..."
|
||||||
|
if [[ $itemType == 'repo' ]]; then
|
||||||
|
$itemCmd || { printFailedWithError "This script requires $itemName but was not able to clone it. Please ensure access to the $itemName repository."; return 10}
|
||||||
|
else
|
||||||
|
$itemCmd || { printFailedWithError "This script requires $itemName but was neither able to locate or install it. Please install $itemName and add it to one of the PATH directories."; return 10}
|
||||||
|
fi
|
||||||
|
printSuccess 'done'
|
||||||
|
}
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
local traps=()
|
local traps=()
|
||||||
local -A colors=() errColors=()
|
local -A colors=() errColors=()
|
||||||
@@ -140,9 +172,9 @@ function main() {
|
|||||||
|
|
||||||
print 'Ensure command line tools are available.'
|
print 'Ensure command line tools are available.'
|
||||||
ensureCommandLineTools
|
ensureCommandLineTools
|
||||||
ensureRepo 'macos-system' cloneMacOSSystemRepo || return
|
ensure 'repo' 'macos-system' cloneMacOSSystemRepo || return
|
||||||
ensureRepo 'zshlib' cloneZSHLibRepo || return
|
ensure 'binary' 'zshlib' downloadZSHLibWordCodeFromGithub || return
|
||||||
ensureBinary 'docopts' ensureDocopts || return
|
ensure 'binary' 'docopts' ensureDocopts || return
|
||||||
|
|
||||||
print 'Will now run the installer.'
|
print 'Will now run the installer.'
|
||||||
[ -t 1 ] && tput cnorm
|
[ -t 1 ] && tput cnorm
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ function main() {
|
|||||||
if [[ "${ZSH_EVAL_CONTEXT}" == toplevel ]]; then
|
if [[ "${ZSH_EVAL_CONTEXT}" == toplevel ]]; then
|
||||||
_DIR="${0:A:h}"
|
_DIR="${0:A:h}"
|
||||||
export ASTZWEIG_MACOS_SYSTEM_LIB=${_DIR}/modules/lib.sh
|
export ASTZWEIG_MACOS_SYSTEM_LIB=${_DIR}/modules/lib.sh
|
||||||
export ASTZWEIG_ZSHLIB=${_DIR}/zshlib
|
export ASTZWEIG_ZSHLIB=${_DIR}/zshlib.zwc
|
||||||
source "${ASTZWEIG_MACOS_SYSTEM_LIB}"
|
source "${ASTZWEIG_MACOS_SYSTEM_LIB}"
|
||||||
main "$@"
|
main "$@"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -2,14 +2,13 @@
|
|||||||
# vi: set ft=zsh tw=80 ts=2
|
# vi: set ft=zsh tw=80 ts=2
|
||||||
|
|
||||||
function autoloadZShLib() {
|
function autoloadZShLib() {
|
||||||
test -d "${ASTZWEIG_ZSHLIB}" || { echo "This module needs astzweig/zshlib to work." >&2; return 99 }
|
[[ -d ${ASTZWEIG_ZSHLIB} || -f ${ASTZWEIG_ZSHLIB} ]] || { echo "This module needs astzweig/zshlib to work." >&2; return 99 }
|
||||||
FPATH="${ASTZWEIG_ZSHLIB}:${FPATH}"
|
|
||||||
fpath+=(${ASTZWEIG_ZSHLIB})
|
fpath+=(${ASTZWEIG_ZSHLIB})
|
||||||
if [[ -d ${ASTZWEIG_ZSHLIB} ]]; then
|
if [[ -d ${ASTZWEIG_ZSHLIB} ]]; then
|
||||||
local funcNames=($(find "${ASTZWEIG_ZSHLIB}" -type f -perm +u=x -maxdepth 1 | awk -F/ '{ print $NF }'))
|
local funcNames=($(find "${ASTZWEIG_ZSHLIB}" -type f -perm +u=x -maxdepth 1 | awk -F/ '{ print $NF }'))
|
||||||
autoload -Uz ${funcNames}
|
autoload -Uz ${funcNames}
|
||||||
elif [[ -f ${ASTZWEIG_ZSHLIB} ]]; then
|
elif [[ -f ${ASTZWEIG_ZSHLIB} ]]; then
|
||||||
autoload -Uzw ${ASTZWEIG_ZSHLIB}
|
autoload -Uzw ${ASTZWEIG_ZSHLIB:t}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
1
zshlib
1
zshlib
Submodule zshlib deleted from 46cbbc2d37
Reference in New Issue
Block a user