root / devel / build_chroot @ 74685117
History | View | Annotate | Download (4 kB)
1 |
#!/bin/bash |
---|---|
2 |
#Configuration |
3 |
: ${DATA_DIR=data} |
4 |
: ${ARCH=amd64} |
5 |
: ${DIST_RELEASE=squeeze} |
6 |
: ${CONF_DIR:=/etc/schroot/chroot.d} |
7 |
: ${CHROOT_DIR:=/srv/chroot} |
8 |
: ${ALTERNATIVE_EDITOR:=/usr/bin/vim.basic} |
9 |
|
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 |
15 |
ROOT=`pwd` |
16 |
CHDIR=$ROOT/$CHNAME |
17 |
USER=`whoami` |
18 |
COMP_FILENAME=$CHROOTNAME.tar.gz |
19 |
COMP_FILEPATH=$ROOT/$COMP_FILENAME |
20 |
|
21 |
#Runnability checks |
22 |
if [ $USER != 'root' ] |
23 |
then |
24 |
echo "This script requires root permissions to run" |
25 |
exit |
26 |
fi |
27 |
|
28 |
if [ -f $TEMP_CHROOT_CONF ] |
29 |
then |
30 |
echo "The configuration file name for the temporary chroot" |
31 |
echo " $TEMP_CHROOT_CONF" |
32 |
echo "already exists." |
33 |
echo "Remove it or change the CHNAME value in the script." |
34 |
exit |
35 |
fi |
36 |
|
37 |
set -e |
38 |
|
39 |
#Cleanup |
40 |
rm -rf $CHDIR |
41 |
mkdir $CHDIR |
42 |
|
43 |
#Install tools for building chroots |
44 |
apt-get install -y schroot debootstrap |
45 |
|
46 |
shopt -s expand_aliases |
47 |
alias in_chroot='schroot -c $CHNAME -d / ' |
48 |
alias subst_variables='sed \ |
49 |
-e "s/\${ARCH}/$ARCH/" \ |
50 |
-e "s*\${CHDIR}*$CHDIR*" \ |
51 |
-e "s/\${CHNAME}/$CHNAME/" \ |
52 |
-e "s/\${CHROOTNAME}/$CHROOTNAME/" \ |
53 |
-e "s*\${CHROOT_DIR}*$CHROOT_DIR*" \ |
54 |
-e "s/\${COMP_FILENAME}/$COMP_FILENAME/" \ |
55 |
-e "s/\${DIST_RELEASE}/$DIST_RELEASE/"' |
56 |
|
57 |
#Generate chroot configurations |
58 |
cat $DATA_DIR/temp.schroot.conf.in | subst_variables > $TEMP_CHROOT_CONF |
59 |
cat $DATA_DIR/final.schroot.conf.in | subst_variables > $FINAL_CHROOT_CONF |
60 |
|
61 |
#Install the base system |
62 |
debootstrap --arch $ARCH $DIST_RELEASE $CHDIR |
63 |
|
64 |
APT_INSTALL="apt-get install -y --no-install-recommends" |
65 |
|
66 |
echo "deb http://backports.debian.org/debian-backports" \ |
67 |
"$DIST_RELEASE-backports main contrib non-free" \ |
68 |
> $CHDIR/etc/apt/sources.list.d/backports.list |
69 |
|
70 |
#Install all the packages |
71 |
in_chroot -- \ |
72 |
apt-get update |
73 |
|
74 |
#Install selected packages from backports |
75 |
in_chroot -- \ |
76 |
apt-get -y --no-install-recommends -t squeeze-backports install \ |
77 |
git \ |
78 |
vim |
79 |
|
80 |
in_chroot -- \ |
81 |
$APT_INSTALL python-setuptools build-essential python-dev sudo automake \ |
82 |
fakeroot rsync locales less |
83 |
|
84 |
echo "en_US.UTF-8 UTF-8" >> $CHDIR/etc/locale.gen |
85 |
|
86 |
in_chroot -- \ |
87 |
locale-gen |
88 |
|
89 |
in_chroot -- \ |
90 |
$APT_INSTALL lvm2 ssh bridge-utils iproute iputils-arping \ |
91 |
ndisc6 python python-pyopenssl openssl \ |
92 |
python-pyparsing python-simplejson \ |
93 |
python-pyinotify python-pycurl python-yaml python-mock \ |
94 |
socat fping |
95 |
|
96 |
in_chroot -- \ |
97 |
$APT_INSTALL python-paramiko qemu-utils |
98 |
|
99 |
in_chroot -- \ |
100 |
easy_install affinity bitarray ipaddr |
101 |
|
102 |
#Haskell packages |
103 |
in_chroot -- \ |
104 |
$APT_INSTALL ghc6 \ |
105 |
libghc6-parallel-dev libghc6-deepseq-dev \ |
106 |
libghc6-curl-dev |
107 |
|
108 |
in_chroot -- \ |
109 |
$APT_INSTALL cabal-install |
110 |
|
111 |
in_chroot -- \ |
112 |
cabal update |
113 |
|
114 |
in_chroot -- \ |
115 |
$APT_INSTALL libpcre3-dev |
116 |
|
117 |
in_chroot -- \ |
118 |
cabal install --global \ |
119 |
QuickCheck==2.5.1.1 \ |
120 |
network==2.3 hslogger Crypto text regex-pcre \ |
121 |
attoparsec vector \ |
122 |
json==0.4.4 \ |
123 |
MonadCatchIO-transformers==0.2.2.0 mtl==2.0.1.0 \ |
124 |
hashable==1.1.2.0 case-insensitive==0.3 parsec==3.0.1 \ |
125 |
network==2.3 snap-server==0.8.1 \ |
126 |
hinotify==0.3.2 \ |
127 |
process==1.0.1.2 |
128 |
|
129 |
|
130 |
#Python development tools |
131 |
in_chroot -- \ |
132 |
$APT_INSTALL pandoc python-epydoc graphviz |
133 |
|
134 |
in_chroot -- \ |
135 |
easy_install sphinx==1.1.3 \ |
136 |
logilab-common \ |
137 |
logilab-astng==0.23.1 \ |
138 |
pylint==0.25.1 \ |
139 |
pep8==1.2 \ |
140 |
coverage |
141 |
|
142 |
#Haskell development tools |
143 |
in_chroot -- \ |
144 |
cabal install --global \ |
145 |
HUnit \ |
146 |
happy \ |
147 |
hlint==1.8.34 \ |
148 |
hscolour==1.20.3 \ |
149 |
temporary \ |
150 |
test-framework==0.6.1 \ |
151 |
test-framework-hunit==0.2.7 \ |
152 |
test-framework-quickcheck2==0.2.12.3 |
153 |
|
154 |
in_chroot -- \ |
155 |
cabal install --global shelltestrunner |
156 |
|
157 |
#Set default editor |
158 |
in_chroot -- \ |
159 |
update-alternatives --set editor $ALTERNATIVE_EDITOR |
160 |
|
161 |
rm -f $COMP_FILEPATH |
162 |
echo "Creating compressed schroot image..." |
163 |
cd $CHDIR |
164 |
tar czf $COMP_FILEPATH ./* |
165 |
cd $ROOT |
166 |
echo "Done" |
167 |
|
168 |
rm -rf $CHDIR |
169 |
rm -f $TEMP_CHROOT_CONF |