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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
#!/bin/bash
# codename : viviane
# Virtualized
# Integrated
# Verification of
# Installer with
# Automated
# Networked
# Eyeballs
#
# adapted from http://kashyapc.wordpress.com/2011/08/18/unattended-guest-install-with-a-local-kickstart/
#VERSION="cauldron"
#DIRECTORY="/pub/linux/Mageia/distrib/$VERSION"
VERSION="2010.2"
DIRECTORY="/pub/linux/MandrivaLinux/official/$VERSION"
SERVER="distrib-coffee.ipsl.jussieu.fr"
TREE="http://$SERVER$DIRECTORY"
function auto_install_test() {
ARCH=$1
PACKAGE=$2
NAME=viviane_${ARCH}_${PACKAGE}_$(date +%Y_%m_%d)
TMP_DIR=$(mktemp -d /tmp/viviane_XXXXX)
chmod go+rx $TMP_DIR
date >> /tmp/viviane.log
echo "test of $NAME started" >> /tmp/viviane.log
# based on http://www.zarb.org/~guillomovitch/installation_automatique.html
# user that is created must be in dialout, to be able to send the message
# to the host on ttyS0 ( since consolekit do not handle this so far )
cat > $TMP_DIR/auto_inst.cfg.pl <<EOF
#!/usr/bin/perl -cw
\$o = {
'timezone' => {
'ntp' => undef,
'timezone' => 'Europe/Paris',
'UTC' => 1
},
'default_packages' => [
'urpmi',
'basesystem',
'man-pages',
'info',
'curl',
'dhcp-client',
'iputils',
'autologin',
'$PACKAGE',
],
'users' => [
{
'icon' => 'default',
'realname' => 'Myrddin Wyllt',
'uid' => undef,
'groups' => ['dialout'],
'name' => 'merlin',
'shell' => '/bin/bash',
'gid' => undef
}
],
'locale' => {
'country' => 'us',
'lang' => 'en_US',
'langs' => {
'en_US' => 1
},
'utf8' => 1
},
'net' => {
'resolv' => {
'DOMAINNAME' => 'test',
'dnsServer' => '192.168.122.1',
'DOMAINNAME2' => undef,
'dnsServer2' => undef,
'DOMAINNAME3' => undef,
'dnsServer3' => undef
},
'network' => {
'NETWORKING' => 'yes',
'GATEWAY' => '192.168.122.1',
'FORWARD_IPV4' => 'false',
'HOSTNAME' => '$NAME.test',
},
'ethernet' => {},
'ifcfg' => {
'eth0' => {
'BROADCAST' => '',
'isUp' => 1,
'BOOTPROTO' => 'dhcp',
'isPtp' => '',
'NETWORK' => '',
'HWADDR' => undef,
'DEVICE' => 'eth0',
'METRIC' => 10
}
},
'net_interface' => 'eth0',
'type' => 'ethernet',
'PROFILE' => 'default'
},
'authentication' => {
'shadow' => 1,
'blowfish' => 1
},
'partitions' => [
{
'fs_type' => 'ext4',
'mntpoint' => '/',
'size' => 7700000
},
{
'fs_type' => 'swap',
'mntpoint' => 'swap',
'size' => 256000
},
],
'partitioning' => {
'auto_allocate' => 1,
'clearall' => 1,
'eraseBadPartitions' => 1
},
'superuser' => {
'password' => 'root',
'realname' => 'root',
'uid' => '0',
'shell' => '/bin/bash',
'home' => '/root',
'gid' => '0'
},
'security' => 1,
'interactiveSteps' => [
# 'doPartitionDisks',
# 'formatPartitions'
],
'autoExitInstall' => 1,
'keyboard' => {
'GRP_TOGGLE' => '',
'KEYBOARD' => 'us'
},
'postInstall' => q(
cat > /usr/local/bin/viviane_notify.sh <<SCRIPT
#!/bin/bash
echo "install_ok" >> /dev/ttyS0
SCRIPT
chmod ugo+rx /usr/local/bin/viviane_notify.sh
cat > /etc/xdg/autostart/viviane_notify.desktop <<DESKTOP
[Desktop Entry]
Exec=/usr/local/bin/viviane_notify.sh
Name=Viviane notification
Terminal=false
Type=Application
StartupNotify=false
NoDisplay=true
X-KDE-autostart-after=panel
DESKTOP
cat > /etc/sysconfig/autologin <<AUTO
USER=merlin
AUTOLOGIN=yes
AUTO
),
'rpmsrate_flags_chosen' => {
},
'compssListLevel' => 3,
'firewall_ports' => undef,
'keep_unrequested_dependencies' => 0,
};
EOF
# check the file, in case someone modify it
perl -cw $TMP_DIR/auto_inst.cfg.pl
if [[ $? -ne 0 ]] ; then
echo "Incorrect auto_inst.cfg.pl file"
exit
fi
# needed to let qemu write here
touch $TMP_DIR/log
setfacl -m u:qemu:rw $TMP_DIR/log
# --os-type and --os-variant are likely needed to find the
# proper layout on the mirror, do not modify it
# required a patched version of virtinst
# ( https://bugzilla.redhat.com/show_bug.cgi?id=733121 )
# Also, the documentation about auto installation is wrong on mandriva
# wiki, since short form "net" is not the same as "netw"
virt-install --connect=qemu:///system \
--network=network=default \
--initrd-inject=$TMP_DIR/auto_inst.cfg.pl \
--extra-args="text kickstart=/auto_inst.cfg.pl automatic=met:http,network:dhcp,ser:$SERVER,dir:$DIRECTORY/$ARCH,hostname:$NAME.test" \
--name=${NAME} \
--disk /var/lib/libvirt/images/${NAME}.img,size=8 \
--ram 1024 \
--vcpus=1 \
--check-cpu \
--location=$TREE/$ARCH \
--serial=file,path=$TMP_DIR/log \
--hvm \
--accelerate \
--os-type=linux \
--os-variant=mandriva2010 \
--wait=30 \
--noautoconsole \
--quiet
# let the system do the first boot
sleep 120
if grep -q install_ok $TMP_DIR/log ; then
virsh --connect qemu:///system destroy $NAME
virsh --connect qemu:///system undefine $NAME
rm -Rf $TMP_DIR
else
# FIXME requires a recent version of libvirt for screenshot
# virsh --connect qemu:///system screenshot $NAME /tmp/$NAME.png
# virsh --connect qemu:///system suspend $NAME
# FIXME better message ( with url of the screenshot )
#echo "test of $NAME failed" | mail foo -s "automated install test report"
date >> /tmp/viviane.log
echo "test of $NAME ( $TMP_DIR ) failed" >> /tmp/viviane.log
cat $TMP_DIR/log >> /tmp/viviane.log
fi
}
auto_install_test i586 task-kde4
#for a in i586 x86_64; do
# for p in task-kde4 task-gnome; do
# auto_install_test $a $p
# done
#done
|