-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
78 lines (64 loc) · 1.73 KB
/
install.sh
File metadata and controls
78 lines (64 loc) · 1.73 KB
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
#!/usr/bin/env bash
remove_old_version () {
rm -rf "$(get_package_install_path)"
}
copy_local_source () {
mkdir -p "$(get_package_install_path)"
# Option cp -T does not exist on Mac
# therefore we need to handle the differences
# between different platforms
{
# Supress the output if this does not work.
cp --recursive --no-target-directory "$(pwd)" "$(get_package_install_path)" > /dev/null 2>&1
} || {
cp -R "$(pwd)/" "$(get_package_install_path)/"
}
}
write_script_file () {
cat > "$(get_script_install_path)" <<EOF
#!/usr/bin/env bash
set -o errexit -o pipefail -o nounset
exec $(get_package_main) \$@
EOF
chmod +x "$(get_script_install_path)"
}
check_permissions () {
if ! [ -x "$(get_package_main)" ]; then
echo "WARNING: $(get_package_main) is not executable."
fi
}
cleanup_install () {
clear_clones
echo "Done"
}
install () {
shift
if ! [ -d "${package_bin}" ] ; then
echo "Making directory ${package_bin}"
mkdir -p "${package_bin}"
fi
if ! [ -d "${package_install_path}" ] ; then
echo "Making directory ${package_install_path}"
mkdir -p "${package_install_path}"
fi
if ! [ -d "${package_clones_path}" ] ; then
echo "Making directory ${package_clones_path}"
mkdir -p "${package_clones_path}"
fi
# If a second argument is passed
# clone the url and enter into the
# cloned project assuming it follows
# the correct climate structure.
if [ ! $# -eq 0 ]; then
clear_clones
clone_cli_repository "${1}"
go_to_cloned_repo "$(get_repository_name "${1}")"
fi
read_config
echo "Installing ${CONFIG_NAME} cli to $(get_script_install_path)"
remove_old_version
copy_local_source
write_script_file
check_permissions
trap cleanup_install EXIT
}