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