source: MondoRescue/branches/2.2.0/tools/build2qemu@ 984

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

Possibility to build only some package with qemu

  • Property svn:executable set to *
File size: 2.4 KB
RevLine 
[440]1#!/bin/bash
2#
3# $Id$
4#
[553]5# Script build packages on various distributions with qemu
[440]6#
7
[572]8#if [ _"$1" == _"" ]; then
9 #echo "Syntax: build2qemu [version-tag [vm1]..|vmx]] )"
10 #exit -1
11#fi
12
[984]13# Syntax: build2qemu [version-tag [--pkg "pkg1...pkgn"] [vm1]..|vmx]]
[572]14
[757]15(
[572]16dname=`dirname $0`
17prem=`echo $dname |cut -c1`
18if [ ${prem} == "/" ]; then
19 export TOOLHOME=$dname
20else
21 export TOOLHOME=${PWD}/$dname
[440]22fi
23
[572]24
[553]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`
[440]31else
[553]32 LAST=$1
33 shift
[440]34fi
[553]35VER=`echo $LAST | cut -d- -f1`
36TAG=`echo $LAST | cut -d- -f2`
37echo "Working on ${VER}-$TAG"
[440]38
[984]39c=""
40if [ _"$1" == _"--pkg" ]; then
41 shift
42 c=$1
43 shift
44fi
45
[553]46if [ _"$1" == _"" ]; then
[556]47 export VMS=`cat ${TOOLHOME}/DISTROS`
[596]48 single=0
[553]49else
[596]50 export VMS="$*"
51 single=1
[553]52fi
53
[885]54cat > $MONDOTMP/mkmondo << EOF
[440]55#!/bin/bash
56
57export LANG="C"
58export LANGUAGE="C"
59export LC_ALL="C"
[553]60export TOOLHOME=$TOOLHOME
[440]61
[984]62$TOOLHOME/build2pkg $LAST $c < /dev/null
63$TOOLHOME/pkg2ftp $LAST $c
[440]64EOF
[885]65chmod 755 $MONDOTMP/mkmondo
[440]66
[596]67if [ $single -eq 0 ]; then
68 $TOOLHOME/file2ftp
69fi
[553]70
[887]71# TOPDIR contains ../.. which causes problems to tar
72# so we need to recompute it
73cd $TOPDIR
74dir=`pwd`
75tar cfz $MONDOTMP/mkmondo.tar.gz $TOOLHOME $MONDOTMP/mkmondo $dir/${VER}-$TAG
76
[553]77for m in $VMS; do
[440]78 vmp=0
[556]79 if [ ! -f /users/qemu/$m.qemu ]; then
[440]80 echo "VM unaccessible. Verify NFS mount"
[885]81 rm -rf $MONDOTMP
[440]82 exit -1
83 fi
[721]84 if [ _"$sp" = _"" ]; then
85 export sp=2222
86 fi
[556]87 ps auxww | grep qemu | grep -v grep | grep -q /users/qemu/$m.qemu
[440]88 if [ $? -ne 0 ]; then
89 # Virtual machine alreday started
90 vmp=1
[556]91 $TOOLHOME/mkqemu $m &
[519]92 sleep 300
[440]93 fi
[885]94 scp -P $sp $MONDOTMP/mkmondo.tar.gz ~/.rpmmacros ~/.rpmrc bruno@localhost:
[599]95 rdate=`date "+%m%d%H%M"`
96 ssh -p $sp root@localhost "date $rdate"
[885]97 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
98 #ssh -p $sp bruno@localhost "cd / ; tar xfz ~bruno/mkmondo.tar.gz ; $MONDOTMP/mkmondo ; rm -f $MONDOTMP" | tee $MONDOTMP/mkvm.log
[440]99 if [ $vmp -eq 1 ]; then
[441]100 ssh -p $sp root@localhost "halt -p"
[519]101 sleep 300
[599]102 proces=`ps auxww | grep qemu | grep -v grep | grep /users/qemu/$m.qemu | awk '{print $2}'`
[519]103 if [ "$proces" != "" ]; then
104 kill $proces
[603]105 sleep 10
[519]106 fi
[440]107 fi
108done
[572]109
110# Should be removed at the end
[885]111rm -rf $MONDOTMP
[757]112) 2>&1 | tee /tmp/build2qemu.log
Note: See TracBrowser for help on using the repository browser.