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