Merge branch 'stable-2.15' into stable-2.16
[ganeti-github.git] / devel / build_chroot
1 #!/bin/bash
2
3 #Requirements for this script to work:
4 #* Make sure that the user who uses the chroot is in group 'src', or change
5 #  the ${GROUP} variable to a group that contains the user.
6 #* Add any path of the host system that you want to access inside the chroot
7 #  to the /etc/schroot/default/fstab file. This is important in particular if
8 #  your homedir is not in /home.
9 #* Add this to your /etc/fstab:
10 #  tmpfs /var/lib/schroot/mount tmpfs defaults,size=3G 0 0
11 #  tmpfs /var/lib/schroot/unpack tmpfs defaults,size=3G 0 0
12
13 #Configuration
14 : ${ARCH:=amd64}
15 : ${DIST_RELEASE:=wheezy}
16 : ${VARIANT:=}
17 : ${CONF_DIR:=/etc/schroot/chroot.d}
18 : ${CHROOT_DIR:=/srv/chroot}
19 : ${ALTERNATIVE_EDITOR:=/usr/bin/vim.basic}
20 : ${CHROOT_FINAL_HOOK:=/bin/true}
21 : ${GROUP:=src}
22 # Additional Variables taken from the environmen
23 # DATA_DIR
24 # CHROOT_EXTRA_DEBIAN_PACKAGES
25
26 # make the appended variant name more readable
27 [ -n "$VARIANT" ] && VARIANT="-${VARIANT#-}"
28
29 #Automatically generated variables
30 CHROOTNAME=$DIST_RELEASE-$ARCH$VARIANT
31 CHNAME=building_$CHROOTNAME
32 TEMP_CHROOT_CONF=$CONF_DIR/$CHNAME.conf
33 FINAL_CHROOT_CONF=$CHROOTNAME.conf
34 ROOT=`pwd`
35 CHDIR=$ROOT/$CHNAME
36 USER=`whoami`
37 COMP_FILENAME=$CHROOTNAME.tar.gz
38 COMP_FILEPATH=$ROOT/$COMP_FILENAME
39 TEMP_DATA_DIR=`mktemp -d`
40 ACTUAL_DATA_DIR=$DATA_DIR
41 ACTUAL_DATA_DIR=${ACTUAL_DATA_DIR:-$TEMP_DATA_DIR}
42 SHA1_LIST='
43 cabal-install-1.18.0.2.tar.gz 2d1f7a48d17b1e02a1e67584a889b2ff4176a773
44 cabal-install-1.22.4.0.tar.gz b98eea96d321cdeed83a201c192dac116e786ec2
45 ghc-7.6.3-i386-unknown-linux.tar.bz2 f042b4171a2d4745137f2e425e6949c185f8ea14
46 ghc-7.6.3-x86_64-unknown-linux.tar.bz2 46ec3f3352ff57fba0dcbc8d9c20f7bcb6924b77
47 ghc-7.8.4-i386-unknown-linux-deb7.tar.bz2 4f523f854c37a43b738359506a89a37a9fa9fc5f
48 ghc-7.8.4-x86_64-unknown-linux-deb7.tar.bz2 3f68321b064e5c1ffcb05838b85bcc00aa2315b4
49 '
50
51 # export all variables needed in the schroot
52 export ARCH SHA1_LIST
53
54 # Use gzip --rsyncable if available, to speed up transfers of generated files
55 # The environment variable GZIP is read automatically by 'gzip',
56 # see ENVIRONMENT in gzip(1).
57 gzip --rsyncable </dev/null >/dev/null 2>&1 && export GZIP="--rsyncable"
58
59 #Runnability checks
60 if [ $USER != 'root' ]
61 then
62   echo "This script requires root permissions to run"
63   exit
64 fi
65
66 if [ -f $TEMP_CHROOT_CONF ]
67 then
68   echo "The configuration file name for the temporary chroot"
69   echo "  $TEMP_CHROOT_CONF"
70   echo "already exists."
71   echo "Remove it or change the CHNAME value in the script."
72   exit
73 fi
74
75 #Create configuration dir and files if they do not exist
76 if [ ! -d $ACTUAL_DATA_DIR ]
77 then
78   mkdir $ACTUAL_DATA_DIR
79   echo "The data directory"
80   echo "  $ACTUAL_DATA_DIR"
81   echo "has been created."
82 fi
83
84 if [ ! -f $ACTUAL_DATA_DIR/final.schroot.conf.in ]
85 then
86   cat <<END >$ACTUAL_DATA_DIR/final.schroot.conf.in
87 [${CHROOTNAME}]
88 description=Debian ${DIST_RELEASE} ${ARCH}
89 groups=${GROUP}
90 source-root-groups=root
91 type=file
92 file=${CHROOT_DIR}/${COMP_FILENAME}
93 END
94   echo "The file"
95   echo " $ACTUAL_DATA_DIR/final.schroot.conf.in"
96   echo "has been created with default configurations."
97 fi
98
99 if [ ! -f $ACTUAL_DATA_DIR/temp.schroot.conf.in ]
100 then
101   cat <<END >$ACTUAL_DATA_DIR/temp.schroot.conf.in
102 [${CHNAME}]
103 description=Debian ${DIST_RELEASE}${VARIANT} ${ARCH}
104 directory=${CHDIR}
105 groups=${GROUP}
106 users=root
107 type=directory
108 END
109   echo "The file"
110   echo " $ACTUAL_DATA_DIR/temp.schroot.conf.in"
111   echo "has been created with default configurations."
112 fi
113
114 #Stop on errors
115 set -e
116
117 #Cleanup
118 rm -rf $CHDIR
119 mkdir $CHDIR
120
121 #Install tools for building chroots
122 apt-get install -y schroot debootstrap
123
124 shopt -s expand_aliases
125 alias in_chroot='schroot -c $CHNAME -d / '
126 function subst_variables {
127   sed \
128     -e "s/\${ARCH}/$ARCH/" \
129     -e "s*\${CHDIR}*$CHDIR*" \
130     -e "s/\${CHNAME}/$CHNAME/" \
131     -e "s/\${CHROOTNAME}/$CHROOTNAME/" \
132     -e "s*\${CHROOT_DIR}*$CHROOT_DIR*" \
133     -e "s/\${COMP_FILENAME}/$COMP_FILENAME/" \
134     -e "s/\${DIST_RELEASE}/$DIST_RELEASE/" $@
135 }
136
137 #Generate chroot configurations
138 cat $ACTUAL_DATA_DIR/temp.schroot.conf.in | subst_variables > $TEMP_CHROOT_CONF
139 cat $ACTUAL_DATA_DIR/final.schroot.conf.in | subst_variables > $FINAL_CHROOT_CONF
140
141 #Install the base system
142 debootstrap --arch $ARCH $DIST_RELEASE $CHDIR
143
144 APT_INSTALL="apt-get install -y --no-install-recommends"
145
146 if [ $DIST_RELEASE = squeeze ]
147 then
148   echo "deb http://backports.debian.org/debian-backports" \
149        "$DIST_RELEASE-backports main contrib non-free" \
150        > $CHDIR/etc/apt/sources.list.d/backports.list
151 fi
152
153 #Install all the packages
154 in_chroot -- \
155   apt-get update
156
157
158 # Functions for downloading and checking Haskell core components.
159 # The functions run commands within the schroot.
160
161 # arguments : file_name expected_sha1
162 function verify_sha1 {
163   local SUM="$( in_chroot -- sha1sum "$1" | awk '{print $1;exit}' )"
164   if [ "$SUM" != "$2" ] ; then
165     echo "ERROR: The SHA1 sum $SUM of $1 doesn't match $2." >&2
166     return 1
167   else
168     echo "SHA1 of $1 verified correct."
169   fi
170 }
171
172 # arguments: URL
173 function lookup_sha1 {
174   grep -o "${1##*/}"'\s\+[0-9a-fA-F]*' <<<"$SHA1_LIST" | awk '{print $2;exit}'
175 }
176
177 # arguments : file_name URL
178 function download {
179   local FNAME="$1"
180   local URL="$2"
181   in_chroot -- wget --no-check-certificate --output-document="$FNAME" "$URL"
182   verify_sha1 "$FNAME" "$( lookup_sha1 "$URL" )"
183 }
184
185 function install_ghc {
186   local GHC_ARCH=$ARCH
187   local TDIR=$( schroot -c $CHNAME -d / -- mktemp -d )
188   [ -n "$TDIR" ]
189   if [ "$ARCH" == "amd64" ] ; then
190     download "$TDIR"/ghc.tar.bz2 \
191       http://www.haskell.org/ghc/dist/${GHC_VERSION}/ghc-${GHC_VERSION}-x86_64-unknown-linux${GHC_VARIANT}.tar.bz2
192   elif [ "$ARCH" == "i386" ] ; then
193     download "$TDIR"/ghc.tar.bz2 \
194       http://www.haskell.org/ghc/dist/${GHC_VERSION}/ghc-${GHC_VERSION}-i386-unknown-linux${GHC_VARIANT}.tar.bz2
195   else
196     echo "Don't know what GHC to download for architecture $ARCH" >&2
197     return 1
198   fi
199   schroot -c $CHNAME -d "$TDIR" -- \
200     tar xjf ghc.tar.bz2
201   schroot -c $CHNAME -d "$TDIR/ghc-${GHC_VERSION}" -- \
202     ./configure --prefix=/usr/local
203   schroot -c $CHNAME -d "$TDIR/ghc-${GHC_VERSION}" -- \
204      make install
205   schroot -c $CHNAME -d "/" -- \
206     rm -rf "$TDIR"
207 }
208
209 function install_cabal {
210   local TDIR=$( schroot -c $CHNAME -d / -- mktemp -d )
211   [ -n "$TDIR" ]
212   download "$TDIR"/cabal-install.tar.gz \
213     http://www.haskell.org/cabal/release/cabal-install-${CABAL_INSTALL_VERSION}/cabal-install-${CABAL_INSTALL_VERSION}.tar.gz
214   schroot -c $CHNAME -d "$TDIR" -- \
215     tar xzf cabal-install.tar.gz
216   schroot -c $CHNAME -d "$TDIR/cabal-install-${CABAL_INSTALL_VERSION}" -- \
217     bash -c 'EXTRA_CONFIGURE_OPTS="--enable-library-profiling" ./bootstrap.sh --global'
218   schroot -c $CHNAME -d "/" -- \
219     rm -rf "$TDIR"
220 }
221
222
223 case ${DIST_RELEASE}${VARIANT} in
224
225   squeeze)
226
227     GHC_VERSION="7.6.3"
228     GHC_VARIANT=""
229     CABAL_INSTALL_VERSION="1.18.0.2"
230     CABAL_LIB_VERSION=">=1.18.0 && <1.19"
231     export GHC_VERSION GHC_VARIANT CABAL_INSTALL_VERSION
232
233     # do not install libghc6-network-dev, since it's too old, and just
234     # confuses the dependencies
235     in_chroot -- \
236       $APT_INSTALL \
237         autoconf automake \
238         zlib1g-dev \
239         libgmp3-dev \
240         libcurl4-gnutls-dev \
241         libpcre3-dev \
242         happy \
243         hscolour pandoc \
244         graphviz qemu-utils \
245         python-docutils \
246         python-simplejson \
247         python-pyparsing \
248         python-pyinotify \
249         python-pycurl \
250         python-ipaddr \
251         python-yaml \
252         python-paramiko
253
254     in_chroot -- \
255       $APT_INSTALL python-setuptools python-dev build-essential
256
257     in_chroot -- \
258       easy_install \
259         unittest2==0.5.1 \
260         logilab-astng==0.24.1 \
261         logilab-common==0.58.3 \
262         mock==1.0.1 \
263         pylint==0.26.0
264
265     in_chroot -- \
266       easy_install \
267         sphinx==1.1.3 \
268         pep8==1.3.3 \
269         coverage==3.4 \
270         bitarray==0.8.0
271
272     install_ghc
273
274     install_cabal
275
276     in_chroot -- \
277       cabal update
278
279     # sinec we're using Cabal >=1.16, we can use the parallel install option
280     in_chroot -- \
281       cabal install --global -j --enable-library-profiling \
282         attoparsec-0.11.1.0 \
283         base64-bytestring-1.0.0.1 \
284         blaze-builder-0.3.3.2 \
285         case-insensitive-1.1.0.3 \
286         Crypto-4.2.5.1 \
287         curl-1.3.8 \
288         happy \
289         hashable-1.2.1.0 \
290         hinotify-0.3.6 \
291         hscolour-1.20.3 \
292         hslogger-1.2.3 \
293         json-0.7 \
294         lifted-base-0.2.2.0 \
295         lens-4.0.4 \
296         MonadCatchIO-transformers-0.3.0.0 \
297         network-2.4.1.2 \
298         parallel-3.2.0.4 \
299         parsec-3.1.3 \
300         regex-pcre-0.94.4 \
301         temporary-1.2.0.1 \
302         vector-0.10.9.1 \
303         zlib-0.5.4.1 \
304         \
305         'hlint>=1.9.12' \
306         HUnit-1.2.5.2 \
307         QuickCheck-2.6 \
308         test-framework-0.8.0.3 \
309         test-framework-hunit-0.3.0.1 \
310         test-framework-quickcheck2-0.3.0.2 \
311         \
312         snap-server-0.9.4.0 \
313         PSQueue-1.1 \
314         \
315         "Cabal $CABAL_LIB_VERSION" \
316         cabal-file-th-0.2.3 \
317         shelltestrunner
318
319     #Install selected packages from backports
320     in_chroot -- \
321       $APT_INSTALL -t squeeze-backports \
322         git \
323         git-email \
324         vim \
325         exuberant-ctags
326
327 ;;
328
329   wheezy)
330
331     in_chroot -- \
332       $APT_INSTALL \
333       autoconf automake ghc ghc-haddock libghc-network-dev \
334       libghc-test-framework{,-hunit,-quickcheck2}-dev \
335       libghc-json-dev libghc-curl-dev libghc-hinotify-dev \
336       libghc-parallel-dev libghc-utf8-string-dev \
337       libghc-hslogger-dev libghc-crypto-dev \
338       libghc-regex-pcre-dev libghc-attoparsec-dev \
339       libghc-vector-dev libghc-temporary-dev \
340       libghc-snap-server-dev libpcre3 libpcre3-dev happy hscolour pandoc \
341       libghc-zlib-dev libghc-psqueue-dev \
342       cabal-install \
343       python-setuptools python-sphinx python-epydoc graphviz python-pyparsing \
344       python-simplejson python-pycurl python-paramiko \
345       python-bitarray python-ipaddr python-yaml qemu-utils python-coverage pep8 \
346       shelltestrunner python-dev openssh-client vim git git-email exuberant-ctags
347
348     # We need version 0.9.4 of pyinotify because the packaged version, 0.9.3, is
349     # incompatibile with the packaged version of python-epydoc 3.0.1.
350     # Reason: a logger class in pyinotify calculates its superclasses at
351     # runtime, which clashes with python-epydoc's static analysis phase.
352     #
353     # Problem introduced in:
354     #   https://github.com/seb-m/pyinotify/commit/2c7e8f8959d2f8528e0d90847df360
355     # and "fixed" in:
356     #   https://github.com/seb-m/pyinotify/commit/98c5f41a6e2e90827a63ff1b878596
357
358     in_chroot -- \
359       easy_install \
360         logilab-astng==0.24.1 \
361         logilab-common==0.58.3 \
362         mock==1.0.1 \
363         pylint==0.26.0 \
364         pep8==1.3.3
365
366     in_chroot -- \
367       easy_install pyinotify==0.9.4
368
369      in_chroot -- \
370        cabal update
371
372      in_chroot -- \
373        cabal install --global \
374         'base64-bytestring>=1' \
375         lens-3.10.2 \
376         'lifted-base>=0.1.2' \
377         'hlint>=1.9.12'
378 ;;
379
380   jessie)
381
382     in_chroot -- \
383       $APT_INSTALL \
384       autoconf automake ghc ghc-haddock libghc-network-dev \
385       libghc-test-framework{,-hunit,-quickcheck2}-dev \
386       libghc-json-dev libghc-curl-dev libghc-hinotify-dev \
387       libghc-parallel-dev libghc-utf8-string-dev \
388       libghc-hslogger-dev libghc-crypto-dev \
389       libghc-regex-pcre-dev libghc-attoparsec-dev \
390       libghc-vector-dev libghc-temporary-dev \
391       libghc-snap-server-dev libpcre3 libpcre3-dev happy hscolour pandoc \
392       libghc-zlib-dev libghc-psqueue-dev \
393       libghc-base64-bytestring-dev libghc-lens-dev libghc-lifted-base-dev \
394       libghc-cabal-dev \
395       cabal-install \
396       python-setuptools python-sphinx python-epydoc graphviz python-pyparsing \
397       python-simplejson python-pycurl python-pyinotify python-paramiko \
398       python-bitarray python-ipaddr python-yaml qemu-utils python-coverage pep8 \
399       shelltestrunner python-dev pylint openssh-client \
400       vim git git-email exuberant-ctags
401
402     in_chroot -- \
403       cabal update
404
405     in_chroot -- \
406       cabal install --global \
407        'hlint>=1.9.12'
408 ;;
409
410   jessie-ghc78)
411
412     GHC_VERSION="7.8.4"
413     GHC_VARIANT="-deb7"
414     CABAL_INSTALL_VERSION="1.22.4.0"
415     # the version of the Cabal library below must match the version used by
416     # CABAL_INSTALL_VERSION, see the dependencies of cabal-install
417     CABAL_LIB_VERSION=">=1.22.2 && <1.23"
418     export GHC_VERSION GHC_VARIANT CABAL_INSTALL_VERSION
419
420     in_chroot -- \
421       $APT_INSTALL \
422         autoconf automake \
423         zlib1g-dev \
424         libgmp3-dev \
425         libcurl4-openssl-dev \
426         libpcre3-dev \
427         happy \
428         hlint hscolour pandoc \
429         graphviz qemu-utils \
430         python-docutils \
431         python-simplejson \
432         python-pyparsing \
433         python-pyinotify \
434         python-pycurl \
435         python-ipaddr \
436         python-yaml \
437         python-paramiko \
438         git \
439         git-email \
440         vim
441
442     in_chroot -- \
443       $APT_INSTALL python-setuptools python-dev build-essential
444
445     in_chroot -- \
446       easy_install \
447         logilab-astng==0.24.1 \
448         logilab-common==0.58.3 \
449         mock==1.0.1 \
450         pylint==0.26.0
451
452     in_chroot -- \
453       easy_install \
454         sphinx==1.1.3 \
455         pep8==1.3.3 \
456         coverage==3.4 \
457         bitarray==0.8.0
458
459     install_ghc
460
461     install_cabal
462
463     in_chroot -- \
464       cabal update
465
466     # since we're using Cabal >=1.16, we can use the parallel install option
467     in_chroot -- \
468       cabal install --global -j --enable-library-profiling \
469         attoparsec==0.12.1.6 \
470         base64-bytestring==1.0.0.1 \
471         blaze-builder==0.4.0.1 \
472         case-insensitive==1.2.0.4 \
473         Crypto==4.2.5.1 \
474         curl==1.3.8 \
475         happy==1.19.5 \
476         hashable==1.2.3.2 \
477         hinotify==0.3.7 \
478         hscolour==1.23 \
479         hslogger==1.2.8 \
480         json==0.9.1 \
481         lifted-base==0.2.3.6 \
482         lens==4.9.1 \
483         MonadCatchIO-transformers==0.3.1.3 \
484         network==2.6.0.2 \
485         parallel==3.2.0.6 \
486         parsec==3.1.7 \
487         regex-pcre==0.94.4 \
488         temporary==1.2.0.3 \
489         vector==0.10.12.3 \
490         zlib==0.5.4.2 \
491         \
492         hlint==1.9.20 \
493         HUnit==1.2.5.2 \
494         QuickCheck==2.8.1 \
495         test-framework==0.8.1.1 \
496         test-framework-hunit==0.3.0.1 \
497         test-framework-quickcheck2==0.3.0.3 \
498         \
499         snap-server==0.9.5.1 \
500         \
501         "Cabal $CABAL_LIB_VERSION" \
502         cabal-file-th==0.2.3 \
503         shelltestrunner==1.3.5
504 ;;
505
506   precise)
507     # ghc, git-email and other dependencies are hosted in the universe
508     # repository, which is not enabled by default.
509     echo "Adding universe repository..."
510     cat > $CHDIR/etc/apt/sources.list.d/universe.list <<EOF
511 deb http://archive.ubuntu.com/ubuntu precise universe
512 EOF
513     in_chroot -- \
514       apt-get update
515
516     echo "Installing packages"
517     in_chroot -- \
518       $APT_INSTALL \
519       autoconf automake ghc ghc-haddock \
520       libghc-curl-dev libghc-hinotify-dev \
521       libghc-parallel-dev libghc-utf8-string-dev \
522       libghc-crypto-dev \
523       libghc-attoparsec-dev \
524       libghc-vector-dev libghc-temporary-dev libghc-psqueue-dev \
525       libghc-cabal-dev \
526       cabal-install \
527       libpcre3 libpcre3-dev happy hscolour pandoc \
528       python-setuptools python-sphinx python-epydoc graphviz python-pyparsing \
529       python-simplejson python-pyinotify python-pycurl python-paramiko \
530       python-bitarray python-ipaddr python-yaml qemu-utils python-coverage pep8 \
531       python-dev pylint openssh-client vim git git-email exuberant-ctags \
532       build-essential
533
534     in_chroot -- \
535       easy_install \
536         logilab-astng==0.24.1 \
537         logilab-common==0.58.3 \
538         mock==1.0.1 \
539         pylint==0.26.0 \
540         pep8==1.3.3
541
542     in_chroot -- \
543       cabal update
544
545      # Precise has network-2.4.0.0, which breaks, see
546      #   https://github.com/haskell/network/issues/60
547      in_chroot -- \
548        cabal install --global \
549         'base64-bytestring>=1' \
550         hslogger-1.2.3 \
551         'hlint>=1.9.12' \
552         json-0.7 \
553         lens-3.10.2 \
554         'lifted-base>=0.1.2' \
555         'network>=2.4.0.1' \
556         'regex-pcre>=0.94.4' \
557         parsec-3.1.3 \
558         shelltestrunner \
559         'snap-server>=0.8.1' \
560         test-framework-0.8.0.3 \
561         test-framework-hunit-0.3.0.1 \
562         test-framework-quickcheck2-0.3.0.2 \
563         'transformers>=0.3.0.0'
564     ;;
565
566   *)
567     in_chroot -- \
568       $APT_INSTALL \
569       autoconf automake ghc ghc-haddock libghc-network-dev \
570       libghc-test-framework{,-hunit,-quickcheck2}-dev \
571       libghc-json-dev libghc-curl-dev libghc-hinotify-dev \
572       libghc-parallel-dev libghc-utf8-string-dev \
573       libghc-hslogger-dev libghc-crypto-dev \
574       libghc-regex-pcre-dev libghc-attoparsec-dev \
575       libghc-vector-dev libghc-temporary-dev libghc-psqueue-dev \
576       libghc-snap-server-dev libpcre3 libpcre3-dev happy hscolour pandoc \
577       libghc-lens-dev libghc-lifted-base-dev \
578       libghc-cabal-dev \
579       cabal-install \
580       libghc-base64-bytestring-dev \
581       python-setuptools python-sphinx python-epydoc graphviz python-pyparsing \
582       python-simplejson python-pyinotify python-pycurl python-paramiko \
583       python-bitarray python-ipaddr python-yaml qemu-utils python-coverage pep8 \
584       shelltestrunner python-dev pylint openssh-client \
585       vim git git-email exuberant-ctags \
586       build-essential
587
588     in_chroot -- \
589       cabal update
590
591      in_chroot -- \
592        cabal install --global \
593         'hlint>=1.9.12'
594 ;;
595 esac
596
597 # print what packages and versions are installed:
598 in_chroot -- \
599   cabal list --installed --simple-output
600
601 in_chroot -- \
602   $APT_INSTALL sudo fakeroot rsync locales less socat
603
604 # Configure the locale
605 case $DIST_RELEASE in
606   precise)
607     in_chroot -- \
608       $APT_INSTALL language-pack-en
609     ;;
610   *)
611     echo "en_US.UTF-8 UTF-8" >> $CHDIR/etc/locale.gen
612
613     in_chroot -- \
614       locale-gen
615     ;;
616 esac
617
618 in_chroot -- \
619   $APT_INSTALL lvm2 ssh bridge-utils iproute iputils-arping \
620                ndisc6 python-openssl openssl \
621                python-mock fping qemu-utils
622
623 in_chroot -- \
624   easy_install psutil
625
626 in_chroot -- \
627   easy_install jsonpointer \
628     jsonpointer \
629     jsonpatch
630
631 in_chroot -- \
632   $APT_INSTALL \
633   python-epydoc debhelper quilt
634
635 # extra debian packages
636
637 for package in $CHROOT_EXTRA_DEBIAN_PACKAGES
638 do in_chroot -- \
639   $APT_INSTALL $package
640 done
641
642 #Set default editor
643 in_chroot -- \
644   update-alternatives --set editor $ALTERNATIVE_EDITOR
645
646 # Final user hook
647
648 in_chroot -- $CHROOT_FINAL_HOOK
649
650 rm -f $COMP_FILEPATH
651 echo "Creating compressed schroot image..."
652 cd $CHDIR
653 tar czf $COMP_FILEPATH ./*
654 cd $ROOT
655
656 rm -rf $CHDIR
657 rm -f $TEMP_CHROOT_CONF
658 rm -rf $TEMP_DATA_DIR
659
660 echo "Chroot created. In order to run it:"
661 echo " * sudo cp $FINAL_CHROOT_CONF $CONF_DIR/$FINAL_CHROOT_CONF"
662 echo " * sudo mkdir -p $CHROOT_DIR"
663 echo " * sudo cp $COMP_FILEPATH $CHROOT_DIR/$COMP_FILENAME"
664 echo "Then run \"schroot -c $CHROOTNAME\""