source: MondoRescue/trunk/tools/build2qemu @ 1043

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

merge -r978:1042 $SVN_M/branches/stable

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