Patchwork [5/5] guest tools: installer for qemu-ga

login
register
mail settings
Submitter Michael Roth
Date Aug. 22, 2011, 5:09 p.m.
Message ID <1314032960-23474-6-git-send-email-mdroth@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/110985/
State New
Headers show

Comments

Michael Roth - Aug. 22, 2011, 5:09 p.m.
Detects host distro/architecture, then chooses the appropriate binary
and init scripts to install. Support for more distros will be added as
they're tested. Currently RHEL6, RHEL5, Fedora 15, Ubuntu 10.04, and
Ubuntu 10.10 are known to be supported with qemu-ga binaries generated
on a RHEL5 build host. RHEL6 builds will not work on RHEL5 due to glibc
issues. These idiosyncrasies will need to be documented once everything
is fleshed out.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 guest-tools-iso/projects/qemu-ga/install.linux |   61 ++++++++++++++++++++++++
 1 files changed, 61 insertions(+), 0 deletions(-)
 create mode 100755 guest-tools-iso/projects/qemu-ga/install.linux

Patch

diff --git a/guest-tools-iso/projects/qemu-ga/install.linux b/guest-tools-iso/projects/qemu-ga/install.linux
new file mode 100755
index 0000000..1f200b6
--- /dev/null
+++ b/guest-tools-iso/projects/qemu-ga/install.linux
@@ -0,0 +1,61 @@ 
+#!/bin/sh
+
+#arch=""
+#distro=""
+
+get_arch() {
+    machine=`uname --machine`
+    if [ "$machine" = "x86_64" ]; then
+        arch="x86_64"
+    elif [ "`echo $machine | sed 's/i[3456]86/x86/'`" = "x86" ]; then
+        arch="x86"
+    else
+        echo "unsupported architecture"
+        exit 1
+    fi
+}
+
+get_distro() {
+    if [ -f /etc/redhat-release ]; then
+        distro="redhat"
+    elif [ -f /etc/fedora-release ]; then
+        distro="fedora"
+    elif [ -f /etc/debian_version ]; then
+        distro_id=`lsb_release -i | awk '{print $3}'`
+        if [ "$distro_id" = "Ubuntu" ]; then
+            distro="ubuntu"
+        else
+            distro="debian"
+        fi
+    else
+        echo "unsupported distribution"
+        exit 1
+    fi
+}
+
+get_arch
+get_distro
+
+echo detected arch: $arch
+echo detected distro: $distro
+echo installing...
+
+install -D -p -m 0755 qemu-ga.linux.$arch /usr/sbin/qemu-ga
+
+if [ "$distro" = "redhat" ] || [ "$distro" = "fedora" ]; then
+    install -D -p -m 0755 redhat/qemu-ga.init /etc/init.d/qemu-ga
+    install -D -p -m 0644 redhat/qemu-ga.sysconfig /etc/sysconfig/qemu-ga
+    /sbin/chkconfig --add qemu-ga
+    /sbin/chkconfig --level 2345 qemu-ga on
+    /sbin/service qemu-ga restart
+elif [ "$distro" = "ubuntu" ] || [ "$distro" = "debian" ]; then
+    install -D -p -m 0755 debian/qemu-ga.init /etc/init.d/qemu-ga
+    install -D -p -m 0644 debian/qemu-ga.sysconfig /etc/sysconfig/qemu-ga
+    /usr/sbin/update-rc.d qemu-ga defaults
+    /etc/init.d/qemu-ga restart
+else
+    "no associated init script for distro: $distro"
+    exit 1
+fi
+
+echo installation complete.