blob: 9535750cf72c05ce1b2a7f4d59581e7bf0d857a8 (
plain) (
tree)
|
|
. ./inc/chroot-functions.inc.sh
. ./inc/color.inc.sh
. ./inc/helper.inc.sh
cleanup_tmp(){
rm -f /tmp/.broot* >/dev/null 2>&1
}
runtasks() {
echo "tasks=(${tasks[@]:0} cleanup)" > /tmp/.broot.tasks
touch /tmp/.broot.runtime_events
while [ -f /tmp/.broot.tasks -a ! -f /tmp/.broot.exit ]
do
# reread tasks list
. /tmp/.broot.tasks
. /tmp/.broot.runtime_events
[ -f $BROOT_BUILDROOT_PATH/.broot.packages.installed ] || mkdir -p $BROOT_BUILDROOT_PATH && touch $BROOT_BUILDROOT_PATH/.broot.packages.installed
. $BROOT_BUILDROOT_PATH/.broot.packages.installed
if [ -f /tmp/.broot.tasks.replace ]; then
mv /tmp/.broot.tasks.replace /tmp/.broot.tasks
. /tmp/.broot.tasks
fi
#TODO: check dependencies
fulltasks=${tasks[@]:0}
t=${tasks[@]:0:1}
tmp_tasks=${tasks[@]:1}
if [ -e "./tasks/$t.task.sh" ]; then
#echo "DEBUG: parsing task: $t"
#echo "DEBUG: rest of list: $tmp_tasks"
#echo "DEBUG: fulltasklist $fulltasks"
. ./tasks/$t.task.sh
eval append=\$${t}_append
still_need=""
eval runtime_dependencies=\$${t}_runtime_dependencies
have_all_runtime_dependencies=1
for d in $runtime_dependencies
do
eval dep=\$${d}_finished
##echo "check for $dep"
if [ "x$dep" != "x1" ]; then
have_all_runtime_dependencies=0
if [ "x$still_need" == "x" ]; then
still_need="$d"
else
still_need="$d $still_need"
fi
fi
done
eval package_dependencies=\$${t}_package_dependencies
have_all_package_dependencies=1
for d in $package_dependencies
do
eval dep=\$${d}_installed
# echo "check for $dep"
if [ "x$dep" != "x1" ]; then
have_all_package_dependencies=0
if [ "x$still_need" == "x" ]; then
still_need="$d"
else
still_need="$d $still_need"
fi
fi
done
if [ "x$have_all_runtime_dependencies" == "x0" -o "x$have_all_package_dependencies" == "x0" ]; then
echo "tasks=($still_need $fulltasks)" > /tmp/.broot.tasks
#echo "DEBUG: unmatched dependencies: prepending: $still_need; tasks: $fulltasks"
else
echo "-- [$t] --"
eval $t
echo "--"
echo "${t}_finished=1" >> /tmp/.broot.runtime_events
# TODO:
echo "${t}_installed=1" >> $BROOT_BUILDROOT_PATH/.broot.packages.installed
echo "tasks=($append $tmp_tasks)" > /tmp/.broot.tasks
#echo "DEBUG: appended tasks: $append; old tasklist $tmp_tasks"
fi
else
echo "Error: task \"$t\" not found.."
echo "Unfinished tasks: $fulltasks"
echo "Try to fix the problem and run: \"$0 resume\""
echo "tasks=($fulltasks)" > $BROOT_BUILDROOT_PATH/.resume
exit 42
fi
done
rm -f /tmp/.broot.tasks
rm -f /tmp/.broot.exit
rm -f /tmp/.broot.runtime_events
}
|