source: branches/2.2.4/tools/build2qemu @ 1504

Last change on this file since 1504 was 1504, checked in by Bruno Cornec, 13 years ago

Do not launch 64 bits versions if called with specific VMs

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