summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian2010-01-27 13:26:06 +0100
committerSebastian2010-01-27 13:26:06 +0100
commitec91e5aa5d231f7fabcff1403dbad852a3764ca2 (patch)
tree3d8e5853bae010fcb865493a31e41bedf23abef4
downloadbroot-ec91e5aa5d231f7fabcff1403dbad852a3764ca2.tar.gz
broot-ec91e5aa5d231f7fabcff1403dbad852a3764ca2.tar.xz
broot-ec91e5aa5d231f7fabcff1403dbad852a3764ca2.zip
broot initial commit
-rwxr-xr-xbroot.sh39
-rw-r--r--chroot-scripts/build-bb.sh20
-rw-r--r--inc/bootstrap.inc.sh36
-rw-r--r--inc/chroot-functions.inc.sh13
-rw-r--r--inc/color.inc.sh32
-rw-r--r--inc/env.inc.sh2
-rw-r--r--inc/helper.inc.sh10
-rw-r--r--inc/update.inc.sh10
8 files changed, 162 insertions, 0 deletions
diff --git a/broot.sh b/broot.sh
new file mode 100755
index 0000000..cee9387
--- /dev/null
+++ b/broot.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+. ./inc/env.inc.sh # read slx config to find paths
+. ./inc/chroot-functions.inc.sh # chroot wrapper
+. ./inc/bootstrap.inc.sh # bootsrap buildroot
+. ./inc/helper.inc.sh # misc functions (setup bindmounts, etc)
+. ./inc/color.inc.sh # functions for color ouput
+. ./inc/update.inc.sh # buildroot update functions
+
+
+case $1 in
+ "setup")
+ if [ ! -e $buildrootpath/bootstraped ]; then
+ bootstrap
+ else
+ echo " * Found existing buildroot - running update instead"
+ updatebuildroot
+ fi
+ ;;
+ "update")
+ if [ ! -e $buildrootpath/bootstraped ]; then
+ echo " * Can't find existing buildroot - running setup instead"
+ bootstrap
+ else
+ updatebuildroot
+ fi
+ ;;
+ "build-bb")
+ if [ ! -e $buildrootpath/bootstraped ]; then
+ echo " * Error: didn't find existing buildroot"
+ else
+ echo " * Building busybox"
+ updateScripts
+ chroot-exec /root/bin/build-bb.sh
+ fi
+ ;;
+ *)
+ echo "Usage: broot (setup|update|build-bb)"
+esac
diff --git a/chroot-scripts/build-bb.sh b/chroot-scripts/build-bb.sh
new file mode 100644
index 0000000..8d1f08a
--- /dev/null
+++ b/chroot-scripts/build-bb.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+if [ ! -d /usr/local/src/busybox ]; then
+ echo "new bb"
+ mkdir -p /usr/local/src
+ cd /usr/local/src
+ git clone git://git.openslx.org/openslx/tools/busybox.git
+else
+ echo "found bb"
+ cd /usr/local/src/busybox
+ [ -e .config ] && rm .config
+ git checkout .config
+ git pull
+fi
+cd /usr/local/src/busybox
+make clean && make && make install
+mkdir -p /root/packages
+cd /usr/local/src/busybox/_install
+sleep 2
+tar cfvj /root/packages/slx-busybox.tbz2 *
diff --git a/inc/bootstrap.inc.sh b/inc/bootstrap.inc.sh
new file mode 100644
index 0000000..0f0648e
--- /dev/null
+++ b/inc/bootstrap.inc.sh
@@ -0,0 +1,36 @@
+
+bootsrap () {
+ [ ! -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 "
+
+ debootstrap 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-apt-installinstall 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
+
+ mkdir -p $buildrootpath/root/bin
+ 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
new file mode 100644
index 0000000..2578e15
--- /dev/null
+++ b/inc/chroot-functions.inc.sh
@@ -0,0 +1,13 @@
+chroot-exec () {
+ if [ $(mount |grep -c $buildrootpath/dev) -eq 0 ]; then
+ setupBindmounts
+ fi
+ chroot $buildrootpath $@
+}
+
+chroot-aptinstall () {
+ if [ $(mount |grep -c $buildrootpath/dev) -eq 0 ]; then
+ setupBindmounts
+ fi
+ chroot $buildrootpath aptitude install -y $@
+}
diff --git a/inc/color.inc.sh b/inc/color.inc.sh
new file mode 100644
index 0000000..824bbd9
--- /dev/null
+++ b/inc/color.inc.sh
@@ -0,0 +1,32 @@
+ NONE="\033[0m" # unsets color to term's fg color
+
+ # regular colors
+ K="\033[0;30m" # black
+ R="\033[0;31m" # red
+ G="\033[0;32m" # green
+ Y="\033[0;33m" # yellow
+ B="\033[0;34m" # blue
+ M="\033[0;35m" # magenta
+ C="\033[0;36m" # cyan
+ W="\033[0;37m" # white
+
+ # emphasized (bolded) colors
+ BK="\033[1;30m"
+ BR="\033[1;31m"
+ BG="\033[1;32m"
+ BY="\033[1;33m"
+ BB="\033[1;34m"
+ BM="\033[1;35m"
+ BC="\033[1;36m"
+ BW="\033[1;37m"
+
+ # background colors
+ BGK="\033[40m"
+ BGR="\033[41m"
+ BGG="\033[42m"
+ BGY="\033[43m"
+ BGB="\033[44m"
+ BGM="\033[45m"
+ BGC="\033[46m"
+ BGW="\033[47m"
+
diff --git a/inc/env.inc.sh b/inc/env.inc.sh
new file mode 100644
index 0000000..9f9881e
--- /dev/null
+++ b/inc/env.inc.sh
@@ -0,0 +1,2 @@
+buildrootpath=$(slxsettings |grep base-path | sed -e "s,^.*='\(.*\)'$,\1,")
+buildrootpath="$buildrootpath/share/buildroot"
diff --git a/inc/helper.inc.sh b/inc/helper.inc.sh
new file mode 100644
index 0000000..c0780b0
--- /dev/null
+++ b/inc/helper.inc.sh
@@ -0,0 +1,10 @@
+
+setupBindmounts() {
+ mount -o bind /proc $buildrootpath/proc
+ mount -o bind /dev $buildrootpath/dev
+}
+
+destroyBindmounts() {
+ umount $buildrootpath/proc
+ umount $buildrootpath/dev
+}
diff --git a/inc/update.inc.sh b/inc/update.inc.sh
new file mode 100644
index 0000000..af3ff9d
--- /dev/null
+++ b/inc/update.inc.sh
@@ -0,0 +1,10 @@
+updatebuildroot () {
+ chroot-exec aptitude update
+ chroot-exec aptitude safe-upgrade
+ updateScripts
+}
+
+updateScripts () {
+ cp ./chroot-scripts/* $buildrootpath/root/bin/
+ chmod 700 $buildrootpath/root/bin/*
+}