Statistics
| Branch: | Tag: | Revision:

root / devel / build_chroot @ d8e3c5c9

History | View | Annotate | Download (3.8 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

    
9
#Automatically generated variables
10
CHROOTNAME=$DIST_RELEASE-$ARCH
11
CHNAME=building_$CHROOTNAME
12
TEMP_CHROOT_CONF=$CONF_DIR/$CHNAME.conf
13
FINAL_CHROOT_CONF=$CHROOTNAME.conf
14
ROOT=`pwd`
15
CHDIR=$ROOT/$CHNAME
16
USER=`whoami`
17
COMP_FILENAME=$CHROOTNAME.tar.gz
18
COMP_FILEPATH=$ROOT/$COMP_FILENAME
19

    
20
#Runnability checks
21
if [ $USER != 'root' ]
22
then
23
  echo "This script requires root permissions to run"
24
  exit
25
fi
26

    
27
if [ -f $TEMP_CHROOT_CONF ]
28
then
29
  echo "The configuration file name for the temporary chroot"
30
  echo "  $TEMP_CHROOT_CONF"
31
  echo "already exists."
32
  echo "Remove it or change the CHNAME value in the script."
33
  exit
34
fi
35

    
36
set -e
37

    
38
#Cleanup
39
rm -rf $CHDIR
40
mkdir $CHDIR
41

    
42
#Install tools for building chroots
43
apt-get install -y schroot debootstrap
44

    
45
shopt -s expand_aliases
46
alias in_chroot='schroot -c $CHNAME -d / '
47
alias subst_variables='sed \
48
  -e "s/\${ARCH}/$ARCH/" \
49
  -e "s*\${CHDIR}*$CHDIR*" \
50
  -e "s/\${CHNAME}/$CHNAME/" \
51
  -e "s/\${CHROOTNAME}/$CHROOTNAME/" \
52
  -e "s*\${CHROOT_DIR}*$CHROOT_DIR*" \
53
  -e "s/\${COMP_FILENAME}/$COMP_FILENAME/" \
54
  -e "s/\${DIST_RELEASE}/$DIST_RELEASE/"'
55

    
56
#Generate chroot configurations
57
cat $DATA_DIR/temp.schroot.conf.in | subst_variables > $TEMP_CHROOT_CONF
58
cat $DATA_DIR/final.schroot.conf.in | subst_variables > $FINAL_CHROOT_CONF
59

    
60
#Install the base system
61
debootstrap --arch $ARCH $DIST_RELEASE $CHDIR
62

    
63
APT_INSTALL="apt-get install -y --no-install-recommends"
64

    
65
echo "deb http://backports.debian.org/debian-backports" \
66
     "$DIST_RELEASE-backports main contrib non-free" \
67
     > $CHDIR/etc/apt/sources.list.d/backports.list
68

    
69
#Install all the packages
70
in_chroot -- \
71
  apt-get update
72

    
73
#Install selected packages from backports
74
in_chroot -- \
75
  apt-get -y --no-install-recommends -t squeeze-backports install \
76
    git \
77
    vim
78

    
79
in_chroot -- \
80
  $APT_INSTALL python-setuptools build-essential python-dev sudo automake \
81
               fakeroot rsync locales
82

    
83
echo "en_US.UTF-8 UTF-8" >> $CHDIR/etc/locale.gen
84

    
85
in_chroot -- \
86
  locale-gen
87

    
88
in_chroot -- \
89
  $APT_INSTALL lvm2 ssh bridge-utils iproute iputils-arping \
90
               ndisc6 python python-pyopenssl openssl \
91
               python-pyparsing python-simplejson \
92
               python-pyinotify python-pycurl python-yaml socat fping
93

    
94
in_chroot -- \
95
  $APT_INSTALL python-paramiko qemu-utils
96

    
97
in_chroot -- \
98
  easy_install affinity bitarray ipaddr
99

    
100
#Haskell packages
101
in_chroot -- \
102
  $APT_INSTALL ghc6 \
103
               libghc6-parallel-dev libghc6-deepseq-dev \
104
               libghc6-curl-dev
105

    
106
in_chroot -- \
107
  $APT_INSTALL cabal-install
108

    
109
in_chroot -- \
110
  cabal update
111

    
112
in_chroot -- \
113
  $APT_INSTALL libpcre3-dev
114

    
115
in_chroot -- \
116
  cabal install --global \
117
    QuickCheck==2.5.1.1 \
118
    network==2.3 hslogger Crypto text regex-pcre \
119
    attoparsec vector \
120
    json==0.4.4 \
121
    MonadCatchIO-transformers==0.2.2.0 mtl==2.0.1.0 \
122
    hashable==1.1.2.0 case-insensitive==0.3 parsec==3.0.1 \
123
    network==2.3 snap-server==0.8.1 \
124
    hinotify==0.3.2
125

    
126
#Python development tools
127
in_chroot -- \
128
  $APT_INSTALL pandoc python-epydoc graphviz
129

    
130
in_chroot -- \
131
  easy_install sphinx==1.1.3 \
132
               logilab-common \
133
               logilab-astng==0.23.1 \
134
               pylint==0.25.1 \
135
               pep8==1.2 \
136
               coverage
137

    
138
#Haskell development tools
139
in_chroot -- \
140
  cabal install --global \
141
    HUnit \
142
    happy \
143
    hlint==1.8.34 \
144
    hscolour==1.20.3 \
145
    temporary \
146
    test-framework==0.6.1 \
147
    test-framework-hunit==0.2.7 \
148
    test-framework-quickcheck2==0.2.12.3
149

    
150
in_chroot -- \
151
  cabal install --global shelltestrunner
152

    
153
rm -f $COMP_FILEPATH
154
echo "Creating compressed schroot image..."
155
cd $CHDIR
156
tar czf $COMP_FILEPATH ./*
157
cd $ROOT
158
echo "Done"
159

    
160
rm -rf $CHDIR
161
rm -f $TEMP_CHROOT_CONF