source: MondoRescue/branches/stable/tools/build2qemu@ 924

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

TAG is now per package and not shared anymore + build process adapted

  • Property svn:executable set to *
File size: 2.1 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
13# Syntax: build2qemu [version-tag [vm1]..|vmx]]
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
[553]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`
[440]30else
[553]31 LAST=$1
32 shift
[440]33fi
[553]34VER=`echo $LAST | cut -d- -f1`
35TAG=`echo $LAST | cut -d- -f2`
36echo "Working on ${VER}-$TAG"
[440]37
[553]38if [ _"$1" == _"" ]; then
[556]39 export VMS=`cat ${TOOLHOME}/DISTROS`
[596]40 single=0
[553]41else
[596]42 export VMS="$*"
43 single=1
[553]44fi
45
[882]46cat > $MONDOTMP/mkmondo << EOF
[440]47#!/bin/bash
48
49export LANG="C"
50export LANGUAGE="C"
51export LC_ALL="C"
[553]52export TOOLHOME=$TOOLHOME
[440]53
[596]54$TOOLHOME/build2pkg $LAST < /dev/null
55$TOOLHOME/pkg2ftp $LAST
[440]56EOF
[882]57chmod 755 $MONDOTMP/mkmondo
[440]58
[596]59if [ $single -eq 0 ]; then
60 $TOOLHOME/file2ftp
61fi
[553]62
[888]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
[553]69for m in $VMS; do
[440]70 vmp=0
[556]71 if [ ! -f /users/qemu/$m.qemu ]; then
[440]72 echo "VM unaccessible. Verify NFS mount"
[882]73 rm -rf $MONDOTMP
[440]74 exit -1
75 fi
[721]76 if [ _"$sp" = _"" ]; then
77 export sp=2222
78 fi
[556]79 ps auxww | grep qemu | grep -v grep | grep -q /users/qemu/$m.qemu
[440]80 if [ $? -ne 0 ]; then
81 # Virtual machine alreday started
82 vmp=1
[556]83 $TOOLHOME/mkqemu $m &
[519]84 sleep 300
[440]85 fi
[882]86 scp -P $sp $MONDOTMP/mkmondo.tar.gz ~/.rpmmacros ~/.rpmrc bruno@localhost:
[599]87 rdate=`date "+%m%d%H%M"`
88 ssh -p $sp root@localhost "date $rdate"
[882]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
[440]90 if [ $vmp -eq 1 ]; then
[441]91 ssh -p $sp root@localhost "halt -p"
[519]92 sleep 300
[599]93 proces=`ps auxww | grep qemu | grep -v grep | grep /users/qemu/$m.qemu | awk '{print $2}'`
[519]94 if [ "$proces" != "" ]; then
95 kill $proces
[603]96 sleep 10
[519]97 fi
[440]98 fi
99done
[572]100
101# Should be removed at the end
[882]102rm -rf $MONDOTMP
[757]103) 2>&1 | tee /tmp/build2qemu.log
Note: See TracBrowser for help on using the repository browser.