source: branches/2.0.9/tools/build2qemu @ 756

Last change on this file since 756 was 756, checked in by Bruno Cornec, 14 years ago

merge -r754:755 $SVN_M/branches/stable

  • Property svn:executable set to *
File size: 2.1 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
15exec > /tmp/build2qemu.log 2>&1
16
17dname=`dirname $0`
18prem=`echo $dname |cut -c1`
19if [ ${prem} == "/" ]; then
20    export TOOLHOME=$dname
21else
22    export TOOLHOME=${PWD}/$dname
23fi
24
25
26. $TOOLHOME/common-env
27. $TOOLHOME/distro-env
28
29# We need to get $VER and $TAG
30if [ "$1" = "" ]; then
31    LAST=`cat ${TOPDIR}/LAST`
32else
33    LAST=$1
34    shift
35fi
36VER=`echo $LAST | cut -d- -f1`
37TAG=`echo $LAST | cut -d- -f2`
38echo "Working on ${VER}-$TAG"
39
40if [ _"$1" == _"" ]; then
41    export VMS=`cat ${TOOLHOME}/DISTROS` 
42    single=0
43else
44    export VMS="$*"
45    single=1
46fi
47
48mkdir -p $TMP
49cat > $TMP/mkmondo << EOF
50#!/bin/bash
51
52export LANG="C"
53export LANGUAGE="C"
54export LC_ALL="C"
55export TOOLHOME=$TOOLHOME
56
57$TOOLHOME/build2pkg $LAST < /dev/null
58$TOOLHOME/pkg2ftp $LAST
59EOF
60chmod 755 $TMP/mkmondo
61
62if [ $single -eq 0 ]; then
63    $TOOLHOME/file2ftp
64fi
65cd $TOOLHOME/..
66tar cfz $TMP/mkmondo.tar.gz $TOOLHOME $TMP/mkmondo $TOPDIR/${VER}-$TAG
67
68for m in $VMS; do
69    vmp=0
70    if [ ! -f /users/qemu/$m.qemu ]; then
71            echo "VM unaccessible. Verify NFS mount"
72            rm -rf $TMP
73            exit -1
74    fi
75    if [ _"$sp" = _"" ]; then
76        export sp=2222
77    fi
78    ps auxww | grep qemu | grep -v grep | grep -q /users/qemu/$m.qemu
79    if [ $? -ne 0 ]; then
80        # Virtual machine alreday started
81        vmp=1
82        $TOOLHOME/mkqemu $m &
83        sleep 300
84    fi
85    scp -P $sp $TMP/mkmondo.tar.gz ~/.rpmmacros ~/.rpmrc bruno@localhost:
86    rdate=`date "+%m%d%H%M"`
87    ssh -p $sp root@localhost "date $rdate"
88    ssh -p $sp bruno@localhost "cd / ; rm -rf ~bruno/mondo ~bruno/RPMS/BUILD/* ~bruno/RPMS/tmp/* /tmp/* ; tar xfz ~bruno/mkmondo.tar.gz ; $TMP/mkmondo " | tee $TMP/mkvm.log
89    #ssh -p $sp bruno@localhost "cd / ; tar xfz ~bruno/mkmondo.tar.gz ; $TMP/mkmondo ; rm -f $TMP" | tee $TMP/mkvm.log
90    if [ $vmp -eq 1 ]; then
91        ssh -p $sp root@localhost "halt -p"
92        sleep 300
93        proces=`ps auxww | grep qemu | grep -v grep | grep /users/qemu/$m.qemu | awk '{print $2}'`
94        if [ "$proces" != "" ]; then
95            kill $proces
96            sleep 10
97        fi
98    fi
99done
100
101# Should be removed at the end
102rm -rf $TMP
Note: See TracBrowser for help on using the repository browser.