root / devel / build_chroot @ b6772b46
History | View | Annotate | Download (5.5 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 | d1068153 | Michele Tartara | # The value of DATA_DIR is read as well from the environment. |
9 | 8b3f1f42 | Michele Tartara | |
10 | 8b3f1f42 | Michele Tartara | #Automatically generated variables |
11 | 8b3f1f42 | Michele Tartara | CHROOTNAME=$DIST_RELEASE-$ARCH |
12 | 8b3f1f42 | Michele Tartara | CHNAME=building_$CHROOTNAME |
13 | 8b3f1f42 | Michele Tartara | TEMP_CHROOT_CONF=$CONF_DIR/$CHNAME.conf |
14 | 8b3f1f42 | Michele Tartara | FINAL_CHROOT_CONF=$CHROOTNAME.conf |
15 | 8b3f1f42 | Michele Tartara | ROOT=`pwd` |
16 | 8b3f1f42 | Michele Tartara | CHDIR=$ROOT/$CHNAME |
17 | 8b3f1f42 | Michele Tartara | USER=`whoami` |
18 | 8b3f1f42 | Michele Tartara | COMP_FILENAME=$CHROOTNAME.tar.gz |
19 | 8b3f1f42 | Michele Tartara | COMP_FILEPATH=$ROOT/$COMP_FILENAME |
20 | d1068153 | Michele Tartara | TEMP_DATA_DIR=`mktemp -d` |
21 | d1068153 | Michele Tartara | ACTUAL_DATA_DIR=$DATA_DIR |
22 | d1068153 | Michele Tartara | ACTUAL_DATA_DIR=${ACTUAL_DATA_DIR:-$TEMP_DATA_DIR} |
23 | 8b3f1f42 | Michele Tartara | |
24 | 8b3f1f42 | Michele Tartara | #Runnability checks |
25 | 8b3f1f42 | Michele Tartara | if [ $USER != 'root' ] |
26 | 8b3f1f42 | Michele Tartara | then |
27 | 8b3f1f42 | Michele Tartara | echo "This script requires root permissions to run" |
28 | 8b3f1f42 | Michele Tartara | exit |
29 | 8b3f1f42 | Michele Tartara | fi |
30 | 8b3f1f42 | Michele Tartara | |
31 | 8b3f1f42 | Michele Tartara | if [ -f $TEMP_CHROOT_CONF ] |
32 | 8b3f1f42 | Michele Tartara | then |
33 | 8b3f1f42 | Michele Tartara | echo "The configuration file name for the temporary chroot" |
34 | 8b3f1f42 | Michele Tartara | echo " $TEMP_CHROOT_CONF" |
35 | 8b3f1f42 | Michele Tartara | echo "already exists." |
36 | 8b3f1f42 | Michele Tartara | echo "Remove it or change the CHNAME value in the script." |
37 | 8b3f1f42 | Michele Tartara | exit |
38 | 8b3f1f42 | Michele Tartara | fi |
39 | 8b3f1f42 | Michele Tartara | |
40 | d1068153 | Michele Tartara | #Create configuration dir and files if they do not exist |
41 | d1068153 | Michele Tartara | if [ ! -d $ACTUAL_DATA_DIR ] |
42 | 85b66af5 | Michele Tartara | then |
43 | d1068153 | Michele Tartara | mkdir $ACTUAL_DATA_DIR |
44 | 85b66af5 | Michele Tartara | echo "The data directory" |
45 | d1068153 | Michele Tartara | echo " $ACTUAL_DATA_DIR" |
46 | d1068153 | Michele Tartara | echo "has been created." |
47 | d1068153 | Michele Tartara | fi |
48 | d1068153 | Michele Tartara | |
49 | d1068153 | Michele Tartara | if [ ! -f $ACTUAL_DATA_DIR/final.schroot.conf.in ] |
50 | d1068153 | Michele Tartara | then |
51 | d1068153 | Michele Tartara | cat <<END >$ACTUAL_DATA_DIR/final.schroot.conf.in |
52 | d1068153 | Michele Tartara | [${CHROOTNAME}] |
53 | d1068153 | Michele Tartara | description=Debian ${DIST_RELEASE} ${ARCH} |
54 | d1068153 | Michele Tartara | groups=src |
55 | d1068153 | Michele Tartara | source-root-groups=root |
56 | d1068153 | Michele Tartara | type=file |
57 | d1068153 | Michele Tartara | file=${CHROOT_DIR}/${COMP_FILENAME} |
58 | d1068153 | Michele Tartara | END |
59 | d1068153 | Michele Tartara | echo "The file" |
60 | d1068153 | Michele Tartara | echo " $ACTUAL_DATA_DIR/final.schroot.conf.in" |
61 | d1068153 | Michele Tartara | echo "has been created with default configurations." |
62 | d1068153 | Michele Tartara | fi |
63 | d1068153 | Michele Tartara | |
64 | d1068153 | Michele Tartara | if [ ! -f $ACTUAL_DATA_DIR/temp.schroot.conf.in ] |
65 | d1068153 | Michele Tartara | then |
66 | d1068153 | Michele Tartara | cat <<END >$ACTUAL_DATA_DIR/temp.schroot.conf.in |
67 | d1068153 | Michele Tartara | [${CHNAME}] |
68 | d1068153 | Michele Tartara | description=Debian ${DIST_RELEASE} ${ARCH} |
69 | d1068153 | Michele Tartara | directory=${CHDIR} |
70 | d1068153 | Michele Tartara | groups=src |
71 | d1068153 | Michele Tartara | users=root |
72 | d1068153 | Michele Tartara | type=directory |
73 | d1068153 | Michele Tartara | END |
74 | d1068153 | Michele Tartara | echo "The file" |
75 | d1068153 | Michele Tartara | echo " $ACTUAL_DATA_DIR/temp.schroot.conf.in" |
76 | d1068153 | Michele Tartara | echo "has been created with default configurations." |
77 | 85b66af5 | Michele Tartara | fi |
78 | 85b66af5 | Michele Tartara | |
79 | d1068153 | Michele Tartara | #Stop on errors |
80 | 8b3f1f42 | Michele Tartara | set -e |
81 | 8b3f1f42 | Michele Tartara | |
82 | 8b3f1f42 | Michele Tartara | #Cleanup |
83 | 8b3f1f42 | Michele Tartara | rm -rf $CHDIR |
84 | 8b3f1f42 | Michele Tartara | mkdir $CHDIR |
85 | 8b3f1f42 | Michele Tartara | |
86 | 8b3f1f42 | Michele Tartara | #Install tools for building chroots |
87 | 8b3f1f42 | Michele Tartara | apt-get install -y schroot debootstrap |
88 | 8b3f1f42 | Michele Tartara | |
89 | 8b3f1f42 | Michele Tartara | shopt -s expand_aliases |
90 | 8b3f1f42 | Michele Tartara | alias in_chroot='schroot -c $CHNAME -d / ' |
91 | 3b308f47 | Michele Tartara | function subst_variables { |
92 | 3b308f47 | Michele Tartara | sed \ |
93 | 3b308f47 | Michele Tartara | -e "s/\${ARCH}/$ARCH/" \ |
94 | 3b308f47 | Michele Tartara | -e "s*\${CHDIR}*$CHDIR*" \ |
95 | 3b308f47 | Michele Tartara | -e "s/\${CHNAME}/$CHNAME/" \ |
96 | 3b308f47 | Michele Tartara | -e "s/\${CHROOTNAME}/$CHROOTNAME/" \ |
97 | 3b308f47 | Michele Tartara | -e "s*\${CHROOT_DIR}*$CHROOT_DIR*" \ |
98 | 3b308f47 | Michele Tartara | -e "s/\${COMP_FILENAME}/$COMP_FILENAME/" \ |
99 | 3b308f47 | Michele Tartara | -e "s/\${DIST_RELEASE}/$DIST_RELEASE/" $@ |
100 | 3b308f47 | Michele Tartara | } |
101 | 8b3f1f42 | Michele Tartara | |
102 | 8b3f1f42 | Michele Tartara | #Generate chroot configurations |
103 | d1068153 | Michele Tartara | cat $ACTUAL_DATA_DIR/temp.schroot.conf.in | subst_variables > $TEMP_CHROOT_CONF |
104 | d1068153 | Michele Tartara | cat $ACTUAL_DATA_DIR/final.schroot.conf.in | subst_variables > $FINAL_CHROOT_CONF |
105 | 8b3f1f42 | Michele Tartara | |
106 | 8b3f1f42 | Michele Tartara | #Install the base system |
107 | 8b3f1f42 | Michele Tartara | debootstrap --arch $ARCH $DIST_RELEASE $CHDIR |
108 | 8b3f1f42 | Michele Tartara | |
109 | 8b3f1f42 | Michele Tartara | APT_INSTALL="apt-get install -y --no-install-recommends" |
110 | 8b3f1f42 | Michele Tartara | |
111 | d8e3c5c9 | Michele Tartara | echo "deb http://backports.debian.org/debian-backports" \ |
112 | d8e3c5c9 | Michele Tartara | "$DIST_RELEASE-backports main contrib non-free" \ |
113 | d8e3c5c9 | Michele Tartara | > $CHDIR/etc/apt/sources.list.d/backports.list |
114 | d8e3c5c9 | Michele Tartara | |
115 | 8b3f1f42 | Michele Tartara | #Install all the packages |
116 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
117 | 8b3f1f42 | Michele Tartara | apt-get update |
118 | 8b3f1f42 | Michele Tartara | |
119 | d8e3c5c9 | Michele Tartara | #Install selected packages from backports |
120 | d8e3c5c9 | Michele Tartara | in_chroot -- \ |
121 | d8e3c5c9 | Michele Tartara | apt-get -y --no-install-recommends -t squeeze-backports install \ |
122 | d8e3c5c9 | Michele Tartara | git \ |
123 | c4101ab5 | Michele Tartara | git-email \ |
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 | 8b3f1f42 | Michele Tartara | python-pyinotify python-pycurl python-yaml socat fping |
140 | 8b3f1f42 | Michele Tartara | |
141 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
142 | 8b3f1f42 | Michele Tartara | $APT_INSTALL python-paramiko qemu-utils |
143 | 8b3f1f42 | Michele Tartara | |
144 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
145 | 8b3f1f42 | Michele Tartara | easy_install affinity bitarray ipaddr |
146 | 8b3f1f42 | Michele Tartara | |
147 | 8b3f1f42 | Michele Tartara | #Haskell packages |
148 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
149 | 8b3f1f42 | Michele Tartara | $APT_INSTALL ghc6 \ |
150 | 8b3f1f42 | Michele Tartara | libghc6-parallel-dev libghc6-deepseq-dev \ |
151 | 8b3f1f42 | Michele Tartara | libghc6-curl-dev |
152 | 8b3f1f42 | Michele Tartara | |
153 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
154 | 8b3f1f42 | Michele Tartara | $APT_INSTALL cabal-install |
155 | 8b3f1f42 | Michele Tartara | |
156 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
157 | 8b3f1f42 | Michele Tartara | cabal update |
158 | 8b3f1f42 | Michele Tartara | |
159 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
160 | 8b3f1f42 | Michele Tartara | $APT_INSTALL libpcre3-dev |
161 | 8b3f1f42 | Michele Tartara | |
162 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
163 | 8b3f1f42 | Michele Tartara | cabal install --global \ |
164 | b4e8599b | Petr Pudlak | blaze-builder==0.3.1.1 \ |
165 | 71e00202 | Michele Tartara | network==2.3 \ |
166 | 71e00202 | Michele Tartara | regex-pcre==0.94.2 \ |
167 | 71e00202 | 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 | 71e00202 | Michele Tartara | json==0.4.4 |
182 | 8b3f1f42 | Michele Tartara | |
183 | 8b3f1f42 | Michele Tartara | #Python development tools |
184 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
185 | 8b3f1f42 | Michele Tartara | $APT_INSTALL pandoc python-epydoc graphviz |
186 | 8b3f1f42 | Michele Tartara | |
187 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
188 | 8b3f1f42 | Michele Tartara | easy_install sphinx==1.1.3 \ |
189 | 8b3f1f42 | Michele Tartara | logilab-common \ |
190 | 8b3f1f42 | Michele Tartara | logilab-astng==0.23.1 \ |
191 | 8b3f1f42 | Michele Tartara | pylint==0.25.1 \ |
192 | 8b3f1f42 | Michele Tartara | pep8==1.2 \ |
193 | 8b3f1f42 | Michele Tartara | coverage |
194 | 8b3f1f42 | Michele Tartara | |
195 | 8b3f1f42 | Michele Tartara | #Haskell development tools |
196 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
197 | 8b3f1f42 | Michele Tartara | cabal install --global \ |
198 | 71e00202 | Michele Tartara | hunit==1.2.5.2 \ |
199 | 71e00202 | Michele Tartara | happy==1.18.10 \ |
200 | 8b3f1f42 | Michele Tartara | hlint==1.8.34 \ |
201 | 8b3f1f42 | Michele Tartara | hscolour==1.20.3 \ |
202 | 71e00202 | Michele Tartara | temporary==1.1.2.3 \ |
203 | 8b3f1f42 | Michele Tartara | test-framework==0.6.1 \ |
204 | 8b3f1f42 | Michele Tartara | test-framework-hunit==0.2.7 \ |
205 | 8b3f1f42 | Michele Tartara | test-framework-quickcheck2==0.2.12.3 |
206 | 8b3f1f42 | Michele Tartara | |
207 | 8b3f1f42 | Michele Tartara | in_chroot -- \ |
208 | 8b3f1f42 | Michele Tartara | cabal install --global shelltestrunner |
209 | 8b3f1f42 | Michele Tartara | |
210 | 9839902a | Michele Tartara | #Tools for creating debian packages |
211 | 9839902a | Michele Tartara | in_chroot -- \ |
212 | 2bc994ce | Michele Tartara | $APT_INSTALL python-docutils debhelper quilt |
213 | 9839902a | Michele Tartara | |
214 | 35133aae | Michele Tartara | #Set default editor |
215 | 35133aae | Michele Tartara | in_chroot -- \ |
216 | 35133aae | Michele Tartara | update-alternatives --set editor $ALTERNATIVE_EDITOR |
217 | 35133aae | Michele Tartara | |
218 | 8b3f1f42 | Michele Tartara | rm -f $COMP_FILEPATH |
219 | 8b3f1f42 | Michele Tartara | echo "Creating compressed schroot image..." |
220 | 8b3f1f42 | Michele Tartara | cd $CHDIR |
221 | 8b3f1f42 | Michele Tartara | tar czf $COMP_FILEPATH ./* |
222 | 8b3f1f42 | Michele Tartara | cd $ROOT |
223 | 8b3f1f42 | Michele Tartara | |
224 | 8b3f1f42 | Michele Tartara | rm -rf $CHDIR |
225 | 8b3f1f42 | Michele Tartara | rm -f $TEMP_CHROOT_CONF |
226 | d1068153 | Michele Tartara | rm -rf $TEMP_DATA_DIR |
227 | 3be0f700 | Michele Tartara | |
228 | 3be0f700 | Michele Tartara | echo "Chroot created. In order to run it:" |
229 | 3be0f700 | Michele Tartara | echo " * Copy the file $FINAL_CHROOT_CONF to $CONF_DIR/$FINAL_CHROOT_CONF" |
230 | 3be0f700 | Michele Tartara | echo " * Copy the file $COMP_FILEPATH to $CHROOT_DIR/$COMP_FILENAME" |
231 | 3be0f700 | Michele Tartara | |
232 | 3be0f700 | Michele Tartara | echo "Then run \"schroot -c $CHROOTNAME\"" |