1 | #!/bin/bash
|
---|
2 | #
|
---|
3 | # $Id$
|
---|
4 | #
|
---|
5 | # Script to test packages on various distributions with qemu
|
---|
6 | #
|
---|
7 |
|
---|
8 | # Syntax: test2qemu [[vm1]..[vmx]]
|
---|
9 |
|
---|
10 | (
|
---|
11 | dname=`dirname $0`
|
---|
12 | prem=`echo $dname |cut -c1`
|
---|
13 | if [ _${prem} = _"/" ]; then
|
---|
14 | export TOOLHOME=$dname
|
---|
15 | else
|
---|
16 | export TOOLHOME=${PWD}/$dname
|
---|
17 | fi
|
---|
18 |
|
---|
19 | . $TOOLHOME/common-env
|
---|
20 | . $TOOLHOME/distro-env
|
---|
21 |
|
---|
22 | if [ _"$1" = _"" ]; then
|
---|
23 | export VMS=`cat ${TOOLHOME}/DISTROS`
|
---|
24 | single=0
|
---|
25 | else
|
---|
26 | export VMS="$*"
|
---|
27 | single=1
|
---|
28 | fi
|
---|
29 |
|
---|
30 | for m in $VMS; do
|
---|
31 | echo "Working on $m"
|
---|
32 | vmp=0
|
---|
33 | if [ ! -f /users/qemu/pxe.qemu ]; then
|
---|
34 | echo "VM pxe unaccessible. Verify NFS mount"
|
---|
35 | rm -rf $MONDOTMP
|
---|
36 | exit -1
|
---|
37 | fi
|
---|
38 | if [ _"$sp" = _"" ]; then
|
---|
39 | export sp=2222
|
---|
40 | fi
|
---|
41 | ps auxww | grep qemu | grep -v grep | grep -q /users/qemu/pxe-$m.qemu
|
---|
42 | if [ $? -ne 0 ]; then
|
---|
43 | # Virtual machine not alreday started
|
---|
44 | vmp=1
|
---|
45 | sudo mkdir -p /pub/users/svg/mnt
|
---|
46 | sudo mount -o loop /pub/users/svg/mondo/images/test-mondo-$m /pub/users/svg/mnt
|
---|
47 | cp -a /pub/users/svg/mnt/vmlinuz /users/qemu/pxe/$m
|
---|
48 | cp -a /pub/users/svg/mnt/initrd.img /users/qemu/pxe/$m.img
|
---|
49 | sudo umount /pub/users/svg/mnt
|
---|
50 | cp /users/qemu/pxe.qemu /users/qemu/pxe-$m.qemu
|
---|
51 | export QEMUOPT="-kernel /users/qemu/pxe/$m -initrd /users/qemu/pxe/$m.img -append 'load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=65536 rw root=/dev/ram iso_mode pxe prefix=test-mondo-$m ipconf=eth0:dhcp nfsmount=flecha.home.musique-ancienne.org:/users/svg/mondo/images'"
|
---|
52 | # ramdisk_blocksize=1024
|
---|
53 | $TOOLHOME/mkqemu pxe-$m &
|
---|
54 | sleep 300
|
---|
55 | fi
|
---|
56 | ssh -q -p $sp bruno@localhost "cd / ; rm -rf ~bruno/mondo ~bruno/RPMS/BUILD/* ~bruno/RPMS/tmp/* /tmp/* ; tar xfz ~bruno/test-mondo.tar.gz ; $MONDOTMP/test-mondo " | tee $MONDOTMP/mkvm.log
|
---|
57 | if [ $vmp -eq 1 ]; then
|
---|
58 | ssh -q -p $sp root@localhost "halt -p"
|
---|
59 | sleep 300
|
---|
60 | proces=`ps auxww | grep qemu | grep -v grep | grep /users/qemu/$m.qemu | awk '{print $2}'`
|
---|
61 | if [ "$proces" != "" ]; then
|
---|
62 | kill $proces
|
---|
63 | sleep 10
|
---|
64 | fi
|
---|
65 | fi
|
---|
66 | done
|
---|
67 |
|
---|
68 | # Should be removed at the end
|
---|
69 | rm -rf $MONDOTMP
|
---|
70 | ) 2>&1 | tee /tmp/test2qemu.log
|
---|