summaryrefslogtreecommitdiffstats
path: root/ci/envs/host-install-qemu.sh
blob: 18886ea53846ff3e6d1a588a4283b8e266384a50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash

###############################################################################
## Copyright (c) 2016 Intel Corp.
##
## All rights reserved. This program and the accompanying materials
## are made available under the terms of the Apache License, Version 2.0
## which accompanies this distribution, and is available at
## http://www.apache.org/licenses/LICENSE-2.0
###############################################################################

source utils.sh
source host-config

QEMU_VERSION=$( getQemuVersion )

if [ -z $QEMU_VERSION ];then
   echo "qemu RPM not found"
   exit 1
fi
rpmdir=${1:-"/root/workspace/rpm/"}
rpmpat="qemu-${QEMU_VERSION}*.rpm"

install_qemu () {
    # Removing Existing qemu rpms
    qemu_rpm=$(rpm -qa | grep 'qemu')
    echo "Removing Existing qemu packages"
    rpm -ev $qemu_rpm
    # Install the qemu rpm
    filenum=`ls -l ${rpmdir}/${rpmpat} |wc -l`
    if [ $filenum -eq 0 ]
    then
        echo "No qemu rpm found in workspace/rpm"
        exit 1
    elif [ $filenum -gt 1 ]
    then
        echo "Multiple qemu rpm found in workspace/rpm"
        exit 1
    else
       qrpm=`find "${rpmdir}" -name "${rpmpat}"`
        rpm -ihv $qrpm
    fi
}
install_qemu