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