ref(install): some refactoring
This commit is contained in:
parent
6648edd51d
commit
685f7bdade
29
install
29
install
@ -200,14 +200,14 @@ cmd_docker() {
|
|||||||
__install_from_sandbox
|
__install_from_sandbox
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_check() {
|
is_target_installed() {
|
||||||
local not_fully_installed=0
|
local not_fully_installed=0
|
||||||
|
|
||||||
local targetfile
|
local targetfile
|
||||||
for targetfile in ${TARGETS["$1"]}
|
for targetfile in ${TARGETS["$1"]}
|
||||||
do
|
do
|
||||||
if [ "${targetfile::1}" = "%" ]; then
|
if [ "${targetfile::1}" = "%" ]; then
|
||||||
cmd_check "${targetfile:1}" || not_fully_installed=1
|
is_target_installed "${targetfile:1}" || not_fully_installed=1
|
||||||
else
|
else
|
||||||
if [ ! -e "$TARGET_PATH/$targetfile" ]; then
|
if [ ! -e "$TARGET_PATH/$targetfile" ]; then
|
||||||
echo "$targetfile not linked"
|
echo "$targetfile not linked"
|
||||||
@ -233,17 +233,20 @@ find_targets_that_depend_on() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
die_if_installed_targets_depend_on() {
|
||||||
|
for reverse_dependecy in $(find_targets_that_depend_on "$1")
|
||||||
|
do
|
||||||
|
if is_target_installed "$reverse_dependecy" >/dev/null; then
|
||||||
|
_die "target '$reverse_dependecy' is depends on installed target '$1'. Exiting..." 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
cmd_unlink() {
|
cmd_unlink() {
|
||||||
local target targetfile
|
local target targetfile
|
||||||
for target in "$@"
|
for target in "$@"
|
||||||
do
|
do
|
||||||
for reverse_dependecy in $(find_targets_that_depend_on "$target")
|
die_if_installed_targets_depend_on "$target"
|
||||||
do
|
|
||||||
if cmd_check "$reverse_dependecy" >/dev/null; then
|
|
||||||
echo "'$reverse_dependecy' is depends on installed '$target'. Exiting..."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
for targetfile in ${TARGETS["$target"]}
|
for targetfile in ${TARGETS["$target"]}
|
||||||
do
|
do
|
||||||
@ -307,10 +310,10 @@ unset executed_command
|
|||||||
readonly executed_command="$1"
|
readonly executed_command="$1"
|
||||||
|
|
||||||
case "$executed_command" in
|
case "$executed_command" in
|
||||||
unlink) shift; cmd_unlink "$@" ;;
|
unlink) shift; cmd_unlink "$@" ;;
|
||||||
check) shift; cmd_check "$@" ;;
|
check) shift; is_target_installed "$@" ;;
|
||||||
list) shift; cmd_list "$@" ;;
|
list) shift; cmd_list "$@" ;;
|
||||||
help) shift; cmd_help "$@" ;;
|
help) shift; cmd_help "$@" ;;
|
||||||
*) shift; cmd_install "$executed_command" "$@" ;;
|
*) shift; cmd_install "$executed_command" "$@" ;;
|
||||||
esac
|
esac
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user