Index: trunk/src/VBox/Additions/solaris/Installer/makepackage.sh
===================================================================
--- trunk/src/VBox/Additions/solaris/Installer/makepackage.sh	(revision 7402)
+++ trunk/src/VBox/Additions/solaris/Installer/makepackage.sh	(revision 7402)
@@ -0,0 +1,35 @@
+#!/bin/sh
+#
+# innotek VirtualBox Solaris Guest Additions package creation script.
+# Usage:
+#       makespackage.sh $(PATH_TARGET)/install packagename
+
+if [ -z "$2" ]; then
+    echo "Usage: $0 installdir packagename"
+    exit 1
+fi
+
+cd "$1"
+echo 'i pkginfo=./vboxguest.pkginfo' > prototype
+echo 'i postinstall=./postinstall.sh' >> prototype
+echo 'i preremove=./preremove.sh' >> prototype
+find . -print | /usr/sfw/bin/ggrep -v -E 'prototype|makepackage.sh|vboxguest.pkginfo|postinstall.sh|preremove.sh' | pkgproto >> prototype
+
+/usr/bin/awk 'NF == 6 { $5 = "root"; $6 = "bin" } { print }' prototype > prototype2
+/usr/bin/awk 'NF == 6 { $3 = "opt/VirtualBoxAdditions/"$3"="$3 } { print }' prototype2 > prototype
+
+# install the kernel module to the right place (for now only 32-bit guests)
+/usr/bin/awk 'NF == 6 && $3 == "opt/VirtualBoxAdditions/vboxguest=vboxguest" { $3 = "platform/i86pc/kernel/drv/vboxguest=vboxguest" } { print }' prototype > prototype2
+/usr/bin/awk 'NF == 6 && $3 == "opt/VirtualBoxAdditions/vboxguest.conf=vboxguest.conf" { $3 = "platform/i86pc/kernel/drv/vboxguest.conf=vboxguest.conf" } { print }' prototype2 > prototype
+
+# install the vboxclient daemon
+/usr/bin/awk 'NF == 6 && $3 == "opt/VirtualBoxAdditions/1099.vboxclient=1099.vboxclient" { $3 = "usr/dt/config/Xsession.d/1099.vboxclient=1099.vboxclient" } { print }' prototype > prototype2
+
+#install the timesync daemon
+/usr/bin/awk 'NF == 6 && $3 == "opt/VirtualBoxAdditions/vboxservice.xml=vboxservice.xml" { $3 = "/var/svc/manifest/system/virtualbox/vboxservice.xml=vboxservice.xml" } { print }' prototype2 > prototype
+
+rm prototype2
+pkgmk -o -r .
+pkgtrans -s -o /var/spool/pkg `pwd`/$2 INNOvboxguest
+rm -rf /var/spool/pkg/INNOvboxguest
+
Index: trunk/src/VBox/Additions/solaris/Installer/postinstall.sh
===================================================================
--- trunk/src/VBox/Additions/solaris/Installer/postinstall.sh	(revision 7402)
+++ trunk/src/VBox/Additions/solaris/Installer/postinstall.sh	(revision 7402)
@@ -0,0 +1,88 @@
+#!/bin/sh
+# innotek VirtualBox
+# VirtualBox postinstall script for Solaris.
+#
+# Copyright (C) 2008 innotek GmbH
+#
+# innotek GmbH confidential
+# All rights reserved
+#
+
+echo "innotek VirtualBox Guest Additions - postinstall script"
+echo "This script will setup and load the VirtualBox Guest kernel module..."
+
+sync
+vboxadditions_path="/opt/VirtualBoxAdditions"
+
+# vboxguest.sh would've been installed, we just need to call it.
+$vboxadditions_path/vboxguest.sh restart silentunload
+
+# suid permissions for timesync
+echo "Setting permissions..."
+chmod 04755 $vboxadditions_path/VBoxService
+
+# create links
+echo "Creating links..."
+/usr/sbin/installf -c none $PKGINST /dev/vboxguest=../devices/pci@0,0/pci80ee,cafe@4:vboxguest s
+/usr/sbin/installf -c none $PKGINST /usr/bin/VBoxClient=$vboxadditions_path/VBoxClient s
+/usr/sbin/installf -c none $PKGINST /usr/bin/VBoxService=$vboxadditions_path/VBoxService s
+
+# Install Xorg components to the required places
+xorgversion_long=`/usr/bin/X11/Xorg -version 2>&1 | grep "X Window System Version"`
+xorgversion=`/usr/bin/expr "${xorgversion_long}" : 'X Window System Version \([^ ]*\)'`
+
+vboxmouse_src=""
+vboxvideo_src=""
+
+case "$xorgversion" in
+    1.3.* )
+        vboxmouse_src="$vboxadditions_path/vboxmouse_drv_71.so"
+        vboxvideo_src="$vboxadditions_path/vboxvideo_drv_13.so"
+        ;;
+    1.4.* )
+        vboxmouse_src="$vboxadditions_path/vboxmouse_drv_14.so"
+        vboxvideo_src="$vboxadditions_path/vboxvideo_drv_14.so"
+        ;;
+    7.1.* | *7.2.* )
+        vboxmouse_src="$vboxadditions_path/vboxmouse_drv_71.so"
+        vboxvideo_src="$vboxadditions_path/vboxvideo_drv_71.so"
+	    ;;
+    6.9.* | 7.0.* )
+        vboxmouse_src="$vboxadditions_path/vboxmouse_drv_70.so"
+        vboxvideo_src="$vboxadditions_path/vboxvideo_drv_70.so"
+        ;;
+esac
+
+if test -z "$vboxmouse_src"; then
+    echo "Unknown version of the X Window System installed."
+    echo "Failed to install the VirtualBox X Window System drivers."
+else
+    vboxmouse_dest="/usr/lib/X11/modules/input/vboxmouse_drv.so"
+    vboxvideo_dest="/usr/lib/X11/modules/input/vboxvideo_drv.so"
+    /usr/sbin/installf -c none $PKGINST "$vboxmouse_dest" f
+    /usr/sbin/installf -c none $PKGINST "$vboxvideo_dest" f
+    cp "$vboxmouse_src" "$vboxmouse_dest"
+    cp "$vboxvideo_src" "$vboxvideo_dest"
+    echo "Installed VirtualBox mouse and video drivers for Xorg $xorgversion"
+
+    # Removing redudant files
+    /usr/sbin/removef $PKGINST $vboxadditions_path/vboxmouse_drv_* 1>/dev/null 2>/dev/null
+    /usr/sbin/removef $PKGINST $vboxadditions_path/vboxvideo_drv_* 1>/dev/null 2>/dev/null
+    rm -f $vboxadditions_path/vboxmouse_drv_*
+    rm -f $vboxadditions_path/vboxvideo_drv_*
+    /usr/sbin/removef -f $PKGINST
+fi
+
+echo "Configuring Xorg..."
+$vboxadditions_path/x11config.pl
+
+/usr/sbin/installf -f $PKGINST
+
+# Setup our VBoxService SMF service
+echo "Configuring service..."
+
+/usr/sbin/svccfg import /var/svc/manifest/system/virtualbox/vboxservice.xml
+/usr/sbin/svcadm enable svc:/system/virtualbox/vboxservice
+
+echo "Done."
+
Index: trunk/src/VBox/Additions/solaris/Installer/preremove.sh
===================================================================
--- trunk/src/VBox/Additions/solaris/Installer/preremove.sh	(revision 7402)
+++ trunk/src/VBox/Additions/solaris/Installer/preremove.sh	(revision 7402)
@@ -0,0 +1,22 @@
+#!/bin/sh
+# innotek VirtualBox
+# VirtualBox pre-remove script for Solaris Guest Additions.
+#
+# Copyright (C) 2008 innotek GmbH
+#
+# innotek GmbH confidential
+# All rights reserved
+#
+
+echo "innotek VirtualBox Guest Additions - preremove script"
+echo "This script will unload the VirtualBox Guest kernel module..."
+
+# stop and unregister VBoxService daemon
+/usr/sbin/svcadm disable -s svc:/system/virtualbox/vboxservice:default
+/usr/sbin/svccfg delete svc:/system/virtualbox/vboxservice:default
+
+# vboxguest.sh would've been installed, we just need to call it.
+/opt/VirtualBoxAdditions/vboxguest.sh stop
+
+echo "Done."
+
Index: trunk/src/VBox/Additions/solaris/Installer/vboxguest.pkginfo
===================================================================
--- trunk/src/VBox/Additions/solaris/Installer/vboxguest.pkginfo	(revision 7402)
+++ trunk/src/VBox/Additions/solaris/Installer/vboxguest.pkginfo	(revision 7402)
@@ -0,0 +1,11 @@
+PKG="INNOvboxguest"
+NAME="innotek VirtualBox Guest Additions"
+ARCH="@UNAME_P@"
+VERSION="@VBOX_VERSION_STRING@"
+CATEGORY="application"
+VENDOR="innotek GmbH"
+EMAIL="info@innotek.de"
+BASEDIR="/"
+CLASSES="none"
+DESC="VirtualBox Guest Additions for Solaris guests."
+
Index: trunk/src/VBox/Additions/solaris/Installer/vboxguest.sh
===================================================================
--- trunk/src/VBox/Additions/solaris/Installer/vboxguest.sh	(revision 7402)
+++ trunk/src/VBox/Additions/solaris/Installer/vboxguest.sh	(revision 7402)
@@ -0,0 +1,135 @@
+#!/bin/bash
+# innotek VirtualBox
+# VirtualBox Guest Additions kernel module control script for Solaris.
+#
+# Copyright (C) 2007 innotek GmbH
+#
+# innotek GmbH confidential
+# All rights reserved
+#
+
+VBOXGUESTFILE=""
+SILENTUNLOAD=""
+
+abort()
+{
+    echo 1>&2 "$1"
+    exit 1
+}
+
+info()
+{
+    echo 1>&2 "$1"
+}
+
+get_module_path()
+{
+    cputype=`isainfo -k`
+    moduledir="/platform/i86pc/kernel/drv";
+    if test "$cputype" = "amd64"; then
+        moduledir=$moduledir/amd64
+    fi
+    modulepath=$moduledir/vboxguest
+    if test -f "$modulepath"; then
+        VBOXGUESTFILE="$modulepath"
+    else
+        VBOXGUESTFILE=""
+    fi
+}
+
+check_if_installed()
+{
+    if test "$VBOXGUESTFILE" -a -f "$VBOXGUESTFILE"; then
+        return 0
+    fi
+    abort "VirtualBox kernel module (vboxguest) not installed."
+}
+
+module_loaded()
+{
+    loadentry=`cat /etc/name_to_major | grep vboxguest`
+    if test -z "$loadentry"; then
+        return 1
+    fi
+    return 0
+}
+
+check_root()
+{
+    if test `id -u` -ne 0; then
+        abort "This program must be run with administrator privileges.  Aborting"
+    fi
+}
+
+start()
+{
+    if module_loaded; then
+        info "vboxguest already loaded..."
+    else
+        /usr/sbin/add_drv -i'pci80ee,cafe' -m'* 0666 root sys' vboxguest
+        if ! module_loaded; then
+            abort "Failed to load vboxguest."
+        elif test -c "/devices/pci@0,0/pci80ee,cafe@4:vboxguest"; then
+            info "Loaded vboxguest."
+        else
+            stop
+            abort "Aborting due to attach failure."
+        fi
+    fi
+}
+
+stop()
+{
+    if module_loaded; then
+        /usr/sbin/rem_drv vboxguest
+        info "Unloaded vboxguest."
+    elif test -z "$SILENTUNLOAD"; then
+        info "vboxguest not loaded."
+    fi
+}
+
+restart()
+{
+    stop
+    sync
+    start
+    return 0
+}
+
+status()
+{
+    if module_loaded; then
+        info "vboxguest running."
+    else
+        info "vboxguest stopped."
+    fi
+}
+
+check_root
+get_module_path
+check_if_installed
+
+if test "$2" = "silentunload"; then
+    SILENTUNLOAD="$2"
+fi
+
+case "$1" in
+start)
+    start
+    ;;
+stop)
+    stop
+    ;;
+restart)
+    restart
+    ;;
+status)
+    status
+    ;;
+*)
+    echo "Usage: $0 {start|stop|restart|status}"
+    exit 1
+esac
+
+exit
+
Index: trunk/src/VBox/Additions/solaris/Installer/vboxservice.xml
===================================================================
--- trunk/src/VBox/Additions/solaris/Installer/vboxservice.xml	(revision 7402)
+++ trunk/src/VBox/Additions/solaris/Installer/vboxservice.xml	(revision 7402)
@@ -0,0 +1,64 @@
+<?xml version='1.0'?>
+<!--
+# innotek VirtualBox
+# Solaris SMF service manifest for VBoxService (timesync).
+#
+# Copyright (C) 2008 innotek GmbH
+#
+# innotek GmbH confidential
+# All rights reserved
+#
+-->
+<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
+
+<service_bundle type='manifest' name='export'>
+
+<service
+    name='system/virtualbox/vboxservice'
+    type='service'
+    version='1'>
+
+    <create_default_instance enabled='false' />
+
+    <single_instance/>
+
+    <!-- Wait for devices to be initialized as we depend on vboxguest (PCI) -->
+    <dependency
+        name='milestone'
+        grouping='require_all'
+        restart_on='none'
+        type='service'> 
+        <service_fmri value='svc:/milestone/devices:default' />
+    </dependency>
+
+    <!-- Wait for local filesystems to be mounted (just to be safe, don't start too early) -->
+    <dependency
+        name='filesystem-local'
+        grouping='require_all'
+        restart_on='none'
+        type='service'>
+        <service_fmri value='svc:/system/filesystem/local:default' />
+    </dependency> 
+
+    <exec_method
+        type='method'
+        name='start'
+        exec='/usr/bin/VBoxService'
+        timeout_seconds='30' >
+    </exec_method>
+
+    <exec_method
+        type='method'
+        name='stop'
+        exec=':kill'
+        timeout_seconds='60' />
+
+    <template>
+        <common_name>
+            <loctext xml:lang='C'>VirtualBox Time Synchronize Daemon.</loctext>
+        </common_name>
+    </template>
+</service>
+
+</service_bundle>
+
Index: trunk/src/VBox/Additions/solaris/Makefile.kmk
===================================================================
--- trunk/src/VBox/Additions/solaris/Makefile.kmk	(revision 7402)
+++ trunk/src/VBox/Additions/solaris/Makefile.kmk	(revision 7402)
@@ -0,0 +1,98 @@
+# $Id$
+## @file
+# Makefile for the Solaris guest additions base directory.
+#
+
+#
+# Copyright (C) 2008 innotek GmbH
+#
+# This file is part of VirtualBox Open Source Edition (OSE), as
+# available from http://www.virtualbox.org. This file is free software;
+# you can redistribute it and/or modify it under the terms of the GNU
+# General Public License (GPL) as published by the Free Software
+# Foundation, in version 2 as it comes in the "COPYING" file of the
+# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+#
+
+DEPTH ?= ../../../..
+SUB_DEPTH = ..
+include	$(PATH_KBUILD)/subheader.kmk
+
+ifneq ($(BUILD_PLATFORM),solaris)
+$(error "The Solaris guest additions installer can only be built on Solaris!")
+endif
+
+PKGFILENAME    := VBoxSolarisAdditions
+PKGINFO_ARCH    = $(shell uname -p)
+VBOX_PATH_SOLARIS_ADDITION_INSTALLER := $(PATH_SUB_CURRENT)/Installer
+VBOX_PATH_X11_ADDITION_INSTALLER := $(PATH_ROOT)/src/VBox/Additions/x11/installer
+SOLARISINSTDIR := $(PATH_TARGET)/install
+
+ifeq ($(BUILD_TYPE),debug)
+ BIN_COPY         := $(CP) -f
+ BIN_COPY_SYMBOLS := $(CP) -f
+else
+ BIN_COPY         := /usr/sfw/bin/gobjcopy -S -R .comment
+ BIN_COPY_SYMBOLS := /usr/sfw/bin/gobjcopy -g -R .comment
+endif
+
+PACKING     += $(PATH_BIN)/additions/$(PKGFILENAME)
+OTHER_CLEAN += $(PACKING)
+
+include	$(PATH_KBUILD)/subfooter.kmk
+
+$(PATH_BIN)/additions/VBoxSolarisAdditions: \
+		$(VBOX_VERSION_STAMP) \
+		$(VBOX_PATH_SOLARIS_ADDITION_INSTALLER)/makepackage.sh \
+		$(VBOX_PATH_SOLARIS_ADDITION_INSTALLER)/postinstall.sh \
+		$(VBOX_PATH_SOLARIS_ADDITION_INSTALLER)/preremove.sh \
+		$(VBOX_PATH_SOLARIS_ADDITION_INSTALLER)/vboxguest.pkginfo \
+		$(VBOX_PATH_SOLARIS_ADDITION_INSTALLER)/vboxguest.sh \
+		$(VBOX_PATH_SOLARIS_ADDITION_INSTALLER)/vboxservice.xml \
+		$(VBOX_PATH_X11_ADDITION_INSTALLER)/98vboxadd-xclient \
+		$(VBOX_PATH_X11_ADDITION_INSTALLER)/x11config.pl \
+		$(PATH_BIN)/additions/vboxguest \
+		$(PATH_ROOT)/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris.conf \
+		$(PATH_BIN)/additions/VBoxClient \
+		$(PATH_BIN)/additions/VBoxService \
+		$(PATH_BIN)/additions/vboxvideo_drv_13.so \
+		$(PATH_BIN)/additions/vboxvideo_drv_14.so \
+		$(PATH_BIN)/additions/vboxvideo_drv_70.so \
+		$(PATH_BIN)/additions/vboxvideo_drv_71.so \
+		$(PATH_BIN)/additions/vboxmouse_drv_14.so \
+		$(PATH_BIN)/additions/vboxmouse_drv_70.so \
+		$(PATH_BIN)/additions/vboxmouse_drv_71.so \
+		$(PATH_SUB_CURRENT)/solaris/Makefile.kmk
+	$(call MSG_L1,Installing guest additions)
+	@# Clear out the existing package files if needed
+	$(QUIET)rm -rf $(SOLARISINSTDIR)
+	$(QUIET)$(MKDIR) -p $(SOLARISINSTDIR)
+	$(QUIET)$(SED) \
+		-e "s/@VBOX_VERSION_STRING@/$(VBOX_VERSION_STRING)/g" \
+		-e "s/@UNAME_P@/$(PKGINFO_ARCH)/g" \
+		--output $(SOLARISINSTDIR)/vboxguest.pkginfo \
+		$(VBOX_PATH_SOLARIS_ADDITION_INSTALLER)/vboxguest.pkginfo
+	$(QUIET)$(INSTALL) -m 0755 $(VBOX_PATH_SOLARIS_ADDITION_INSTALLER)/makepackage.sh                   $(SOLARISINSTDIR)/makepackage.sh
+	$(QUIET)$(INSTALL) -m 0755 $(VBOX_PATH_SOLARIS_ADDITION_INSTALLER)/postinstall.sh                   $(SOLARISINSTDIR)/postinstall.sh
+	$(QUIET)$(INSTALL) -m 0755 $(VBOX_PATH_SOLARIS_ADDITION_INSTALLER)/preremove.sh                     $(SOLARISINSTDIR)/preremove.sh
+	$(QUIET)$(INSTALL) -m 0755 $(VBOX_PATH_SOLARIS_ADDITION_INSTALLER)/vboxguest.sh                     $(SOLARISINSTDIR)/vboxguest.sh
+	$(QUIET)$(INSTALL) -m 0644 $(VBOX_PATH_SOLARIS_ADDITION_INSTALLER)/vboxservice.xml                  $(SOLARISINSTDIR)/vboxservice.xml
+	$(QUIET)$(INSTALL) -m 0755 $(VBOX_PATH_X11_ADDITION_INSTALLER)/98vboxadd-xclient                    $(SOLARISINSTDIR)/1099.vboxclient
+	$(QUIET)$(INSTALL) -m 0755 $(VBOX_PATH_X11_ADDITION_INSTALLER)/x11config.pl                         $(SOLARISINSTDIR)/x11config.pl
+	$(QUIET)$(INSTALL) -m 0644 $(PATH_ROOT)/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris.conf  $(SOLARISINSTDIR)/vboxguest.conf
+	$(QUIET)$(CP) -f $(PATH_BIN)/additions/vboxguest                                                    $(SOLARISINSTDIR)/vboxguest
+	$(QUIET)$(if $(VBOX_DO_STRIP),strip $(SOLARISINSTDIR)/vboxguest,)
+	$(QUIET)$(BIN_COPY) $(PATH_BIN)/additions/VBoxClient                                                $(SOLARISINSTDIR)/VBoxClient
+	$(QUIET)$(BIN_COPY) $(PATH_BIN)/additions/VBoxService                                               $(SOLARISINSTDIR)/VBoxService
+	$(QUIET)$(BIN_COPY) $(PATH_BIN)/additions/vboxvideo_drv_13.so                                       $(SOLARISINSTDIR)/vboxvideo_drv_13.so
+	$(QUIET)$(BIN_COPY) $(PATH_BIN)/additions/vboxvideo_drv_14.so                                       $(SOLARISINSTDIR)/vboxvideo_drv_14.so
+	$(QUIET)$(BIN_COPY) $(PATH_BIN)/additions/vboxvideo_drv_70.so                                       $(SOLARISINSTDIR)/vboxvideo_drv_70.so
+	$(QUIET)$(BIN_COPY) $(PATH_BIN)/additions/vboxvideo_drv_71.so                                       $(SOLARISINSTDIR)/vboxvideo_drv_71.so
+	$(QUIET)$(BIN_COPY) $(PATH_BIN)/additions/vboxmouse_drv_14.so                                       $(SOLARISINSTDIR)/vboxmouse_drv_14.so
+	$(QUIET)$(BIN_COPY) $(PATH_BIN)/additions/vboxmouse_drv_70.so                                       $(SOLARISINSTDIR)/vboxmouse_drv_70.so
+	$(QUIET)$(BIN_COPY) $(PATH_BIN)/additions/vboxmouse_drv_71.so                                       $(SOLARISINSTDIR)/vboxmouse_drv_71.so
+	$(call MSG_L1,Creating install package: $@)
+	$(QUIET)$(SOLARISINSTDIR)/makepackage.sh $(SOLARISINSTDIR) $(PKGFILENAME) 1>/dev/null 2>/dev/null
+	$(QUIET)$(INSTALL) -m 0644 $(SOLARISINSTDIR)/$(PKGFILENAME) $(PATH_BIN)/additions/$(PKGFILENAME)
+
