source: branches/2.2.0/tools/build2qemu @ 885

Last change on this file since 885 was 885, checked in by bruno, 13 years ago

merge -r881:884 $SVN_M/branches/stable

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