From bbf39bd59f31084d499c2cdd064274093b39dad8 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 9 Apr 2010 23:56:28 +0200 Subject: added dependency based system to run defined tasks --- inc/bootstrap.inc.sh | 46 ---------------------- inc/chroot-functions.inc.sh | 8 ++-- inc/env.inc.sh | 8 ++-- inc/functions.inc.sh | 96 +++++++++++++++++++++++++++++++++++++++++++++ inc/helper.inc.sh | 10 +++-- inc/update.inc.sh | 4 +- 6 files changed, 113 insertions(+), 59 deletions(-) delete mode 100644 inc/bootstrap.inc.sh create mode 100644 inc/functions.inc.sh (limited to 'inc') diff --git a/inc/bootstrap.inc.sh b/inc/bootstrap.inc.sh deleted file mode 100644 index 7822b96..0000000 --- a/inc/bootstrap.inc.sh +++ /dev/null @@ -1,46 +0,0 @@ - -bootstrap () { - [ ! -d $buildrootpath ] && mkdir -p $buildrootpath - - echo "broot is going to run debootsrap now: ~-_" - echo " depending on your machine/connection this can _-~ " - echo " take up to 20min.. time enough for a coffee ;) c|_| " - echo "press Strg-c to abbort" - echo -n "Starting debootsrap in .. " - echo -en "${R}3${NONE} " && sleep 1 && \ - echo -en "${R}2${NONE} " && sleep 1 && \ - echo -en "${R}1${NONE} " && sleep 1 && \ - echo ".. go " - - export DEBOOTSTRAP_DIR="$BROOT_BASE_DIR/contrib/debootstrap" - - mkdir -p "$buildrootpath/root/bin" - - mkdir -p "/tmp/deb/partial" - mkdir -p "$buildrootpath/var/cache/apt/archives" - mount -o bind "/tmp/deb" "$buildrootpath/var/cache/apt/archives" - - $DEBOOTSTRAP_DIR/debootstrap --arch="i386" squeeze $buildrootpath http://ftp.de.debian.org/debian - - touch $buildrootpath/bootstraped - - sed -i -e "s,main,main non-free," $buildrootpath/etc/apt/sources.list - setupBindmounts $buildrootpath - updatebuildroot $buildrootpath - chroot-exec aptitude update - - chroot-aptinstall locales - sed -i -e "s,^#.*\(en_US.*\)$,\1," $buildrootpath/etc/locale.gen - chroot-exec locale-gen - chroot-aptinstall build-essential - chroot-aptinstall git-core subversion - chroot-aptinstall firmware-iwlwifi firmware-linux firmware-linux-free firmware-linux-nonfree linux-image-2.6.32-trunk-686-bigmem - - cp ./chroot-scripts/* $buildrootpath/root/bin/ - chmod 700 $buildrootpath/root/bin/* - - # chroot-exec /root/bin/build-bb.sh - - destroyBindmounts - -} diff --git a/inc/chroot-functions.inc.sh b/inc/chroot-functions.inc.sh index b07f3ea..5693a54 100644 --- a/inc/chroot-functions.inc.sh +++ b/inc/chroot-functions.inc.sh @@ -1,13 +1,13 @@ chroot-exec () { - if [ $(mount |grep -c $buildrootpath/dev) -eq 0 ]; then + if [ $(mount |grep -c $BROOT_BUILDROOT_PATH/dev) -eq 0 ]; then setupBindmounts fi - chroot $buildrootpath linux32 $@ + chroot $BROOT_BUILDROOT_PATH linux32 $@ } chroot-aptinstall () { - if [ $(mount |grep -c $buildrootpath/dev) -eq 0 ]; then + if [ $(mount |grep -c $BROOT_BUILDROOT_PATH/dev) -eq 0 ]; then setupBindmounts fi - chroot $buildrootpath linux32 aptitude install -y $@ + chroot $BROOT_BUILDROOT_PATH linux32 aptitude install -y $@ } diff --git a/inc/env.inc.sh b/inc/env.inc.sh index bab613c..34e9c5b 100644 --- a/inc/env.inc.sh +++ b/inc/env.inc.sh @@ -1,12 +1,14 @@ slxsettings=$(slxsettings 2>/dev/null ) if [ $? -eq 0 ]; then - buildrootpath=$(slxsettings |grep public-path | sed -e "s,^.*='\(.*\)'$,\1,") - buildrootpath="$buildrootpath/buildroot" + BROOT_BUILDROOT_PATH=$(slxsettings |grep public-path | sed -e "s,^.*='\(.*\)'$,\1,") + BROOT_BUILDROOT_PATH="$BROOT_BUILDROOT_PATH/buildroot" else - buildrootpath="/tmp/buildroot" + BROOT_BUILDROOT_PATH="/tmp/buildroot" fi SCRIPT=$(readlink -f $0) SCRIPTPATH=`dirname $SCRIPT` BROOT_BASE_DIR=$SCRIPTPATH +BROOT_LOG=/tmp/broot.log +[ -e /tmp/.broot.tasks ] && rm -rf /tmp/.broot.tasks diff --git a/inc/functions.inc.sh b/inc/functions.inc.sh new file mode 100644 index 0000000..9535750 --- /dev/null +++ b/inc/functions.inc.sh @@ -0,0 +1,96 @@ + +. ./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 +} diff --git a/inc/helper.inc.sh b/inc/helper.inc.sh index eed974d..00c1915 100644 --- a/inc/helper.inc.sh +++ b/inc/helper.inc.sh @@ -1,11 +1,13 @@ setupBindmounts() { - mount -o bind /proc $buildrootpath/proc - mount -o bind /dev $buildrootpath/dev + mount -o bind /proc $BROOT_BUILDROOT_PATH/proc + mount -t devtmpfs dev $BROOT_BUILDROOT_PATH/dev + chroot $BROOT_BUILDROOT_PATH mount -t devpts devpts /dev/pts } destroyBindmounts() { - umount $buildrootpath/proc - umount $buildrootpath/dev + umount $BROOT_BUILDROOT_PATH/proc + umount $BROOT_BUILDROOT_PATH/dev/pts + umount $BROOT_BUILDROOT_PATH/dev umount /tmp/deb } diff --git a/inc/update.inc.sh b/inc/update.inc.sh index af3ff9d..fa7cd25 100644 --- a/inc/update.inc.sh +++ b/inc/update.inc.sh @@ -5,6 +5,6 @@ updatebuildroot () { } updateScripts () { - cp ./chroot-scripts/* $buildrootpath/root/bin/ - chmod 700 $buildrootpath/root/bin/* + cp ./chroot-scripts/* $BROOT_BUILDROOT_PATH/root/bin/ + chmod 700 $BROOT_BUILDROOT_PATH/root/bin/* } -- cgit v1.2.3-55-g7522