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