(feat) add dependencies
This commit is contained in:
parent
44afad7241
commit
b4c9cb55d2
49
brick.sh
49
brick.sh
|
@ -78,6 +78,19 @@ tmpdir() {
|
|||
exec_brick() {
|
||||
echo -e "$(bricksenv)\n$*" | bash
|
||||
}
|
||||
print_long_list() {
|
||||
list=($@)
|
||||
i=0
|
||||
printf '%s' "$(inf)$(inf)"
|
||||
for el in ${list[@]}; do
|
||||
printf '%s ' $el
|
||||
if [ "$i" == "2" ]; then
|
||||
printf '\n%s' "$(inf)$(inf)"
|
||||
fi
|
||||
i=$(( i + 1 ))
|
||||
done
|
||||
echo
|
||||
}
|
||||
|
||||
# checking that brick's dependencies are installed
|
||||
BRICK_DEPS=(curl)
|
||||
|
@ -190,11 +203,45 @@ if [ "$ERRORED" == "true" ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# lets resolve the dependencies huh
|
||||
find_deps_for() {
|
||||
brick=$1
|
||||
deps=()
|
||||
SCRIPT="
|
||||
source $(getbrick $brick)\n
|
||||
if ! [ \"\$dependencies\" == \"\" ]; then\n
|
||||
echo \"\${dependencies[@]}\"\n
|
||||
fi\n
|
||||
"
|
||||
deps=$(exec_brick $SCRIPT)
|
||||
deps=(${deps[@]})
|
||||
if ! [ "${#deps[@]}" == "0" ]; then
|
||||
for dep in "${deps[@]}"; do
|
||||
if ! [ -f "$(getbrick $dep)" ]; then
|
||||
err "$brick depends on $dep, which is not an available package"
|
||||
ERRORED=true
|
||||
fi
|
||||
ndeps=$(find_deps_for $dep)
|
||||
deps=(${deps[@]} ${ndeps[@]})
|
||||
done
|
||||
fi
|
||||
|
||||
echo ${deps[@]}
|
||||
}
|
||||
for pkg in "${PKGS[@]}"; do
|
||||
PKGS=(${PKGS[@]} $(find_deps_for $pkg))
|
||||
done
|
||||
|
||||
if [ "$ERRORED" == "true" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${#PKGS[@]}" == "0" ]; then
|
||||
inf "nothing to do"
|
||||
exit
|
||||
else
|
||||
inf "packages to install: ${PKGS[@]}"
|
||||
inf "packages to install:"
|
||||
print_long_list "${PKGS[@]}"
|
||||
if ! user_confirm; then
|
||||
inf "canceled"
|
||||
exit
|
||||
|
|
Loading…
Reference in New Issue