-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·96 lines (75 loc) · 2.04 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
#!/usr/bin/env bash
check_requirements() {
local missing_deps=()
for command in \
"autoconf" \
"automake" \
"autopoint" \
"gcc" \
"gettext" \
"git" \
"groff" \
"make" \
"pkg-config"; do
if ! type $command >& /dev/null; then
missing_deps+=($command)
fi
done
if [[ ${#missing_deps[*]} -gt 0 ]]; then
echo "ERROR: missing dependency: ${missing_deps[@]}"
exit 1
fi
}
install_nano() {
local version=$1
local install_path=$2
local concurrency=$3
check_requirements
local default_config="--enable-utf8"
local config="${ASDF_NANO_CONFIG:-${default_config}}"
if [[ -z "$TMPDIR" ]]; then
local tmp_download_dir="$(mktemp -d -t asdf_nano_build_XXXXXX)"
else
local tmp_download_dir="$TMPDIR"
fi
# path to the repo
local 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 "git" &> /dev/null; then
echo "ERROR: git not found"
exit 1
fi
cd "$source_path" || exit 1
./autogen.sh
if [[ "${version}" =~ ^[0-9]+\.* ]] ; then
# if version is a release number, remove specific files to prevent showing the git revision as the nano's version.
rm -rf .git roll-a-release.sh
fi
local configure_option="--prefix=${install_path} $config"
echo "configure option: $configure_option"
./configure $configure_option || exit 1
make -j "$concurrency" || exit 1
make install || exit 1
make clean all
)
}
download_source_file() {
local version=$1
local download_path=$2
local download_url="https://git.savannah.gnu.org/git/nano.git"
if [[ "${version}" =~ ^[0-9]+\.* ]] ; then
# if version is a release number, prepend v
version="v$version"
fi
git -c advice.detachedHead=false clone --depth=1 --branch=${version} "${download_url}" "${download_path}"
}
get_download_file_path() {
local version=$1
local tmp_download_dir=$2
echo "$tmp_download_dir/nano-$version"
}
install_nano $ASDF_INSTALL_VERSION $ASDF_INSTALL_PATH $ASDF_CONCURRENCY