source: MondoRescue/trunk/tools/build2qemu@ 999

Last change on this file since 999 was 932, checked in by Bruno Cornec, 17 years ago

merge -r913:931 $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
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" == _"" ]; then
39 export VMS=`cat ${TOOLHOME}/DISTROS`
40 single=0
41else
42 export VMS="$*"
43 single=1
44fi
45
46cat > $MONDOTMP/mkmondo << EOF
47#!/bin/bash
48
49export LANG="C"
50export LANGUAGE="C"
51export LC_ALL="C"
52export TOOLHOME=$TOOLHOME
53
54$TOOLHOME/build2pkg $LAST < /dev/null
55$TOOLHOME/pkg2ftp $LAST
56EOF
57chmod 755 $MONDOTMP/mkmondo
58
59if [ $single -eq 0 ]; then
60 $TOOLHOME/file2ftp
61fi
62
63# TOPDIR contains ../.. which causes problems to tar
64# so we need to recompute it
65cd $TOPDIR
66dir=`pwd`
67tar cfz $MONDOTMP/mkmondo.tar.gz $TOOLHOME $MONDOTMP/mkmondo $dir/${VER}-$TAG
68
69for m in $VMS; do
70 vmp=0
71 if [ ! -f /users/qemu/$m.qemu ]; then
72 echo "VM unaccessible. Verify NFS mount"
73 rm -rf $MONDOTMP
74 exit -1
75 fi
76 if [ _"$sp" = _"" ]; then
77 export sp=2222
78 fi
79 ps auxww | grep qemu | grep -v grep | grep -q /users/qemu/$m.qemu
80 if [ $? -ne 0 ]; then
81 # Virtual machine alreday started
82 vmp=1
83 $TOOLHOME/mkqemu $m &
84 sleep 300
85 fi
86 scp -P $sp $MONDOTMP/mkmondo.tar.gz ~/.rpmmacros ~/.rpmrc bruno@localhost:
87 rdate=`date "+%m%d%H%M"`
88 ssh -p $sp root@localhost "date $rdate"
89 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
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 $MONDOTMP
103) 2>&1 | tee /tmp/build2qemu.log
Note: See TracBrowser for help on using the repository browser.