Setting up a proper environment for building a Ganeti can be quite difficult.

This patch adds a script for building a compressed chroot with all the
required libraries and tools.

Signed-off-by: Michele Tartara <[email protected]>
---
 .gitignore                      |   1 +
 Makefile.am                     |   2 +
 devel/build_chroot              | 139 ++++++++++++++++++++++++++++++++++++++++
 devel/data/temp.schroot.conf.in |   6 ++
 4 files changed, 148 insertions(+)
 create mode 100755 devel/build_chroot
 create mode 100644 devel/data/temp.schroot.conf.in

diff --git a/.gitignore b/.gitignore
index 8656a8a..50f4c66 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,7 @@
 /config.log
 /config.status
 /configure
+/devel/squeeze64.tar.gz
 /epydoc.conf
 /ganeti
 /stamp-srclinks
diff --git a/Makefile.am b/Makefile.am
index b43c187..c22a57a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -93,6 +93,7 @@ DIRS = \
        autotools \
        daemons \
        devel \
+       devel/data \
        doc \
        doc/css \
        doc/examples \
@@ -178,6 +179,7 @@ CLEANFILES = \
        $(SHELL_ENV_INIT) \
        daemons/daemon-util \
        daemons/ganeti-cleaner \
+       devel/squeeze64.tar.gz
        $(mandocrst) \
        doc/manpages-enabled.rst \
        $(BUILT_EXAMPLES) \
diff --git a/devel/build_chroot b/devel/build_chroot
new file mode 100755
index 0000000..065eacc
--- /dev/null
+++ b/devel/build_chroot
@@ -0,0 +1,139 @@
+#!/bin/bash
+#Configuration
+CHROOTNAME=squeeze64
+CONF_DIR=/etc/schroot/chroot.d
+DATA_DIR=data
+
+#Automatically generated variables
+CHNAME=building_$CHROOTNAME
+TEMP_CHROOT_CONF=$CONF_DIR/$CHNAME
+ROOT=`pwd`
+CHDIR=$ROOT/$CHNAME
+USER=`whoami`
+COMP_FILE=$ROOT/$CHROOTNAME.tar.gz
+
+#Runnability checks
+if [ $USER != 'root' ]
+then
+  echo "This script requires root permissions to run"
+  exit
+fi
+
+if [ -f $TEMP_CHROOT_CONF ]
+then
+  echo "The configuration file name for the temporary chroot"
+  echo "  $TEMP_CHROOT_CONF"
+  echo "already exists."
+  echo "Remove it or change the CHNAME value in the script."
+  exit
+fi
+
+set -e
+
+#Cleanup
+rm -rf $CHDIR
+mkdir $CHDIR
+
+#Install tools for building chroots
+apt-get install -y schroot debootstrap
+
+#Generate temporary chroot configuration
+cat $DATA_DIR/temp.schroot.conf.in | sed \
+  -e "s*\${CHDIR}*$CHDIR*" \
+  -e "s/\${CHNAME}/$CHNAME/" \
+  > $TEMP_CHROOT_CONF
+
+#Install the base system
+debootstrap --arch amd64 squeeze $CHDIR
+
+shopt -s expand_aliases
+alias in_chroot='schroot -c $CHNAME -d / '
+APT_INSTALL="apt-get install -y --no-install-recommends"
+
+#Install all the packages
+in_chroot -- \
+  apt-get update
+
+in_chroot -- \
+  $APT_INSTALL python-setuptools build-essential python-dev sudo automake git \
+               fakeroot vim locales
+
+echo "en_US.UTF-8 UTF-8" >> $CHDIR/etc/locale.gen
+
+in_chroot -- \
+  locale-gen
+
+in_chroot -- \
+  $APT_INSTALL lvm2 ssh bridge-utils iproute iputils-arping \
+               ndisc6 python python-pyopenssl openssl \
+               python-pyparsing python-simplejson \
+               python-pyinotify python-pycurl python-yaml socat fping
+
+in_chroot -- \
+  $APT_INSTALL python-paramiko qemu-utils
+
+in_chroot -- \
+  easy_install affinity bitarray ipaddr
+
+#Haskell packages
+in_chroot -- \
+  $APT_INSTALL ghc6 \
+               libghc6-parallel-dev libghc6-deepseq-dev \
+               libghc6-curl-dev
+
+in_chroot -- \
+  $APT_INSTALL cabal-install
+
+in_chroot -- \
+  cabal update
+
+in_chroot -- \
+  $APT_INSTALL libpcre3-dev
+
+in_chroot -- \
+  cabal install --global \
+    QuickCheck==2.5.1.1 \
+    network==2.3 hslogger Crypto text regex-pcre \
+    attoparsec vector \
+    json==0.4.4 \
+    MonadCatchIO-transformers==0.2.2.0 mtl==2.0.1.0 \
+    hashable==1.1.2.0 case-insensitive==0.3 parsec==3.0.1 \
+    network==2.3 snap-server==0.8.1 \
+    hinotify==0.3.2
+
+#Python development tools
+in_chroot -- \
+  $APT_INSTALL pandoc python-epydoc graphviz
+
+in_chroot -- \
+  easy_install sphinx==1.1.3 \
+               logilab-common \
+               logilab-astng==0.23.1 \
+               pylint==0.25.1 \
+               pep8==1.2 \
+               coverage
+
+#Haskell development tools
+in_chroot -- \
+  cabal install --global \
+    HUnit \
+    happy \
+    hlint==1.8.34 \
+    hscolour==1.20.3 \
+    temporary \
+    test-framework==0.6.1 \
+    test-framework-hunit==0.2.7 \
+    test-framework-quickcheck2==0.2.12.3
+
+in_chroot -- \
+  cabal install --global shelltestrunner
+
+rm -f $COMP_FILE
+echo "Creating compressed schroot image..."
+cd $CHDIR
+tar czf $COMP_FILE ./*
+cd $ROOT
+echo "Done"
+
+rm -rf $CHDIR
+rm -f $TEMP_CHROOT_CONF
diff --git a/devel/data/temp.schroot.conf.in b/devel/data/temp.schroot.conf.in
new file mode 100644
index 0000000..8270e72
--- /dev/null
+++ b/devel/data/temp.schroot.conf.in
@@ -0,0 +1,6 @@
+[${CHNAME}]
+description=Debian squeeze 64-bit
+directory=${CHDIR}
+groups=src
+users=root
+type=directory
-- 
1.8.1.3

Reply via email to