4 : ${DIST_RELEASE:=squeeze}
5 : ${CONF_DIR:=/etc/schroot/chroot.d}
6 : ${CHROOT_DIR:=/srv/chroot}
7 : ${ALTERNATIVE_EDITOR:=/usr/bin/vim.basic}
8 : ${CHROOT_FINAL_HOOK:=/bin/true}
9 # Additional Variables taken from the environmen
11 # CHROOT_EXTRA_DEBIAN_PACKAGES
13 #Automatically generated variables
14 CHROOTNAME=$DIST_RELEASE-$ARCH
15 CHNAME=building_$CHROOTNAME
16 TEMP_CHROOT_CONF=$CONF_DIR/$CHNAME.conf
17 FINAL_CHROOT_CONF=$CHROOTNAME.conf
21 COMP_FILENAME=$CHROOTNAME.tar.gz
22 COMP_FILEPATH=$ROOT/$COMP_FILENAME
23 TEMP_DATA_DIR=`mktemp -d`
24 ACTUAL_DATA_DIR=$DATA_DIR
25 ACTUAL_DATA_DIR=${ACTUAL_DATA_DIR:-$TEMP_DATA_DIR}
28 if [ $USER != 'root' ]
30 echo "This script requires root permissions to run"
34 if [ -f $TEMP_CHROOT_CONF ]
36 echo "The configuration file name for the temporary chroot"
37 echo " $TEMP_CHROOT_CONF"
38 echo "already exists."
39 echo "Remove it or change the CHNAME value in the script."
43 #Create configuration dir and files if they do not exist
44 if [ ! -d $ACTUAL_DATA_DIR ]
46 mkdir $ACTUAL_DATA_DIR
47 echo "The data directory"
48 echo " $ACTUAL_DATA_DIR"
49 echo "has been created."
52 if [ ! -f $ACTUAL_DATA_DIR/final.schroot.conf.in ]
54 cat <<END >$ACTUAL_DATA_DIR/final.schroot.conf.in
56 description=Debian ${DIST_RELEASE} ${ARCH}
58 source-root-groups=root
60 file=${CHROOT_DIR}/${COMP_FILENAME}
63 echo " $ACTUAL_DATA_DIR/final.schroot.conf.in"
64 echo "has been created with default configurations."
67 if [ ! -f $ACTUAL_DATA_DIR/temp.schroot.conf.in ]
69 cat <<END >$ACTUAL_DATA_DIR/temp.schroot.conf.in
71 description=Debian ${DIST_RELEASE} ${ARCH}
78 echo " $ACTUAL_DATA_DIR/temp.schroot.conf.in"
79 echo "has been created with default configurations."
89 #Install tools for building chroots
90 apt-get install -y schroot debootstrap
92 shopt -s expand_aliases
93 alias in_chroot='schroot -c $CHNAME -d / '
94 function subst_variables {
96 -e "s/\${ARCH}/$ARCH/" \
97 -e "s*\${CHDIR}*$CHDIR*" \
98 -e "s/\${CHNAME}/$CHNAME/" \
99 -e "s/\${CHROOTNAME}/$CHROOTNAME/" \
100 -e "s*\${CHROOT_DIR}*$CHROOT_DIR*" \
101 -e "s/\${COMP_FILENAME}/$COMP_FILENAME/" \
102 -e "s/\${DIST_RELEASE}/$DIST_RELEASE/" $@
105 #Generate chroot configurations
106 cat $ACTUAL_DATA_DIR/temp.schroot.conf.in | subst_variables > $TEMP_CHROOT_CONF
107 cat $ACTUAL_DATA_DIR/final.schroot.conf.in | subst_variables > $FINAL_CHROOT_CONF
109 #Install the base system
110 debootstrap --arch $ARCH $DIST_RELEASE $CHDIR
112 APT_INSTALL="apt-get install -y --no-install-recommends"
114 echo "deb http://backports.debian.org/debian-backports" \
115 "$DIST_RELEASE-backports main contrib non-free" \
116 > $CHDIR/etc/apt/sources.list.d/backports.list
118 #Install all the packages
122 #Install selected packages from backports
124 $APT_INSTALL -t squeeze-backports \
130 $APT_INSTALL python-setuptools build-essential python-dev sudo automake \
131 fakeroot rsync locales less
133 echo "en_US.UTF-8 UTF-8" >> $CHDIR/etc/locale.gen
139 $APT_INSTALL lvm2 ssh bridge-utils iproute iputils-arping \
140 ndisc6 python python-pyopenssl openssl \
141 python-pyparsing python-simplejson \
142 python-pyinotify python-pycurl python-yaml python-mock \
146 $APT_INSTALL python-paramiko qemu-utils
149 easy_install affinity bitarray ipaddr
154 libghc6-parallel-dev libghc6-deepseq-dev \
158 $APT_INSTALL cabal-install
164 $APT_INSTALL libpcre3-dev
167 cabal install --global \
172 attoparsec==0.10.1.1\
173 quickcheck==2.5.1.1 \
175 monadcatchio-transformers==0.2.2.0 \
178 case-insensitive==0.3 \
187 #Python development tools
189 $APT_INSTALL pandoc python-epydoc graphviz
192 easy_install sphinx==1.1.3 \
194 logilab-astng==0.23.1 \
199 #Haskell development tools
201 cabal install --global \
207 test-framework==0.6.1 \
208 test-framework-hunit==0.2.7 \
209 test-framework-quickcheck2==0.2.12.3
212 cabal install --global shelltestrunner
214 #Tools for creating debian packages
216 $APT_INSTALL python-docutils debhelper quilt
218 # extra debian packages
220 for package in $CHROOT_EXTRA_DEBIAN_PACKAGES
222 $APT_INSTALL $package
227 update-alternatives --set editor $ALTERNATIVE_EDITOR
231 in_chroot -- $CHROOT_FINAL_HOOK
234 echo "Creating compressed schroot image..."
236 tar czf $COMP_FILEPATH ./*
240 rm -f $TEMP_CHROOT_CONF
241 rm -rf $TEMP_DATA_DIR
243 echo "Chroot created. In order to run it:"
244 echo " * Copy the file $FINAL_CHROOT_CONF to $CONF_DIR/$FINAL_CHROOT_CONF"
245 echo " * Copy the file $COMP_FILEPATH to $CHROOT_DIR/$COMP_FILENAME"
247 echo "Then run \"schroot -c $CHROOTNAME\""