source: MondoRescue/branches/2.2.4/tools/build2qemu@ 1484

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

Preparation for x86_64 build with QEMU

  • Property svn:executable set to *
File size: 2.5 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
[985]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
[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=""
39if [ _"$1" == _"--pkg" ]; then
40 shift
41 c=$1
42 shift
43fi
44
[553]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
[1479]53VMS64=`echo $VMS | perl -pi -e 's/\b([A-z0-9_.]+)\b/$1_64/g'`
54
[882]55cat > $MONDOTMP/mkmondo << EOF
[440]56#!/bin/bash
57
58export LANG="C"
59export LANGUAGE="C"
60export LC_ALL="C"
[553]61export TOOLHOME=$TOOLHOME
[440]62
[985]63$TOOLHOME/build2pkg $LAST $c < /dev/null
64$TOOLHOME/pkg2ftp $LAST $c
[440]65EOF
[882]66chmod 755 $MONDOTMP/mkmondo
[440]67
[596]68if [ $single -eq 0 ]; then
69 $TOOLHOME/file2ftp
70fi
[553]71
[888]72# TOPDIR contains ../.. which causes problems to tar
73# so we need to recompute it
74cd $TOPDIR
75dir=`pwd`
76tar cfz $MONDOTMP/mkmondo.tar.gz $TOOLHOME $MONDOTMP/mkmondo $dir/${VER}-$TAG
77
[1479]78for m in $VMS $VMS64; do
[1012]79 echo "Working on $m"
[440]80 vmp=0
[556]81 if [ ! -f /users/qemu/$m.qemu ]; then
[1479]82 echo $m | grep -Eq '_64$'
83 if [ $? -eq 0 ]; then
84 echo "VM unaccessible. No x86_64 version yet probably"
85 continue
86 else
[440]87 echo "VM unaccessible. Verify NFS mount"
[882]88 rm -rf $MONDOTMP
[440]89 exit -1
[1479]90 fi
[440]91 fi
[721]92 if [ _"$sp" = _"" ]; then
93 export sp=2222
94 fi
[556]95 ps auxww | grep qemu | grep -v grep | grep -q /users/qemu/$m.qemu
[440]96 if [ $? -ne 0 ]; then
97 # Virtual machine alreday started
98 vmp=1
[556]99 $TOOLHOME/mkqemu $m &
[519]100 sleep 300
[440]101 fi
[882]102 scp -P $sp $MONDOTMP/mkmondo.tar.gz ~/.rpmmacros ~/.rpmrc bruno@localhost:
[599]103 rdate=`date "+%m%d%H%M"`
[1011]104 ssh -q -p $sp root@localhost "date $rdate"
105 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]106 if [ $vmp -eq 1 ]; then
[1011]107 ssh -q -p $sp root@localhost "halt -p"
[519]108 sleep 300
[599]109 proces=`ps auxww | grep qemu | grep -v grep | grep /users/qemu/$m.qemu | awk '{print $2}'`
[519]110 if [ "$proces" != "" ]; then
111 kill $proces
[603]112 sleep 10
[519]113 fi
[440]114 fi
115done
[572]116
117# Should be removed at the end
[882]118rm -rf $MONDOTMP
[757]119) 2>&1 | tee /tmp/build2qemu.log
Note: See TracBrowser for help on using the repository browser.