[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] | 16 | dname=`dirname $0`
|
---|
| 17 | prem=`echo $dname |cut -c1`
|
---|
| 18 | if [ ${prem} == "/" ]; then
|
---|
| 19 | export TOOLHOME=$dname
|
---|
| 20 | else
|
---|
| 21 | export TOOLHOME=${PWD}/$dname
|
---|
[440] | 22 | fi
|
---|
| 23 |
|
---|
[572] | 24 |
|
---|
[553] | 25 | . $TOOLHOME/common-env
|
---|
| 26 | . $TOOLHOME/distro-env
|
---|
| 27 |
|
---|
| 28 | # We need to get $VER and $TAG
|
---|
| 29 | if [ "$1" = "" ]; then
|
---|
| 30 | LAST=`cat ${TOPDIR}/LAST`
|
---|
[440] | 31 | else
|
---|
[553] | 32 | LAST=$1
|
---|
| 33 | shift
|
---|
[440] | 34 | fi
|
---|
[553] | 35 | VER=`echo $LAST | cut -d- -f1`
|
---|
| 36 | TAG=`echo $LAST | cut -d- -f2`
|
---|
| 37 | echo "Working on ${VER}-$TAG"
|
---|
[440] | 38 |
|
---|
[553] | 39 | if [ _"$1" == _"" ]; then
|
---|
[556] | 40 | export VMS=`cat ${TOOLHOME}/DISTROS`
|
---|
[596] | 41 | single=0
|
---|
[553] | 42 | else
|
---|
[596] | 43 | export VMS="$*"
|
---|
| 44 | single=1
|
---|
[553] | 45 | fi
|
---|
| 46 |
|
---|
[572] | 47 | mkdir -p $TMP
|
---|
[553] | 48 | cat > $TMP/mkmondo << EOF
|
---|
[440] | 49 | #!/bin/bash
|
---|
| 50 |
|
---|
| 51 | export LANG="C"
|
---|
| 52 | export LANGUAGE="C"
|
---|
| 53 | export LC_ALL="C"
|
---|
[553] | 54 | export TOOLHOME=$TOOLHOME
|
---|
[440] | 55 |
|
---|
[596] | 56 | $TOOLHOME/build2pkg $LAST < /dev/null
|
---|
| 57 | $TOOLHOME/pkg2ftp $LAST
|
---|
[440] | 58 | EOF
|
---|
[553] | 59 | chmod 755 $TMP/mkmondo
|
---|
[440] | 60 |
|
---|
[596] | 61 | if [ $single -eq 0 ]; then
|
---|
| 62 | $TOOLHOME/file2ftp
|
---|
| 63 | fi
|
---|
[553] | 64 | cd $TOOLHOME/..
|
---|
[572] | 65 | tar cfz $TMP/mkmondo.tar.gz $TOOLHOME $TMP/mkmondo $TOPDIR/${VER}-$TAG
|
---|
[553] | 66 |
|
---|
| 67 | for m in $VMS; do
|
---|
[440] | 68 | vmp=0
|
---|
[556] | 69 | if [ ! -f /users/qemu/$m.qemu ]; then
|
---|
[440] | 70 | echo "VM unaccessible. Verify NFS mount"
|
---|
[572] | 71 | rm -rf $TMP
|
---|
[440] | 72 | exit -1
|
---|
| 73 | fi
|
---|
[721] | 74 | if [ _"$sp" = _"" ]; then
|
---|
| 75 | export sp=2222
|
---|
| 76 | fi
|
---|
[556] | 77 | ps auxww | grep qemu | grep -v grep | grep -q /users/qemu/$m.qemu
|
---|
[440] | 78 | if [ $? -ne 0 ]; then
|
---|
| 79 | # Virtual machine alreday started
|
---|
| 80 | vmp=1
|
---|
[556] | 81 | $TOOLHOME/mkqemu $m &
|
---|
[519] | 82 | sleep 300
|
---|
[440] | 83 | fi
|
---|
[755] | 84 | scp -P $sp $TMP/mkmondo.tar.gz ~/.rpmmacros ~/.rpmrc bruno@localhost:
|
---|
[599] | 85 | rdate=`date "+%m%d%H%M"`
|
---|
| 86 | ssh -p $sp root@localhost "date $rdate"
|
---|
| 87 | ssh -p $sp bruno@localhost "cd / ; rm -rf ~bruno/mondo ~bruno/RPMS/BUILD/* ~bruno/RPMS/tmp/* /tmp/* ; tar xfz ~bruno/mkmondo.tar.gz ; $TMP/mkmondo " | tee $TMP/mkvm.log
|
---|
[572] | 88 | #ssh -p $sp bruno@localhost "cd / ; tar xfz ~bruno/mkmondo.tar.gz ; $TMP/mkmondo ; rm -f $TMP" | tee $TMP/mkvm.log
|
---|
[440] | 89 | if [ $vmp -eq 1 ]; then
|
---|
[441] | 90 | ssh -p $sp root@localhost "halt -p"
|
---|
[519] | 91 | sleep 300
|
---|
[599] | 92 | proces=`ps auxww | grep qemu | grep -v grep | grep /users/qemu/$m.qemu | awk '{print $2}'`
|
---|
[519] | 93 | if [ "$proces" != "" ]; then
|
---|
| 94 | kill $proces
|
---|
[603] | 95 | sleep 10
|
---|
[519] | 96 | fi
|
---|
[440] | 97 | fi
|
---|
| 98 | done
|
---|
[572] | 99 |
|
---|
| 100 | # Should be removed at the end
|
---|
| 101 | rm -rf $TMP
|
---|
[757] | 102 | ) 2>&1 | tee /tmp/build2qemu.log
|
---|