Update submodules, clean up the update, specify the need for coretutils (for the timeout command), and allow the use of gtimeout in the update script on OSX

This commit is contained in:
Kevin MacMartin 2016-09-29 11:46:56 -04:00
parent 279a6cabe9
commit 4374e1155d
4 changed files with 35 additions and 4 deletions

View file

@ -6,6 +6,7 @@ A theme, config and collection of plugins for Vim.
* **Vim**: The latest [vim](http://www.vim.org) should be installed to use this distribution (versions 7.3 and below aren't tested or guaranteed to work). * **Vim**: The latest [vim](http://www.vim.org) should be installed to use this distribution (versions 7.3 and below aren't tested or guaranteed to work).
* **Bash**: Required by the _update_ and _gentags_ scripts. * **Bash**: Required by the _update_ and _gentags_ scripts.
* **Coreutils**: Required by the _update_ script.
* **Git**: Required by the _update_ script and git-related plugins. * **Git**: Required by the _update_ script and git-related plugins.
* **Python**: Required by the _gundo_ and _MatchTagAlways_ plugins. * **Python**: Required by the _gundo_ and _MatchTagAlways_ plugins.

34
update
View file

@ -10,6 +10,7 @@
script_name="${0//*\/}" script_name="${0//*\/}"
script_home="${0%$script_name}" script_home="${0%$script_name}"
if [[ -z "$script_home" ]]; then if [[ -z "$script_home" ]]; then
script_home="$PWD" script_home="$PWD"
else else
@ -17,6 +18,7 @@ else
script_home="$PWD" script_home="$PWD"
popd >/dev/null popd >/dev/null
fi fi
repo_version="$(printf "%s.r%s" "$(git show -s --format=%ci master | sed 's/\ .*//g;s/-//g')" "$(git rev-list --count HEAD)")" repo_version="$(printf "%s.r%s" "$(git show -s --format=%ci master | sed 's/\ .*//g;s/-//g')" "$(git rev-list --count HEAD)")"
error_log='update-errors.log' error_log='update-errors.log'
@ -36,10 +38,12 @@ error_log='update-errors.log'
function error { function error {
printf '%s\n' "$cbg_blue $c_reset$cbg_red_bold ! ERROR: $c_reset$cfg_red_bold $2 " >&2 printf '%s\n' "$cbg_blue $c_reset$cbg_red_bold ! ERROR: $c_reset$cfg_red_bold $2 " >&2
printf '%s\n' "$cbg_blue $c_reset$cbg_red_bold ! COMMAND: $c_reset ${cfg_white_bold}=> $1$c_reset" >&2 printf '%s\n' "$cbg_blue $c_reset$cbg_red_bold ! COMMAND: $c_reset ${cfg_white_bold}=> $1$c_reset" >&2
[[ -n "$3" ]] \ [[ -n "$3" ]] \
&& printf '%s\n' "$cbg_blue $c_reset$cbg_red_bold ! OUTPUT: $c_reset$cfg_white_bold $3" >&2 && printf '%s\n' "$cbg_blue $c_reset$cbg_red_bold ! OUTPUT: $c_reset$cfg_white_bold $3" >&2
printf '%s\n%s\n%s\n' "DATE: @ $(date)" "ERROR: $2" "COMMAND: $1" >> "$script_home/$error_log" printf '%s\n%s\n%s\n' "DATE: @ $(date)" "ERROR: $2" "COMMAND: $1" >> "$script_home/$error_log"
[[ -n "$3" ]] \ [[ -n "$3" ]] \
&& printf '%s\n' "OUTPUT: $3" >> "$script_home/$error_log" && printf '%s\n' "OUTPUT: $3" >> "$script_home/$error_log"
@ -62,6 +66,15 @@ function show_help {
} }
### SETUP ### SETUP
if type -P timeout >/dev/null; then
timeout_command=timeout
elif type -P gtimeout >/dev/null; then
timeout_command=gtimeout
else
error 'type -P timeout' 'The timeout command could not be found (install coreutils)'
exit 1
fi
cd "$script_home" || exit cd "$script_home" || exit
# delete old error log if it exists # delete old error log if it exists
@ -95,6 +108,7 @@ printf '\n%s\n' "$cbg_black ~~~ DarkCloud Vimconfig Update Tool ~~~ $c_reset"
[[ -d 'vim/bundle.user' ]] || { [[ -d 'vim/bundle.user' ]] || {
printf '\n%s' "$cbg_blue >> Creating user plugin directory:$c_reset" printf '\n%s' "$cbg_blue >> Creating user plugin directory:$c_reset"
process_status="$(install -d 'vim/bundle.user' 2>&1)" process_status="$(install -d 'vim/bundle.user' 2>&1)"
if (( ! $? )); then if (( ! $? )); then
printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset" printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset"
else else
@ -107,6 +121,7 @@ printf '\n%s\n' "$cbg_black ~~~ DarkCloud Vimconfig Update Tool ~~~ $c_reset"
[[ -e 'vim/vimrc.user' ]] || { [[ -e 'vim/vimrc.user' ]] || {
printf '\n%s' "$cbg_blue >> Creating user config file:$c_reset" printf '\n%s' "$cbg_blue >> Creating user config file:$c_reset"
process_status="$(touch 'vim/vimrc.user' 2>&1)" process_status="$(touch 'vim/vimrc.user' 2>&1)"
if (( ! $? )); then if (( ! $? )); then
{ {
printf '%s\n%s\n\n' '"Autostart Filer in empty buffers: (*1:filer loads in new empty buffers | 0:filer must be triggered)' '"let g:autostartfiler=1' printf '%s\n%s\n\n' '"Autostart Filer in empty buffers: (*1:filer loads in new empty buffers | 0:filer must be triggered)' '"let g:autostartfiler=1'
@ -117,6 +132,7 @@ printf '\n%s\n' "$cbg_black ~~~ DarkCloud Vimconfig Update Tool ~~~ $c_reset"
printf '%s\n%s\n\n' '"Enable Powerline fonts: (1:expect powerline font | *0:expect regular font)' '"let g:powerlinefonts=0 "(set powerline font for gvim and terminal when enabled)' printf '%s\n%s\n\n' '"Enable Powerline fonts: (1:expect powerline font | *0:expect regular font)' '"let g:powerlinefonts=0 "(set powerline font for gvim and terminal when enabled)'
printf '%s\n%s\n' '"GVim font selection: (Escaping spaces and use powerline if appropriate)' '"set guifont=Monospace\ 12' printf '%s\n%s\n' '"GVim font selection: (Escaping spaces and use powerline if appropriate)' '"set guifont=Monospace\ 12'
} >> vim/vimrc.user } >> vim/vimrc.user
if [[ -e 'vim/vimrc.user' ]]; then if [[ -e 'vim/vimrc.user' ]]; then
printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset" printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset"
else else
@ -131,6 +147,7 @@ printf '\n%s\n' "$cbg_black ~~~ DarkCloud Vimconfig Update Tool ~~~ $c_reset"
### REPO UPDATE ### REPO UPDATE
printf '\n%s' "$cbg_blue >> Updating darkcloud-vimconfig:$c_reset" printf '\n%s' "$cbg_blue >> Updating darkcloud-vimconfig:$c_reset"
process_status="$(git pull origin master 2>&1)" process_status="$(git pull origin master 2>&1)"
if (( ! $? )); then if (( ! $? )); then
printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset" printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset"
else else
@ -143,6 +160,7 @@ fi
printf '\n%s\n' "$cbg_blue >> Updating plugin submodules >> $c_reset" printf '\n%s\n' "$cbg_blue >> Updating plugin submodules >> $c_reset"
printf '%s' "$cbg_blue $c_reset$cbg_yellow + Updating plugin URLs:$c_reset" printf '%s' "$cbg_blue $c_reset$cbg_yellow + Updating plugin URLs:$c_reset"
process_status="$(git submodule sync 2>&1)" process_status="$(git submodule sync 2>&1)"
if (( ! $? )); then if (( ! $? )); then
printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset" printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset"
else else
@ -154,8 +172,10 @@ fi
printf '%s' "$cbg_blue $c_reset$cbg_yellow + Fetching updates:$c_reset" printf '%s' "$cbg_blue $c_reset$cbg_yellow + Fetching updates:$c_reset"
git submodule foreach git reset --hard >/dev/null 2>&1 git submodule foreach git reset --hard >/dev/null 2>&1
process_status="$(git submodule foreach git fetch --all 2>&1)" process_status="$(git submodule foreach git fetch --all 2>&1)"
if (( ! $? )); then if (( ! $? )); then
process_status=$(git submodule update --init --recursive 2>&1) process_status=$(git submodule update --init --recursive 2>&1)
if (( ! $? )); then if (( ! $? )); then
printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset" printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset"
else else
@ -170,6 +190,7 @@ fi
# run 'git checkout origin/master' on each submodule # run 'git checkout origin/master' on each submodule
printf '%s' "$cbg_blue $c_reset$cbg_yellow + Checkout updates:$c_reset" printf '%s' "$cbg_blue $c_reset$cbg_yellow + Checkout updates:$c_reset"
process_status="$(git submodule foreach git checkout -f origin/master 2>&1)" process_status="$(git submodule foreach git checkout -f origin/master 2>&1)"
if (( ! $? )); then if (( ! $? )); then
printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset" printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset"
else else
@ -181,6 +202,7 @@ fi
printf '\n%s\n' "$cbg_blue >> Clean plugin directories >> $c_reset" printf '\n%s\n' "$cbg_blue >> Clean plugin directories >> $c_reset"
printf '%s' "$cbg_blue $c_reset$cbg_yellow + Remove untracked files:$c_reset" printf '%s' "$cbg_blue $c_reset$cbg_yellow + Remove untracked files:$c_reset"
process_status="$(git submodule foreach git clean -dxf 2>&1)" process_status="$(git submodule foreach git clean -dxf 2>&1)"
if (( ! $? )); then if (( ! $? )); then
printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset" printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset"
else else
@ -192,12 +214,15 @@ fi
for plugin in vim/bundle/*; do for plugin in vim/bundle/*; do
[[ -f "$plugin/.git" ]] && { [[ -f "$plugin/.git" ]] && {
plugin_dirname="${plugin/*\/}" plugin_dirname="${plugin/*\/}"
grep 'path = ' .gitmodules | egrep -o '[^\/]*$' | egrep -q "$plugin_dirname$" || { grep 'path = ' .gitmodules | egrep -o '[^\/]*$' | egrep -q "$plugin_dirname$" || {
[[ -z "$first_found" ]] && { [[ -z "$first_found" ]] && {
first_found=1 first_found=1
printf '%s\n' "$cbg_blue $c_reset$cbg_yellow + Removing old plugins: $c_reset" printf '%s\n' "$cbg_blue $c_reset$cbg_yellow + Removing old plugins: $c_reset"
} }
process_status="$(rm -rf "${plugin:?}")" process_status="$(rm -rf "${plugin:?}")"
if (( ! $? )); then if (( ! $? )); then
printf '%s\n' "$cbg_blue $c_reset$cbg_yellow = $cfg_white_bold$plugin$c_reset" printf '%s\n' "$cbg_blue $c_reset$cbg_yellow = $cfg_white_bold$plugin$c_reset"
else else
@ -207,6 +232,7 @@ fi
} }
} }
done done
printf '\n' printf '\n'
} }
@ -214,11 +240,13 @@ fi
[[ -d vim/bundle.user ]] && find vim/bundle.user -mindepth 3 -maxdepth 3 -name config | grep -q '.git/config' && { [[ -d vim/bundle.user ]] && find vim/bundle.user -mindepth 3 -maxdepth 3 -name config | grep -q '.git/config' && {
printf '%s\n' "$cbg_blue >> Updating user plugins >> $c_reset" printf '%s\n' "$cbg_blue >> Updating user plugins >> $c_reset"
pushd 'vim/bundle.user' >/dev/null pushd 'vim/bundle.user' >/dev/null
for plugin in *; do for plugin in *; do
[[ -d "$plugin/.git" ]] && { [[ -d "$plugin/.git" ]] && {
pushd "$plugin" >/dev/null pushd "$plugin" >/dev/null
printf '%s' "$cbg_blue $c_reset$cbg_yellow + Updating 'vim/bundle.user/$plugin':$c_reset" printf '%s' "$cbg_blue $c_reset$cbg_yellow + Updating 'vim/bundle.user/$plugin':$c_reset"
process_status="$(git pull origin master 2>&1)" process_status="$(git pull origin master 2>&1)"
if (( ! $? )); then if (( ! $? )); then
if ! grep -q "Already up-to-date" <<< "$process_status"; then if ! grep -q "Already up-to-date" <<< "$process_status"; then
printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset" printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset"
@ -228,9 +256,11 @@ fi
else else
error 'git pull origin master' "Failed pulling changes for $plugin" "$process_status" error 'git pull origin master' "Failed pulling changes for $plugin" "$process_status"
fi fi
popd >/dev/null popd >/dev/null
} }
done done
popd >/dev/null popd >/dev/null
printf '\n' printf '\n'
} }
@ -238,7 +268,8 @@ fi
### GENERATE PLUGIN HELP ### GENERATE PLUGIN HELP
[[ $(type -P vim) ]] && { [[ $(type -P vim) ]] && {
printf '%s' "$cbg_blue >> Generating plugin help:$c_reset" printf '%s' "$cbg_blue >> Generating plugin help:$c_reset"
timeout --preserve-status --foreground 1m vim -u "./vimrc" -c "Helptags|qa!" $timeout_command --preserve-status --foreground 1m vim -u "./vimrc" -c "Helptags|qa!"
if (( ! $? )); then if (( ! $? )); then
printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset" printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset"
else else
@ -250,4 +281,3 @@ fi
### FINISH ### FINISH
printf '\n%s\n\n' "$cbg_black ~~~ Update Complete ~~~ $c_reset" printf '\n%s\n\n' "$cbg_black ~~~ Update Complete ~~~ $c_reset"

@ -1 +1 @@
Subproject commit 75b2ea052310bf4615c739808ba9de03f8cdc113 Subproject commit 16d650348538f780d282863ecbdcc45319d36522

@ -1 +1 @@
Subproject commit 472668fbd286c8f8f3db0024a02056d4c25524b1 Subproject commit faf7a0307180ec10418fa0eae85e68b526eed267