1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#!/bin/bash
if [ `id -u` != 0 ];
then
echo "! you must be root to run $0"
exit
fi
DIR=`dirname $0`
. $DIR/function.sh
[ -f $DIR/../testing.conf ] || die "!! Configuration file 'testing.conf' not found"
. $DIR/../testing.conf
execute()
{
cmd=${1}
echo $cmd >>$LOGFILE
$cmd >>$LOGFILE 2>&1
status=$?
if [ $status != 0 ]; then
echo "! command $cmd failed, exiting (status $status)"
echo "! check why here $LOGFILE"
exit 1
fi
}
execute_chroot()
{
execute "chroot $LOOPDIR $@"
}
# additional packages
EXTRAS=build-essential,gperf,libgmp-dev,libldap2-dev,libcurl4-openssl-dev,libxml2-dev,libtspi-dev,libsqlite3-dev,openssh-server,tcpdump,psmisc,openssl,vim,sqlite3,conntrack,gdb,cmake,libxerces-c2-dev,libltdl-dev,liblog4cxx10-dev,libboost-thread-dev,libboost-system-dev,git-core
SERVICES="isc-dhcp-server apache2 slapd"
PACKAGES=$EXTRAS,${SERVICES// /,}
CACHEDIR=$BUILDDIR/cache
APTCACHE=$LOOPDIR/var/cache/apt/archives
mkdir -p $LOOPDIR
mkdir -p $BUILDDIR
mkdir -p $CACHEDIR
rm -f $ROOTFS
echo "`date`, building $ROOTFS" >>$LOGFILE
echo " * Creating sparse image $ROOTFS ..."
execute "dd if=/dev/null of=$ROOTFS bs=1M seek=$ROOTFSSIZE count=1"
echo " * Creating ext3 filesystem ..."
execute "mkfs.ext3 -F $ROOTFS"
execute "mount -o loop $ROOTFS $LOOPDIR"
mkdir -p $APTCACHE
execute "mount -o bind $CACHEDIR $APTCACHE"
echo " * Running debootstrap ..."
execute "debootstrap --arch=$ROOTFSARCH --include=$PACKAGES $ROOTFSSUITE $LOOPDIR $ROOTFSMIRROR"
echo " * Disabling root password ..."
execute_chroot "passwd -d root"
echo " * Disabling services ..."
for service in $SERVICES
do
echo -n " - $service ... "
execute_chroot "/etc/init.d/$service stop"
execute_chroot "update-rc.d -f $service remove"
echo "done"
done
execute "umount -l $APTCACHE"
execute "umount -l $LOOPDIR"
|