-
Notifications
You must be signed in to change notification settings - Fork 3
/
make.sh
executable file
·47 lines (36 loc) · 1.41 KB
/
make.sh
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
#!/bin/sh
MAKE_SCRIPT_DIR="$(realpath "$(dirname "${0}")")"
. "${MAKE_SCRIPT_DIR}/config-files/shell-utils/util.sh"
. "${MAKE_SCRIPT_DIR}/config-files/paths.sh"
. "${MAKE_SCRIPT_DIR}/paths.sh"
usage() {
print_msg "Usage: ${0} <install|uninstall> <pkg> [--verbose]\n"
}
exit_with_msg() {
print_msg "${1}\n"
usage
exit ${2}
}
main() {
setup_verbosity "${@}"
local action="${1}"
local pkg="${2}"
[ -z "${pkg}" ] && exit_with_msg "Missing pkg param" 1
[ ! -f "${MAKE_SCRIPT_DIR}/${pkg}/${pkg}.sh" ] && exit_with_msg "Unknown pkg ${pkg}" 2
. "${MAKE_SCRIPT_DIR}/${pkg}/${pkg}.sh"
[ -z "$(type install | grep "function")" ] && exit_with_msg "Missing install func" 3
[ -z "$(type uninstall | grep "function")" ] && exit_with_msg "Missing uninstall func" 4
if [ "${action}" = "install" ]; then
[ -n "$(type pre_install | grep "function")" ] && perform_task pre_install
perform_task install "Installing ${pkg}"
[ -n "$(type post_install | grep "function")" ] && perform_task post_install
elif [ "${action}" = "uninstall" ]; then
[ -n "$(type pre_uninstall | grep "function")" ] && perform_task pre_uninstall
perform_task uninstall "Uninstalling ${pkg}"
[ -n "$(type post_uninstall | grep "function")" ] && perform_task post_uninstall
else
exit_with_msg "Unknown action ${action}" 5
fi
check_for_errors
}
main "${@}"