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