Compare commits
2 Commits
44afad7241
...
098f3a0962
Author | SHA1 | Date |
---|---|---|
b1ek | 098f3a0962 | |
b1ek | b4c9cb55d2 |
51
brick.sh
51
brick.sh
|
@ -78,6 +78,21 @@ tmpdir() {
|
||||||
exec_brick() {
|
exec_brick() {
|
||||||
echo -e "$(bricksenv)\n$*" | bash
|
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
|
||||||
|
if ! [ "$(( "${#list[@]}" % 3 ))" == "0" ]; then
|
||||||
|
printf '\n%s' "$(inf)$(inf)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
i=$(( i + 1 ))
|
||||||
|
done
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
# checking that brick's dependencies are installed
|
# checking that brick's dependencies are installed
|
||||||
BRICK_DEPS=(curl)
|
BRICK_DEPS=(curl)
|
||||||
|
@ -190,11 +205,45 @@ if [ "$ERRORED" == "true" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
if [ "${#PKGS[@]}" == "0" ]; then
|
||||||
inf "nothing to do"
|
inf "nothing to do"
|
||||||
exit
|
exit
|
||||||
else
|
else
|
||||||
inf "packages to install: ${PKGS[@]}"
|
inf "packages to install:"
|
||||||
|
print_long_list "${PKGS[@]}"
|
||||||
if ! user_confirm; then
|
if ! user_confirm; then
|
||||||
inf "canceled"
|
inf "canceled"
|
||||||
exit
|
exit
|
||||||
|
|
Loading…
Reference in New Issue