-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathinstall
executable file
·117 lines (96 loc) · 2.59 KB
/
install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env bash
install_vim() {
local version
local install_path
local concurrency
version=$1
install_path=$2
concurrency=$(get_valid_concurrency "$3")
echo "Install Vim version:${version}, path:${install_path}, build concurrency:${concurrency}"
local default_config="\
--with-tlib=ncurses \
--with-compiledby=asdf \
--enable-multibyte \
--enable-cscope \
--enable-terminal \
--enable-perlinterp \
--enable-rubyinterp \
--enable-python3interp \
--enable-luainterp \
--enable-gui=no \
--without-x"
local type="${ASDF_VIM_TYPE:-huge}"
local config="${ASDF_VIM_CONFIG:-${default_config}}"
local tmp_download_dir
if [ "${TMPDIR}" = "" ]; then
tmp_download_dir=$(mktemp -d -t asdf_vim_build_XXXXXX)
else
tmp_download_dir="${TMPDIR}"
fi
# path to the tar file
local source_path
source_path=$(get_download_file_path "${version}" "${tmp_download_dir}")
echo "${source_path}"
download_source_file "${version}" "${source_path}"
# running this in subshell
# we don't want to disturb current working dir
(
if ! type "tar" &> /dev/null; then
echo "ERROR: tar not found"
exit 1
fi
tar -xvf "${source_path}" -C "${tmp_download_dir}" || exit 1
cd "${tmp_download_dir}/vim-${version}" || exit 1
local configure_option="--prefix=${install_path} --with-features=${type} ${config}"
# shellcheck disable=SC2086
echo 'configure option: ' $configure_option || exit 1
# shellcheck disable=SC2086
./configure $configure_option || exit 1
make -j "${concurrency}" || exit 1
make install || exit 1
)
return
}
download_source_file() {
local version
local download_path
local download_url
version=$1
download_path=$2
download_url=$(get_download_url "${version}")
curl -Lo "${download_path}" -C - "${download_url}"
return
}
get_download_file_path() {
local version
local tmp_download_dir
version=$1
tmp_download_dir=$2
echo "${tmp_download_dir}/vim-${version}.tar.gz"
return
}
get_download_url() {
local version
version=$1
if [[ "${version}" =~ ^[0-9]+\.* ]] ; then
# if version is a release number, prepend v
echo "https://github.com/vim/vim/archive/v${version}.tar.gz"
else
# otherwise it can be a branch name or commit sha
echo "https://github.com/vim/vim/archive/${version}.tar.gz"
fi
return
}
get_valid_concurrency() {
local concurrency
concurrency=$1
if [[ "${concurrency}" =~ ^[0-9]+$ ]]; then
# number
echo "${concurrency}"
else
# is not number
echo "1"
fi
return
}
install_vim "${ASDF_INSTALL_VERSION}" "${ASDF_INSTALL_PATH}" "${ASDF_CONCURRENCY:-1}"