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

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

Syntax review (== suppresse for stricter POSIX conformance with =)

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