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 --- tasks/bootstrap.task.sh | 47 ++++++++++++++++++++++++++++++++++++++ tasks/bootstrap_precheck.task.sh | 10 ++++++++ tasks/build_busybox.task.sh | 7 ++++++ tasks/buildtools.task.sh | 17 ++++++++++++++ tasks/cleanup.task.sh | 6 +++++ tasks/locales.task.sh | 11 +++++++++ tasks/update.task.sh | 10 ++++++++ tasks/update_chrootscripts.task.sh | 7 ++++++ 8 files changed, 115 insertions(+) create mode 100644 tasks/bootstrap.task.sh create mode 100644 tasks/bootstrap_precheck.task.sh create mode 100644 tasks/build_busybox.task.sh create mode 100644 tasks/buildtools.task.sh create mode 100644 tasks/cleanup.task.sh create mode 100644 tasks/locales.task.sh create mode 100644 tasks/update.task.sh create mode 100644 tasks/update_chrootscripts.task.sh (limited to 'tasks') diff --git a/tasks/bootstrap.task.sh b/tasks/bootstrap.task.sh new file mode 100644 index 0000000..2f0624b --- /dev/null +++ b/tasks/bootstrap.task.sh @@ -0,0 +1,47 @@ +bootstrap_append="update update_chrootscripts locales" +bootstrap_runtime_dependencies="bootstrap_precheck" + +bootstrap () { + + local ME=bootstrap + + [ ! -d $BROOT_BUILDROOT_PATH ] && mkdir -p $BROOT_BUILDROOT_PATH + + 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" + + # create directory for scripts to be run inside the buildroot + mkdir -p "$BROOT_BUILDROOT_PATH/root/bin" + + # create bindmount outside to apt cache outside chroot + mkdir -p "/tmp/deb/partial" + mkdir -p "$BROOT_BUILDROOT_PATH/var/cache/apt/archives" + mount -o bind "/tmp/deb" "$BROOT_BUILDROOT_PATH/var/cache/apt/archives" + + # run bootstrap itself + echo -n " debootstrap running: " + $DEBOOTSTRAP_DIR/debootstrap --arch="i386" squeeze $BROOT_BUILDROOT_PATH http://ftp.de.debian.org/debian | tee $BROOT_LOG.$ME - | awk '{printf "."}' + lastline=$(tail -n 1 $BROOT_LOG.$ME) + echo "done" + echo " debootstrap finished with: $lastline" + + # write bootstrap lock + touch $BROOT_BUILDROOT_PATH/bootstraped + + # add non-free to apt sources + sed -i -e "s,main,main non-free," $BROOT_BUILDROOT_PATH/etc/apt/sources.list + + echo " update package list" + # update package list + chroot-exec aptitude update >> $BROOT_LOG.$ME + echo " finished all for bootstrap" +} diff --git a/tasks/bootstrap_precheck.task.sh b/tasks/bootstrap_precheck.task.sh new file mode 100644 index 0000000..f2ab6dd --- /dev/null +++ b/tasks/bootstrap_precheck.task.sh @@ -0,0 +1,10 @@ +bootstrap_precheck () { + + local ME=bootstrap_precheck + + if [ -f $BROOT_BUILDROOT_PATH/bootstraped ]; then + tasks=${tmp_tasks#bootstrap} + echo "tasks=(update $tasks)" > /tmp/.broot.tasks.replace + echo " System already bootstraped, run update instead" + fi +} diff --git a/tasks/build_busybox.task.sh b/tasks/build_busybox.task.sh new file mode 100644 index 0000000..eaf373e --- /dev/null +++ b/tasks/build_busybox.task.sh @@ -0,0 +1,7 @@ +build_busybox_package_dependencies="buildtools" + +build_busybox() { + local ME=build_busybox + echo " Building busybox" + chroot-exec /root/bin/build-bb.sh >> $BROOT_LOG.$ME +} diff --git a/tasks/buildtools.task.sh b/tasks/buildtools.task.sh new file mode 100644 index 0000000..da8544a --- /dev/null +++ b/tasks/buildtools.task.sh @@ -0,0 +1,17 @@ +buildtools_package_dependencies="update" + +buildtools() { + local ME=buildtools + + echo -n " Install build-essentials " + chroot-aptinstall build-essential | tee - $DEBUG.$ME | awk '{printf "."}' 2>&1 + echo "done" + + echo -n " Install git, svn " + chroot-aptinstall git-core subversion | tee -a - $DEBUG.$ME | awk '{printf "."}' 2>&1 + echo "done" + + echo -n " Install kernelsources and firmware packages " + chroot-aptinstall firmware-iwlwifi firmware-linux firmware-linux-free firmware-linux-nonfree linux-image-2.6.32-trunk-686-bigmem | tee -a - $DEBUG.$ME | awk '{printf "."}' 2>&1 + echo "done" +} diff --git a/tasks/cleanup.task.sh b/tasks/cleanup.task.sh new file mode 100644 index 0000000..1f25878 --- /dev/null +++ b/tasks/cleanup.task.sh @@ -0,0 +1,6 @@ +cleanup() { + # make sure all bindmounts have been umounted + echo " Umount temporary (bind)mounts" + destroyBindmounts + touch /tmp/.broot.exit +} diff --git a/tasks/locales.task.sh b/tasks/locales.task.sh new file mode 100644 index 0000000..3afc19f --- /dev/null +++ b/tasks/locales.task.sh @@ -0,0 +1,11 @@ +locales_require_bindmounts=1 + +locales() { + local ME=locales + # fix locales + chroot-aptinstall locales > $BROOT_LOG.$ME 2>&1 + sed -i -e "s,^#.*\(en_US.*\)$,\1," $BROOT_BUILDROOT_PATH/etc/locale.gen + chroot-exec locale-gen >> $BROOT_LOG.$ME 2>&1 + lastline=$(tail -n 1 $BROOT_LOG.$ME) + echo " $lastline" +} diff --git a/tasks/update.task.sh b/tasks/update.task.sh new file mode 100644 index 0000000..f6ec089 --- /dev/null +++ b/tasks/update.task.sh @@ -0,0 +1,10 @@ +update_package_dependencies="bootstrap" + +update() { + ME=update + echo " Refresh apt sources" + chroot-exec aptitude update > $DEBUG.$ME 2>&1 + echo -n " Running system update " + chroot-exec aptitude -y safe-upgrade | tee -a - $DEBUG.$ME | awk '{printf "."}' 2>&1 + echo "done" +} diff --git a/tasks/update_chrootscripts.task.sh b/tasks/update_chrootscripts.task.sh new file mode 100644 index 0000000..9302fae --- /dev/null +++ b/tasks/update_chrootscripts.task.sh @@ -0,0 +1,7 @@ +update_chrootscripts () { + rm -f $BROOT_BUILDROOT_PATH/root/bin/*.sh 2>&1 > /dev/null + cp ./chroot-scripts/* $BROOT_BUILDROOT_PATH/root/bin/ + chmod 700 $BROOT_BUILDROOT_PATH/root/bin/* + count=$(ls -1 $BROOT_BUILDROOT_PATH/root/bin/*.sh|wc -l) + echo " Reinstalled $count scripts" +} -- cgit v1.2.3-55-g7522