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

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