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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
#!/bin/bash
# Copyright 2012 Holger Levsen <holger@layer-acht.org>
# released under the GPLv=2
# $1 = vnc-display, each job should have a unique one, so jobs can run in parallel
# $2 = name
# $3 = disksize in GB
# $4 = wget url/jigdo url
if [ "$1" = "" ] || [ "$2" = "" ] || [ "$3" = "" ] || [ "$4" = "" ] ; then
echo "need three params"
echo '# $1 = vnc-display, each job should have a unique one, so jobs can run in parallel'
echo '# $2 = name'
echo '# $3 = disksize in GB'
echo '# $4 = wget url/jigdo url'
exit 1
fi
#
# default settings
#
set -x
set -e
export LC_ALL=C
export MIRROR=http://ftp.de.debian.org/debian
export http_proxy="http://localhost:3128"
#
# init
#
DISPLAY=localhost:$1
NAME=$2
DISKSIZE_IN_GB=$3
URL=$4
if [ "$(basename $URL)" != "amd64" ] ; then
IMAGE=$(pwd)/$(basename $URL)
IMAGE_MNT="/media/cd-$NAME.iso"
else
KERNEL=linux
INITRD=initrd.gz
fi
#
# define workspace + results
#
rm -rf results
mkdir -p results
WORKSPACE=$(pwd)
RESULTS=$WORKSPACE/results
cleanup_all() {
set +x
set +e
cd $RESULTS
echo -n "Last screenshot: "
(ls -t1 snapshot* | head -1) || true
#
# create video
#
ffmpeg2theora --videobitrate 700 --no-upscaling snapshot_%06d.ppm --framerate 12 --max_size 800x600 -o cd-test-$NAME.ogv
rm snapshot_??????.ppm
# rename .bak files back to .ppm
for i in *.bak ; do
mv $i ${i%.bak}.ppm
done
set -x
#
# kill qemu and image
#
sudo kill -9 $(ps fax | grep -v grep | grep qemu-system | grep ${NAME}-preseed.cfg 2>/dev/null | cut -d "?" -f1) || true
sleep 0.3s
rm $WORKSPACE/$NAME.raw
#
# cleanup
#
sudo umount $IMAGE_MNT
}
bootstrap() {
cd $WORKSPACE
echo "Creating raw disk image with ${DISKSIZE_IN_GB}g now."
qemu-img create -f raw $NAME.raw ${DISKSIZE_IN_GB}g
echo "Doing cd tests for $NAME now."
case $NAME in
wheezy-debian-edu-workstation)
# FIXME: this obviously needs to be moved to a function
echo "Preseeding used:"
echo
curl -s http://localhost/userContent/${NAME}-preseed.cfg | grep -v ^# |grep -v "^$"
echo
echo "Starting QEMU now:"
sudo qemu-system-x86_64 -cdrom $IMAGE -drive file=$NAME.raw,index=0,media=disk,cache=writeback -boot d -m 1024 -display vnc=$DISPLAY --kernel $IMAGE_MNT/install.amd/vmlinuz --append "auto=true priority=critical locale=en_US keymap=us url=http://10.0.2.2/userContent/${NAME}-preseed.cfg video=vesa:ywrap,mtrr vga=788 initrd=/install.amd/gtk/initrd.gz -- quiet" --initrd $IMAGE_MNT/install.amd/gtk/initrd.gz &
;;
squeeze-test-debian-edu-standalone)
echo "Preseeding used:"
echo
curl -s http://localhost/userContent/${NAME}-preseed.cfg | grep -v ^# |grep -v "^$"
echo
echo "Starting QEMU now:"
sudo qemu-system-x86_64 -cdrom $IMAGE -drive file=$NAME.raw,index=0,media=disk,cache=writeback -boot d -m 1024 -display vnc=$DISPLAY --kernel $IMAGE_MNT/install.amd/vmlinuz --append "auto=true priority=critical locale=en_US console-keymaps-at/keymap=us url=http://10.0.2.2/userContent/${NAME}-preseed.cfg video=vesa:ywrap,mtrr vga=788 initrd=/install.amd/gtk/initrd.gz -- quiet" --initrd $IMAGE_MNT/install.amd/gtk/initrd.gz &
;;
wheezy-lxde)
echo "Preseeding used:"
echo
curl -s http://localhost/userContent/${NAME}-preseed.cfg | grep -v ^# |grep -v "^$"
echo
echo "Starting QEMU now:"
sudo qemu-system-x86_64 -drive file=$NAME.raw,index=0,media=disk,cache=writeback -boot c -m 1024 -display vnc=$DISPLAY --kernel $KERNEL --append "auto=true priority=critical desktop=lxde locale=en_US keymap=us url=http://10.0.2.2/userContent/${NAME}-preseed.cfg video=vesa:ywrap,mtrr vga=788 --" --initrd $INITRD &
;;
*) echo "unsupported distro."
exit 1
;;
esac
}
monitor_installation() {
cd $RESULTS
sleep 4
echo "Taking screenshots every 2 seconds now, until the installation is finished (or qemu ends for other reasons) or 6h have passed or if the installation seems to hang."
echo
NR=0
MAX_RUNS=10800
while [ $NR -lt $MAX_RUNS ] ; do
set +x
#
# break if qemu-system has finished
#
if [ $(ps fax | grep -v grep | grep qemu-system | grep ${NAME}-preseed.cfg 2>/dev/null | wc -l) -eq 0 ] ; then
break
fi
vncsnapshot -quiet -allowblank $DISPLAY snapshot_$(printf "%06d" $NR).jpg 2>/dev/null
convert snapshot_$(printf "%06d" $NR).jpg snapshot_$(printf "%06d" $NR).ppm
rm snapshot_$(printf "%06d" $NR).jpg
# give signal we are still running
if [ $(($NR % 15)) -eq 0 ] ; then
date
fi
# press ctrl-key to avoid screensaver kicking in
if [ $(($NR % 150)) -eq 0 ] ; then
vncdo -s $DISPLAY key ctrl
fi
# if this screenshot is the same as the one 400 screenshots ago, let stop this
if [ $(($NR % 100)) -eq 0 ] && [ $NR -gt 400 ] ; then
# from help let: "Exit Status: If the last ARG evaluates to 0, let returns 1; let returns 0 otherwise."
let OLD=NR-400
set -x
if diff -q snapshot_$(printf "%06d" $NR).ppm snapshot_$(printf "%06d" $OLD).ppm ; then
echo ERROR snapshot_$(printf "%06d" $NR).ppm snapshot_$(printf "%06d" $OLD).ppm match, ending installation.
cp snapshot_$(printf "%06d" $NR).ppm snapshot_$(printf "%06d" $NR).ppm.bak
cp snapshot_$(printf "%06d" $OLD).ppm snapshot_$(printf "%06d" $OLD).ppm.bak
ls -la snapshot_$(printf "%06d" $NR).ppm snapshot_$(printf "%06d" $OLD).ppm
figlet "Installation hangs."
break
fi
set +x
fi
let NR=NR+1
sleep 2
done
set -x
if [ $NR -eq $MAX_RUNS ] ; then
echo Warning: running for 6h, forceing termination.
fi
}
trap cleanup_all INT TERM EXIT
#
# if there is a CD image...
#
if [ ! -z $IMAGE ] ; then
# Only download if newer image is avaiable
CURLOPTS=""
if [ -f $IMAGE ] ; then
CURLOPTS="-z $IMAGE"
fi
curl $CURLOPTS -o $IMAGE $URL
sudo mkdir -p $IMAGE_MNT
mount | grep -v grep | grep $IMAGE_MNT && sudo umount -l $IMAGE_MNT
sleep 1
sudo mount -o loop,ro $IMAGE $IMAGE_MNT
else
#
# else netboot gtk
#
# only download if $KERNEL is older than a week...
if test $(find $KERNEL -mmin +9500) || ! test -f $KERNEL ; then
curl $URL/$KERNEL > $KERNEL
curl $URL/$INITRD > $INITRD
fi
fi
bootstrap
monitor_installation
cleanup_all
trap - INT TERM EXIT
|