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 \
124 $APT_INSTALL python-setuptools build-essential python-dev sudo automake \
125 fakeroot rsync locales less
127 echo "en_US.UTF-8 UTF-8" >> $CHDIR/etc/locale.gen
133 $APT_INSTALL lvm2 ssh bridge-utils iproute iputils-arping \
134 ndisc6 python python-pyopenssl openssl \
135 python-pyparsing python-simplejson \
136 python-pyinotify python-pycurl python-yaml socat fping
139 $APT_INSTALL python-paramiko qemu-utils
142 easy_install affinity bitarray ipaddr
147 libghc6-parallel-dev libghc6-deepseq-dev \
151 $APT_INSTALL cabal-install
157 $APT_INSTALL libpcre3-dev
160 cabal install --global \
165 attoparsec==0.10.1.1\
166 quickcheck==2.5.1.1 \
168 monadcatchio-transformers==0.2.2.0 \
171 case-insensitive==0.3 \
179 #Python development tools
181 $APT_INSTALL pandoc python-epydoc graphviz
184 easy_install sphinx==1.1.3 \
186 logilab-astng==0.23.1 \
191 #Haskell development tools
193 cabal install --global \
199 test-framework==0.6.1 \
200 test-framework-hunit==0.2.7 \
201 test-framework-quickcheck2==0.2.12.3
204 cabal install --global shelltestrunner
206 #Tools for creating debian packages
208 apt-get install python-docutils debhelper quilt
212 update-alternatives --set editor $ALTERNATIVE_EDITOR
215 echo "Creating compressed schroot image..."
217 tar czf $COMP_FILEPATH ./*
221 rm -f $TEMP_CHROOT_CONF
222 rm -rf $TEMP_DATA_DIR
224 echo "Chroot created. In order to run it:"
225 echo " * Copy the file $FINAL_CHROOT_CONF to $CONF_DIR/$FINAL_CHROOT_CONF"
226 echo " * Copy the file $COMP_FILEPATH to $CHROOT_DIR/$COMP_FILENAME"
228 echo "Then run \"schroot -c $CHROOTNAME\""