4 : ${DIST_RELEASE:=squeeze}
5 : ${CONF_DIR:=/etc/schroot/chroot.d}
6 : ${CHROOT_DIR:=/srv/chroot}
7 : ${ALTERNATIVE_EDITOR:=/usr/bin/vim.basic}
8 # The value of DATA_DIR is read as well from the environment.
10 #Automatically generated variables
11 CHROOTNAME=$DIST_RELEASE-$ARCH
12 CHNAME=building_$CHROOTNAME
13 TEMP_CHROOT_CONF=$CONF_DIR/$CHNAME.conf
14 FINAL_CHROOT_CONF=$CHROOTNAME.conf
18 COMP_FILENAME=$CHROOTNAME.tar.gz
19 COMP_FILEPATH=$ROOT/$COMP_FILENAME
20 TEMP_DATA_DIR=`mktemp -d`
21 ACTUAL_DATA_DIR=$DATA_DIR
22 ACTUAL_DATA_DIR=${ACTUAL_DATA_DIR:-$TEMP_DATA_DIR}
25 if [ $USER != 'root' ]
27 echo "This script requires root permissions to run"
31 if [ -f $TEMP_CHROOT_CONF ]
33 echo "The configuration file name for the temporary chroot"
34 echo " $TEMP_CHROOT_CONF"
35 echo "already exists."
36 echo "Remove it or change the CHNAME value in the script."
40 #Create configuration dir and files if they do not exist
41 if [ ! -d $ACTUAL_DATA_DIR ]
43 mkdir $ACTUAL_DATA_DIR
44 echo "The data directory"
45 echo " $ACTUAL_DATA_DIR"
46 echo "has been created."
49 if [ ! -f $ACTUAL_DATA_DIR/final.schroot.conf.in ]
51 cat <<END >$ACTUAL_DATA_DIR/final.schroot.conf.in
53 description=Debian ${DIST_RELEASE} ${ARCH}
55 source-root-groups=root
57 file=${CHROOT_DIR}/${COMP_FILENAME}
60 echo " $ACTUAL_DATA_DIR/final.schroot.conf.in"
61 echo "has been created with default configurations."
64 if [ ! -f $ACTUAL_DATA_DIR/temp.schroot.conf.in ]
66 cat <<END >$ACTUAL_DATA_DIR/temp.schroot.conf.in
68 description=Debian ${DIST_RELEASE} ${ARCH}
75 echo " $ACTUAL_DATA_DIR/temp.schroot.conf.in"
76 echo "has been created with default configurations."
86 #Install tools for building chroots
87 apt-get install -y schroot debootstrap
89 shopt -s expand_aliases
90 alias in_chroot='schroot -c $CHNAME -d / '
91 alias subst_variables='sed \
92 -e "s/\${ARCH}/$ARCH/" \
93 -e "s*\${CHDIR}*$CHDIR*" \
94 -e "s/\${CHNAME}/$CHNAME/" \
95 -e "s/\${CHROOTNAME}/$CHROOTNAME/" \
96 -e "s*\${CHROOT_DIR}*$CHROOT_DIR*" \
97 -e "s/\${COMP_FILENAME}/$COMP_FILENAME/" \
98 -e "s/\${DIST_RELEASE}/$DIST_RELEASE/"'
100 #Generate chroot configurations
101 cat $ACTUAL_DATA_DIR/temp.schroot.conf.in | subst_variables > $TEMP_CHROOT_CONF
102 cat $ACTUAL_DATA_DIR/final.schroot.conf.in | subst_variables > $FINAL_CHROOT_CONF
104 #Install the base system
105 debootstrap --arch $ARCH $DIST_RELEASE $CHDIR
107 APT_INSTALL="apt-get install -y --no-install-recommends"
109 echo "deb http://backports.debian.org/debian-backports" \
110 "$DIST_RELEASE-backports main contrib non-free" \
111 > $CHDIR/etc/apt/sources.list.d/backports.list
113 #Install all the packages
117 #Install selected packages from backports
119 apt-get -y --no-install-recommends -t squeeze-backports install \
125 $APT_INSTALL python-setuptools build-essential python-dev sudo automake \
126 fakeroot rsync locales less
128 echo "en_US.UTF-8 UTF-8" >> $CHDIR/etc/locale.gen
134 $APT_INSTALL lvm2 ssh bridge-utils iproute iputils-arping \
135 ndisc6 python python-pyopenssl openssl \
136 python-pyparsing python-simplejson \
137 python-pyinotify python-pycurl python-yaml socat fping
140 $APT_INSTALL python-paramiko qemu-utils
143 easy_install affinity bitarray ipaddr
148 libghc6-parallel-dev libghc6-deepseq-dev \
152 $APT_INSTALL cabal-install
158 $APT_INSTALL libpcre3-dev
161 cabal install --global \
166 attoparsec==0.10.1.1\
167 quickcheck==2.5.1.1 \
169 monadcatchio-transformers==0.2.2.0 \
172 case-insensitive==0.3 \
180 #Python development tools
182 $APT_INSTALL pandoc python-epydoc graphviz
185 easy_install sphinx==1.1.3 \
187 logilab-astng==0.23.1 \
192 #Haskell development tools
194 cabal install --global \
200 test-framework==0.6.1 \
201 test-framework-hunit==0.2.7 \
202 test-framework-quickcheck2==0.2.12.3
205 cabal install --global shelltestrunner
207 #Tools for creating debian packages
209 $APT_INSTALL python-docutils debhelper quilt
213 update-alternatives --set editor $ALTERNATIVE_EDITOR
216 echo "Creating compressed schroot image..."
218 tar czf $COMP_FILEPATH ./*
222 rm -f $TEMP_CHROOT_CONF
223 rm -rf $TEMP_DATA_DIR
225 echo "Chroot created. In order to run it:"
226 echo " * Copy the file $FINAL_CHROOT_CONF to $CONF_DIR/$FINAL_CHROOT_CONF"
227 echo " * Copy the file $COMP_FILEPATH to $CHROOT_DIR/$COMP_FILENAME"
229 echo "Then run \"schroot -c $CHROOTNAME\""