source: trunk/tools/build2qemu @ 592

Last change on this file since 592 was 592, checked in by bcornec, 13 years ago

merge -r 587:591 $SVN_M/branches/stable

  • Property svn:executable set to *
File size: 1.9 KB
Line 
1#!/bin/bash
2#
3# $Id$
4#
5# Script build packages on various distributions with qemu
6#
7
8#if [ _"$1" == _"" ]; then
9    #echo "Syntax: build2qemu [version-tag [vm1]..|vmx]] )"
10    #exit -1
11#fi
12
13# Syntax: build2qemu [version-tag [vm1]..|vmx]]
14
15umask 022
16dname=`dirname $0`
17prem=`echo $dname |cut -c1`
18if [ ${prem} == "/" ]; then
19    export TOOLHOME=$dname
20else
21    export TOOLHOME=${PWD}/$dname
22fi
23
24
25. $TOOLHOME/common-env
26. $TOOLHOME/distro-env
27
28# We need to get $VER and $TAG
29if [ "$1" = "" ]; then
30    LAST=`cat ${TOPDIR}/LAST`
31else
32    LAST=$1
33    shift
34fi
35VER=`echo $LAST | cut -d- -f1`
36TAG=`echo $LAST | cut -d- -f2`
37echo "Working on ${VER}-$TAG"
38
39if [ _"$1" == _"" ]; then
40    export VMS=`cat ${TOOLHOME}/DISTROS` 
41else
42    export VMS="$1"
43fi
44
45mkdir -p $TMP
46cat > $TMP/mkmondo << EOF
47#!/bin/bash
48
49export LANG="C"
50export LANGUAGE="C"
51export LC_ALL="C"
52export TOOLHOME=$TOOLHOME
53
54$TOOLHOME/build2pkg $LAST
55$TOOLHOME/pkg2ftp
56EOF
57chmod 755 $TMP/mkmondo
58
59$TOOLHOME/files2ftp
60cd $TOOLHOME/..
61tar cfz $TMP/mkmondo.tar.gz $TOOLHOME $TMP/mkmondo $TOPDIR/${VER}-$TAG
62
63for m in $VMS; do
64    vmp=0
65    if [ ! -f /users/qemu/$m.qemu ]; then
66            echo "VM unaccessible. Verify NFS mount"
67            rm -rf $TMP
68            exit -1
69    fi
70    ps auxww | grep qemu | grep -v grep | grep -q /users/qemu/$m.qemu
71    export sp=2222
72    if [ $? -ne 0 ]; then
73        # Virtual machine alreday started
74        vmp=1
75        $TOOLHOME/mkqemu $m &
76        sleep 300
77    fi
78    scp -P $sp $TMP/mkmondo.tar.gz bruno@localhost:
79    ssh -p $sp bruno@localhost "cd / ; tar xfz ~bruno/mkmondo.tar.gz ; $TMP/mkmondo " | tee $TMP/mkvm.log
80    #ssh -p $sp bruno@localhost "cd / ; tar xfz ~bruno/mkmondo.tar.gz ; $TMP/mkmondo ; rm -f $TMP" | tee $TMP/mkvm.log
81    if [ $vmp -eq 1 ]; then
82        ssh -p $sp root@localhost "halt -p"
83        sleep 300
84        proces=`ps auxww | grep qemu | grep -v grep | grep -q /users/qemu/$m.qemu | awk '{print $2}'`
85        if [ "$proces" != "" ]; then
86            kill $proces
87        fi
88    fi
89done
90
91# Should be removed at the end
92rm -rf $TMP
Note: See TracBrowser for help on using the repository browser.