root / devel / build_chroot @ 6676f007
History | View | Annotate | Download (5.7 kB)
1 | 8b3f1f42 | Michele Tartara | #!/bin/bash |
---|---|---|---|
2 | 8b3f1f42 | Michele Tartara | #Configuration |
3 | d1068153 | Michele Tartara | : ${ARCH:=amd64} |
4 | d1068153 | Michele Tartara | : ${DIST_RELEASE:=squeeze} |
5 | 8b3f1f42 | Michele Tartara | : ${CONF_DIR:=/etc/schroot/chroot.d} |
6 | 8b3f1f42 | Michele Tartara | : ${CHROOT_DIR:=/srv/chroot} |
7 | 35133aae | Michele Tartara | : ${ALTERNATIVE_EDITOR:=/usr/bin/vim.basic} |
8 | 6676f007 | Klaus Aehlig | : ${CHROOT_FINAL_HOOK:=/bin/true} |
9 | 6676f007 | Klaus Aehlig | # Additional Variables taken from the environmen |
10 | 6676f007 | Klaus Aehlig | # DATA_DIR |
11 | 6676f007 | Klaus Aehlig | # CHROOT_EXTRA_DEBIAN_PACKAGES |
12 | 8b3f1f42 | Michele Tartara | |
13 | 8b3f1f42 | Michele Tartara | #Automatically generated variables |
14 | 8b3f1f42 | Michele Tartara | CHROOTNAME=$DIST_RELEASE-$ARCH |
15 | 8b3f1f42 | Michele Tartara | CHNAME=building_$CHROOTNAME |
16 | 8b3f1f42 | Michele Tartara | TEMP_CHROOT_CONF=$CONF_DIR/$CHNAME.conf |
17 | 8b3f1f42 | Michele Tartara | FINAL_CHROOT_CONF=$CHROOTNAME.conf |
18 | 8b3f1f42 | Michele Tartara | ROOT=`pwd` |
19 | 8b3f1f42 | Michele Tartara | CHDIR=$ROOT/$CHNAME |
20 | 8b3f1f42 | Michele Tartara | USER=`whoami` |
21 | 8b3f1f42 | Michele Tartara | COMP_FILENAME=$CHROOTNAME.tar.gz |
22 | 8b3f1f42 | Michele Tartara | COMP_FILEPATH=$ROOT/$COMP_FILENAME |
23 | d1068153 | Michele Tartara | TEMP_DATA_DIR=`mktemp -d` |
24 | d1068153 | Michele Tartara | ACTUAL_DATA_DIR=$DATA_DIR |
25 | d1068153 | Michele Tartara | ACTUAL_DATA_DIR=${ACTUAL_DATA_DIR:-$TEMP_DATA_DIR} |
26 | 8b3f1f42 | Michele Tartara | |
27 | 8b3f1f42 | Michele Tartara | #Runnability checks |
28 | 8b3f1f42 | Michele Tartara | if [ $USER != 'root' ] |
29 | 8b3f1f42 | Michele Tartara | then |
30 | 8b3f1f42 | Michele Tartara | echo "This script requires root permissions to run" |
31 | 8b3f1f42 | Michele Tartara | exit |
32 | 8b3f1f42 | Michele Tartara | fi |
33 | 8b3f1f42 | Michele Tartara | |
34 | 8b3f1f42 | Michele Tartara | if [ -f $TEMP_CHROOT_CONF ] |
35 | 8b3f1f42 | Michele Tartara | then |
36 | 8b3f1f42 | Michele Tartara | echo "The configuration file name for the temporary chroot" |
37 | 8b3f1f42 | Michele Tartara | echo " $TEMP_CHROOT_CONF" |
38 | 8b3f1f42 | Michele Tartara | echo "already exists." |
39 | 8b3f1f42 | Michele Tartara | echo "Remove it or change the CHNAME value in the script." |
40 | 8b3f1f42 | Michele Tartara | exit |
41 | 8b3f1f42 | Michele Tartara | fi |
42 | 8b3f1f42 | Michele Tartara | |
43 | d1068153 | Michele Tartara | #Create configuration dir and files if they do not exist |
44 | d1068153 | Michele Tartara | if [ ! -d $ACTUAL_DATA_DIR ] |
45 | 85b66af5 | Michele Tartara | then |
46 | d1068153 | Michele Tartara | mkdir $ACTUAL_DATA_DIR |
47 | 85b66af5 | Michele Tartara | echo "The data directory" |
48 | d1068153 | Michele Tartara | echo " $ACTUAL_DATA_DIR" |
49 | d1068153 | Michele Tartara | echo "has been created." |
50 | d1068153 | Michele Tartara | fi |
51 | d1068153 | Michele Tartara | |
52 | d1068153 | Michele Tartara | if [ ! -f $ACTUAL_DATA_DIR/final.schroot.conf.in ] |
53 | d1068153 | Michele Tartara | then |
54 | d1068153 | Michele Tartara | cat <<END >$ACTUAL_DATA_DIR/final.schroot.conf.in |
55 | d1068153 | Michele Tartara | [${CHROOTNAME}] |
56 | d1068153 | Michele Tartara | description=Debian ${DIST_RELEASE} ${ARCH} |
57 | d1068153 | Michele Tartara | groups=src |
58 | d1068153 | Michele Tartara | source-root-groups=root |
59 | d1068153 | Michele Tartara | type=file |
60 | d1068153 | Michele Tartara | file=${CHROOT_DIR}/${COMP_FILENAME} |
61 | d1068153 | Michele Tartara | END |
62 | d1068153 | Michele Tartara | echo "The file" |
63 | d1068153 | Michele Tartara | echo " $ACTUAL_DATA_DIR/final.schroot.conf.in" |
64 | d1068153 | Michele Tartara | echo "has been created with default configurations." |
65 | 85b66af5 | Michele Tartara | fi |
66 | 85b66af5 | Michele Tartara | |
67 | d1068153 | Michele Tartara | if [ ! -f $ACTUAL_DATA_DIR/temp.schroot.conf.in ] |
68 | d1068153 | Michele Tartara | then |
69 | d1068153 | Michele Tartara | cat <<END >$ACTUAL_DATA_DIR/temp.schroot.conf.in |
70 | d1068153 | Michele Tartara | [${CHNAME}] |
71 | d1068153 | Michele Tartara | description=Debian ${DIST_RELEASE} ${ARCH} |
72 | d1068153 | Michele Tartara | directory=${CHDIR} |
73 | d1068153 | Michele Tartara | groups=src |
74 | d1068153 | Michele Tartara | users=root |
75 | d1068153 | Michele Tartara | type=directory |
76 | d1068153 | Michele Tartara | END |
77 | d1068153 | Michele Tartara | echo "The file" |
78 | d1068153 | Michele Tartara | echo " $ACTUAL_DATA_DIR/temp.schroot.conf.in" |
79 | d1068153 | Michele Tartara | echo "has been created with default configurations." |
80 | 85b66af5 | Michele Tartara | fi |
81 | 85b66af5 | Michele Tartara | |
82 | d1068153 | Michele Tartara | #Stop on errors |
83 | 8b3f1f42 | Michele Tartara | set -e |
84 | 8b3f1f42 | Michele Tartara | |
85 | 8b3f1f42 | Michele Tartara | #Cleanup |
86 | 8b3f1f42 | Michele Tartara | rm -rf $CHDIR |
87 | 8b3f1f42 | Michele Tartara | mkdir $CHDIR |
88 | 8b3f1f42 | Michele Tartara | |
89 | 8b3f1f42 | Michele Tartara | #Install tools for building chroots |
90 | 8b3f1f42 | Michele Tartara | apt-get install -y schroot debootstrap |
91 | 8b3f1f42 | Michele Tartara | |
92 | 8b3f1f42 | Michele Tartara | shopt -s expand_aliases |
93 | 8b3f1f42 | Michele Tartara | alias in_chroot='schroot -c $CHNAME -d / ' |
94 | 8b3f1f42 | Michele Tartara | alias subst_variables='sed \ |
95 | 8b3f1f42 | Michele Tartara | -e "s/\${ARCH}/$ARCH/" \ |
96 | 8b3f1f42 | Michele Tartara | -e "s*\${CHDIR}*$CHDIR*" \ |
97 | 8b3f1f42 | Michele Tartara | -e "s/\${CHNAME}/$CHNAME/" \ |
98 | 8b3f1f42 | Michele Tartara | -e "s/\${CHROOTNAME}/$CHROOTNAME/" \ |
99 | 8b3f1f42 | Michele Tartara | -e "s*\${CHROOT_DIR}*$CHROOT_DIR*" \ |
100 | 8b3f1f42 | Michele Tartara | -e "s/\${COMP_FILENAME}/$COMP_FILENAME/" \ |
101 | 8b3f1f42 | Michele Tartara | -e "s/\${DIST_RELEASE}/$DIST_RELEASE/"' |
102 | 8b3f1f42 | Michele Tartara | |
103 | 8b3f1f42 | Michele Tartara | #Generate chroot configurations |
104 | d1068153 | Michele Tartara | cat $ACTUAL_DATA_DIR/temp.schroot.conf.in | subst_variables > $TEMP_CHROOT_CONF |
105 | d1068153 | Michele Tartara | cat $ACTUAL_DATA_DIR/final.schroot.conf.in | subst_variables > $FINAL_CHROOT_CONF |
106 | 8b3f1f42 | Michele Tartara | |
107 | 8b3f1f42 | Michele Tartara | #Install the base system |
108 | 8b3f1f42 | Michele Tartara | debootstrap --arch $ARCH $DIST_RELEASE $CHDIR |
109 | 8b3f1f42 | Michele Tartara | |
110 | 8b3f1f42 | Michele Tartara | APT_INSTALL="apt-get install -y --no-install-recommends" |
111 | 8b3f1f42 | Michele Tartara | |
112 | d8e3c5c9 | Michele Tartara | echo "deb http://backports.debian.org/debian-backports" \ |
113 | d8e3c5c9 | Michele Tartara | "$DIST_RELEASE-backports main contrib non-free" \ |
114 | d8e3c5c9 | Michele Tartara | > $CHDIR/etc/apt/sources.list.d/backports.list |
115 | d8e3c5c9 | Michele Tartara | |
116 | 8b3f1f42 | Michele Tartara | #Install all the packages |
117 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
118 | 8b3f1f42 | Michele Tartara | apt-get update |
119 | 8b3f1f42 | Michele Tartara | |
120 | d8e3c5c9 | Michele Tartara | #Install selected packages from backports |
121 | d8e3c5c9 | Michele Tartara | in_chroot -- \ |
122 | f5263f86 | Klaus Aehlig | $APT_INSTALL -t squeeze-backports \ |
123 | d8e3c5c9 | Michele Tartara | git \ |
124 | d8e3c5c9 | Michele Tartara | vim |
125 | d8e3c5c9 | Michele Tartara | |
126 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
127 | d8e3c5c9 | Michele Tartara | $APT_INSTALL python-setuptools build-essential python-dev sudo automake \ |
128 | 4cbf242b | Michele Tartara | fakeroot rsync locales less |
129 | 8b3f1f42 | Michele Tartara | |
130 | 8b3f1f42 | Michele Tartara | echo "en_US.UTF-8 UTF-8" >> $CHDIR/etc/locale.gen |
131 | 8b3f1f42 | Michele Tartara | |
132 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
133 | 8b3f1f42 | Michele Tartara | locale-gen |
134 | 8b3f1f42 | Michele Tartara | |
135 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
136 | 8b3f1f42 | Michele Tartara | $APT_INSTALL lvm2 ssh bridge-utils iproute iputils-arping \ |
137 | 8b3f1f42 | Michele Tartara | ndisc6 python python-pyopenssl openssl \ |
138 | 8b3f1f42 | Michele Tartara | python-pyparsing python-simplejson \ |
139 | 7a694e30 | Thomas Thrainer | python-pyinotify python-pycurl python-yaml python-mock \ |
140 | 7a694e30 | Thomas Thrainer | socat fping |
141 | 8b3f1f42 | Michele Tartara | |
142 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
143 | 8b3f1f42 | Michele Tartara | $APT_INSTALL python-paramiko qemu-utils |
144 | 8b3f1f42 | Michele Tartara | |
145 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
146 | 8b3f1f42 | Michele Tartara | easy_install affinity bitarray ipaddr |
147 | 8b3f1f42 | Michele Tartara | |
148 | 8b3f1f42 | Michele Tartara | #Haskell packages |
149 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
150 | 8b3f1f42 | Michele Tartara | $APT_INSTALL ghc6 \ |
151 | 8b3f1f42 | Michele Tartara | libghc6-parallel-dev libghc6-deepseq-dev \ |
152 | 8b3f1f42 | Michele Tartara | libghc6-curl-dev |
153 | 8b3f1f42 | Michele Tartara | |
154 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
155 | 8b3f1f42 | Michele Tartara | $APT_INSTALL cabal-install |
156 | 8b3f1f42 | Michele Tartara | |
157 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
158 | 8b3f1f42 | Michele Tartara | cabal update |
159 | 8b3f1f42 | Michele Tartara | |
160 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
161 | 8b3f1f42 | Michele Tartara | $APT_INSTALL libpcre3-dev |
162 | 8b3f1f42 | Michele Tartara | |
163 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
164 | 8b3f1f42 | Michele Tartara | cabal install --global \ |
165 | 71e00202 | Michele Tartara | network==2.3 \ |
166 | 71e00202 | Michele Tartara | regex-pcre==0.94.2 \ |
167 | 74685117 | Michele Tartara | hinotify==0.3.2 \ |
168 | 71e00202 | Michele Tartara | hslogger==1.1.4 \ |
169 | 71e00202 | Michele Tartara | attoparsec==0.10.1.1\ |
170 | 71e00202 | Michele Tartara | quickcheck==2.5.1.1 \ |
171 | 71e00202 | Michele Tartara | crypto==4.2.4 \ |
172 | 71e00202 | Michele Tartara | monadcatchio-transformers==0.2.2.0 \ |
173 | 71e00202 | Michele Tartara | mtl==2.0.1.0 \ |
174 | 71e00202 | Michele Tartara | hashable==1.1.2.0 \ |
175 | 71e00202 | Michele Tartara | case-insensitive==0.3 \ |
176 | 71e00202 | Michele Tartara | parsec==3.0.1 \ |
177 | 71e00202 | Michele Tartara | network==2.3 \ |
178 | 71e00202 | Michele Tartara | snap-server==0.8.1 \ |
179 | 71e00202 | Michele Tartara | text==0.11.3.0 \ |
180 | 71e00202 | Michele Tartara | vector==0.9.1 \ |
181 | 1bb99a33 | Bernardo Dal Seno | json==0.4.4 \ |
182 | 74685117 | Michele Tartara | process==1.0.1.2 |
183 | 74685117 | Michele Tartara | |
184 | 8b3f1f42 | Michele Tartara | #Python development tools |
185 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
186 | 8b3f1f42 | Michele Tartara | $APT_INSTALL pandoc python-epydoc graphviz |
187 | 8b3f1f42 | Michele Tartara | |
188 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
189 | 8b3f1f42 | Michele Tartara | easy_install sphinx==1.1.3 \ |
190 | 8b3f1f42 | Michele Tartara | logilab-common \ |
191 | 8b3f1f42 | Michele Tartara | logilab-astng==0.23.1 \ |
192 | 8b3f1f42 | Michele Tartara | pylint==0.25.1 \ |
193 | 8b3f1f42 | Michele Tartara | pep8==1.2 \ |
194 | 8b3f1f42 | Michele Tartara | coverage |
195 | 8b3f1f42 | Michele Tartara | |
196 | 8b3f1f42 | Michele Tartara | #Haskell development tools |
197 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
198 | 8b3f1f42 | Michele Tartara | cabal install --global \ |
199 | 71e00202 | Michele Tartara | hunit==1.2.5.2 \ |
200 | 71e00202 | Michele Tartara | happy==1.18.10 \ |
201 | 8b3f1f42 | Michele Tartara | hlint==1.8.34 \ |
202 | 8b3f1f42 | Michele Tartara | hscolour==1.20.3 \ |
203 | 71e00202 | Michele Tartara | temporary==1.1.2.3 \ |
204 | 8b3f1f42 | Michele Tartara | test-framework==0.6.1 \ |
205 | 8b3f1f42 | Michele Tartara | test-framework-hunit==0.2.7 \ |
206 | 8b3f1f42 | Michele Tartara | test-framework-quickcheck2==0.2.12.3 |
207 | 8b3f1f42 | Michele Tartara | |
208 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
209 | 8b3f1f42 | Michele Tartara | cabal install --global shelltestrunner |
210 | 8b3f1f42 | Michele Tartara | |
211 | 9839902a | Michele Tartara | #Tools for creating debian packages |
212 | 9839902a | Michele Tartara | in_chroot -- \ |
213 | 43ffd839 | Klaus Aehlig | $APT_INSTALL python-docutils debhelper quilt |
214 | 9839902a | Michele Tartara | |
215 | 6676f007 | Klaus Aehlig | # extra debian packages |
216 | 6676f007 | Klaus Aehlig | |
217 | 6676f007 | Klaus Aehlig | for package in $CHROOT_EXTRA_DEBIAN_PACKAGES |
218 | 6676f007 | Klaus Aehlig | do in_chroot -- \ |
219 | 6676f007 | Klaus Aehlig | $APT_INSTALL $package |
220 | 6676f007 | Klaus Aehlig | done |
221 | 6676f007 | Klaus Aehlig | |
222 | 35133aae | Michele Tartara | #Set default editor |
223 | 35133aae | Michele Tartara | in_chroot -- \ |
224 | 35133aae | Michele Tartara | update-alternatives --set editor $ALTERNATIVE_EDITOR |
225 | 35133aae | Michele Tartara | |
226 | 6676f007 | Klaus Aehlig | # Final user hook |
227 | 6676f007 | Klaus Aehlig | |
228 | 6676f007 | Klaus Aehlig | in_chroot -- $CHROOT_FINAL_HOOK |
229 | 6676f007 | Klaus Aehlig | |
230 | 8b3f1f42 | Michele Tartara | rm -f $COMP_FILEPATH |
231 | 8b3f1f42 | Michele Tartara | echo "Creating compressed schroot image..." |
232 | 8b3f1f42 | Michele Tartara | cd $CHDIR |
233 | 8b3f1f42 | Michele Tartara | tar czf $COMP_FILEPATH ./* |
234 | 8b3f1f42 | Michele Tartara | cd $ROOT |
235 | 8b3f1f42 | Michele Tartara | |
236 | 8b3f1f42 | Michele Tartara | rm -rf $CHDIR |
237 | 8b3f1f42 | Michele Tartara | rm -f $TEMP_CHROOT_CONF |
238 | d1068153 | Michele Tartara | rm -rf $TEMP_DATA_DIR |
239 | 3be0f700 | Michele Tartara | |
240 | 3be0f700 | Michele Tartara | echo "Chroot created. In order to run it:" |
241 | 3be0f700 | Michele Tartara | echo " * Copy the file $FINAL_CHROOT_CONF to $CONF_DIR/$FINAL_CHROOT_CONF" |
242 | 3be0f700 | Michele Tartara | echo " * Copy the file $COMP_FILEPATH to $CHROOT_DIR/$COMP_FILENAME" |
243 | 3be0f700 | Michele Tartara | |
244 | 3be0f700 | Michele Tartara | echo "Then run \"schroot -c $CHROOTNAME\"" |