summaryrefslogtreecommitdiffstats
path: root/install
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2016-02-21 22:11:28 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2016-02-21 22:11:28 +0900
commit42c006d07c7d795517aa6040f4ac789b371a3ea6 (patch)
treef677761ea39187ff85d51a1e9827fd1fefef416b /install
parent1b9ca314b87283b8daf2e0e16201779dadc1b5fa (diff)
Update install script to try "go get ..."
Related: #470, #497
Diffstat (limited to 'install')
-rwxr-xr-xinstall49
1 files changed, 35 insertions, 14 deletions
diff --git a/install b/install
index 8177e7b4..225d4936 100755
--- a/install
+++ b/install
@@ -102,6 +102,16 @@ symlink() {
fi
}
+link_fzf_in_path() {
+ if which_fzf="$(which fzf 2> /dev/null)"; then
+ echo " - Found in \$PATH"
+ echo " - Creating symlink: $which_fzf -> bin/fzf"
+ (cd "$fzf_base"/bin && rm -f fzf && ln -sf "$which_fzf" fzf)
+ check_binary && return
+ fi
+ return 1
+}
+
download() {
echo "Downloading bin/fzf ..."
if [ $pre = 0 ]; then
@@ -112,12 +122,7 @@ download() {
if [ -x "$fzf_base"/bin/$1 ]; then
symlink $1 && check_binary && return
fi
- if which_fzf="$(which fzf 2> /dev/null)"; then
- echo " - Found in \$PATH"
- echo " - Creating symlink: $which_fzf -> bin/fzf"
- (cd "$fzf_base"/bin && rm -f fzf && ln -sf "$which_fzf" fzf)
- check_binary && return
- fi
+ link_fzf_in_path && return
fi
mkdir -p "$fzf_base"/bin && cd "$fzf_base"/bin
if [ $? -ne 0 ]; then
@@ -155,14 +160,7 @@ case "$archi" in
*) binary_available=0 binary_error=1 ;;
esac
-cd "$fzf_base"
-if [ -n "$binary_error" ]; then
- if [ $binary_available -eq 0 ]; then
- echo "No prebuilt binary for $archi ... "
- else
- echo " - $binary_error !!!"
- exit 1
- fi
+install_ruby_fzf() {
echo "Installing legacy Ruby version ..."
# ruby executable
@@ -228,6 +226,29 @@ if [ -n "$binary_error" ]; then
echo "$fzf_cmd \"\$@\"" >> "$fzf_base"/bin/fzf
chmod +x "$fzf_base"/bin/fzf
echo "OK"
+}
+
+cd "$fzf_base"
+if [ -n "$binary_error" ]; then
+ if [ $binary_available -eq 0 ]; then
+ echo "No prebuilt binary for $archi ..."
+ if which go > /dev/null 2>&1; then
+ echo -n "Building binary (go get github.com/junegunn/fzf/src/fzf) ... "
+ if go get github.com/junegunn/fzf/src/fzf; then
+ echo "OK"
+ link_fzf_in_path
+ else
+ echo "Failed to build binary ..."
+ install_ruby_fzf
+ fi
+ else
+ echo "go executable not found. Cannot build binary ..."
+ install_ruby_fzf
+ fi
+ else
+ echo " - $binary_error !!!"
+ exit 1
+ fi
fi
[[ "$*" =~ "--bin" ]] && exit 0