source: trunk/tools/build2qemu @ 588

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

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

  • Property svn:executable set to *
File size: 1.8 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/mkdeliv
56EOF
57chmod 755 $TMP/mkmondo
58
59cd $TOOLHOME/..
60tar cfz $TMP/mkmondo.tar.gz $TOOLHOME $TMP/mkmondo $TOPDIR/${VER}-$TAG
61
62for m in $VMS; do
63    vmp=0
64    if [ ! -f /users/qemu/$m.qemu ]; then
65            echo "VM unaccessible. Verify NFS mount"
66            rm -rf $TMP
67            exit -1
68    fi
69    ps auxww | grep qemu | grep -v grep | grep -q /users/qemu/$m.qemu
70    export sp=2222
71    if [ $? -ne 0 ]; then
72        # Virtual machine alreday started
73        vmp=1
74        $TOOLHOME/mkqemu $m &
75        sleep 300
76    fi
77    scp -P $sp $TMP/mkmondo.tar.gz bruno@localhost:
78    ssh -p $sp bruno@localhost "cd / ; tar xfz ~bruno/mkmondo.tar.gz ; $TMP/mkmondo " | tee $TMP/mkvm.log
79    #ssh -p $sp bruno@localhost "cd / ; tar xfz ~bruno/mkmondo.tar.gz ; $TMP/mkmondo ; rm -f $TMP" | tee $TMP/mkvm.log
80    if [ $vmp -eq 1 ]; then
81        ssh -p $sp root@localhost "halt -p"
82        sleep 300
83        proces=`ps auxww | grep qemu | grep -v grep | grep -q /users/qemu/$m.qemu | awk '{print $2}'`
84        if [ "$proces" != "" ]; then
85            kill $proces
86        fi
87    fi
88done
89
90# Should be removed at the end
91rm -rf $TMP
Note: See TracBrowser for help on using the repository browser.