Index: trunk/src/VBox/Installer/solaris/Makefile.kmk
===================================================================
--- trunk/src/VBox/Installer/solaris/Makefile.kmk	(revision 87034)
+++ trunk/src/VBox/Installer/solaris/Makefile.kmk	(revision 87035)
@@ -48,5 +48,7 @@
 # Base package
 PKGINFO_ARCH      = $(shell uname -p)
-PKGINFO_REVSTAMP  = $(date %Y.%m.%d.%H.%M)
+PKGINFO_DATE      = $(date %Y.%m.%d.%H.%M.%S)
+PKGINFO_REVSTAMP  = $(PKGINFO_DATE).$(VBOX_SVN_REV)
+PKGINFO_PSTAMP    = vbox_$(subst .,,$(PKGINFO_DATE))_r$(VBOX_SVN_REV)
 PKG_FILENAME     := VirtualBox-$(VBOX_VERSION_STRING)-SunOS-$(KBUILD_TARGET_ARCH)-r$(VBOX_SVN_REV)
 
@@ -60,9 +62,12 @@
 PACKING          += \
 	$(PATH_STAGE_BIN)/$(PKG_FILENAME).tar.gz \
+	$(if $(VBOX_WITH_SOLARIS_IPS_PACKAGE),$(PATH_STAGE_BIN)/$(PKG_FILENAME).p5p,) \
 	$(PATH_STAGE_BIN)/VirtualBoxDebug.tar.bz2
 OTHER_CLEAN      += \
 	$(VBOX_PATH_SI_SCRATCH)/$(PKG_FILENAME).pkg \
 	$(PATH_STAGE_BIN)/$(PKG_FILENAME).tar.gz \
-	$(PATH_STAGE_BIN)/VirtualBoxDebug.tar.bz2
+	$(PATH_STAGE_BIN)/$(PKG_FILENAME).p5p \
+	$(PATH_STAGE_BIN)/VirtualBoxDebug.tar.bz2 \
+	$(VBOX_PATH_SI_SCRATCH)/dist-copy.ts
 
 #
@@ -527,8 +532,7 @@
 
 #
-# Creates the System V style installer package.
-#
-solaris-package:: $(VBOX_PATH_SI_SCRATCH)/$(PKG_FILENAME).pkg
-$(VBOX_PATH_SI_SCRATCH)/$(PKG_FILENAME).pkg: \
+# Copy all files needed for packaging into the final directory structure
+#
+$(VBOX_PATH_SI_SCRATCH)/dist-copy.ts: \
 		$(VBOX_VERSION_STAMP) \
 		\
@@ -537,4 +541,5 @@
 		$(VBOX_PATH_SOL_INST_SRC)/virtualbox.applications.in \
 		$(VBOX_PATH_SOL_INST_SRC)/vbox.pkginfo \
+		$(VBOX_PATH_SOL_INST_SRC)/vbox-ips.mog \
 		\
 		$(if-expr defined(VBOX_WITH_ADDITIONS_PACKING),$(PATH_STAGE_BIN)/additions/VBoxGuestAdditions.iso,) \
@@ -663,14 +668,28 @@
 		-e "s/@VBOX_VENDOR@/$(VBOX_VENDOR)/g" \
 		-e "s/@VBOX_VERSION_STRING@/$(VBOX_VERSION_STRING)/g" \
-		-e "s/@VBOX_SVN_REV@/$(VBOX_SVN_REV)/g" \
 		-e "s/@VBOX_VERSION_REVSTAMP@/$(PKGINFO_REVSTAMP)/g" \
 		-e "s/@UNAME_P@/$(PKGINFO_ARCH)/g" \
+		-e "s/@VBOX_PSTAMP@/$(PKGINFO_PSTAMP)/g" \
 		--output $(VBOX_PATH_SI_SCRATCH_PKG)/vbox.pkginfo \
 		$(VBOX_PATH_SOL_INST_SRC)/vbox.pkginfo
-	$(INSTALL) -m 0644 $(VBOX_PATH_SOL_INST_SRC)/vbox.pkgresponse	$(VBOX_PATH_SI_SCRATCH_PKG)/autoresponse
-
-# Done copying file, create the package!
+	$(SED)	-e "s/@VBOX_PRODUCT@/$(VBOX_PRODUCT)/g" \
+		-e "s/@VBOX_VENDOR@/$(VBOX_VENDOR)/g" \
+		-e "s/@VBOX_VERSION_STRING@/$(VBOX_VERSION_STRING)/g" \
+		-e "s/@VBOX_SVN_REV@/$(VBOX_SVN_REV)/g" \
+		-e "s/@UNAME_P@/$(PKGINFO_ARCH)/g" \
+		--output $(VBOX_PATH_SI_SCRATCH_PKG)/vbox-ips.mog \
+		$(VBOX_PATH_SOL_INST_SRC)/vbox-ips.mog
+	$(APPEND) -t $@ "done"
+
+#
+# Creates the System V style installer package.
+#
+solaris-package:: $(VBOX_PATH_SI_SCRATCH)/$(PKG_FILENAME).pkg
+$(VBOX_PATH_SI_SCRATCH)/$(PKG_FILENAME).pkg: \
+		$(VBOX_PATH_SI_SCRATCH)/dist-copy.ts \
+		$(VBOX_SI_DEP_ON_MAKEFILE) \
+		| $$(dir $$@)
 	$(call MSG_L1,Creating install package: $(PKG_FILENAME).pkg)
-	$(REDIRECT) -C $(VBOX_PATH_SOL_INST_SRC) -- $(VBOX_PATH_SI_SCRATCH_PKG)/makepackage.sh \
+	$(VBOX_PATH_SI_SCRATCH_PKG)/makepackage.sh \
 		$(if-expr defined(VBOX_WITH_HARDENING),--hardened,) \
 		$(VBOX_PATH_SI_SCRATCH_PKG) \
@@ -679,9 +698,7 @@
 		$(VBOX_SVN_REV)
 	$(MV) -- "$(VBOX_PATH_SI_SCRATCH_PKG)/$(PKG_FILENAME).pkg" "$@"
-	$(RM) -Rf -- "$(VBOX_PATH_SI_SCRATCH_PKG)/"
-
-
-#
-# Creates the tar file containing license, readme and autoresponse file in addition to the system V package.
+
+#
+# Creates the tar file containing license, readme and autoresponse file in addition to the System V package.
 #
 solaris-package-tar-gz:: $(PATH_STAGE_BIN)/$(PKG_FILENAME).tar.gz
@@ -712,4 +729,21 @@
 	$(call MSG_L1,Packaging $@ is completed.)
 
+#
+# Creates the IPS style installer package.
+#
+solaris-package-ips:: $(PATH_STAGE_BIN)/$(PKG_FILENAME).p5p
+$(PATH_STAGE_BIN)/$(PKG_FILENAME).p5p: \
+		$(VBOX_PATH_SI_SCRATCH)/dist-copy.ts \
+		$(VBOX_SI_DEP_ON_MAKEFILE) \
+		| $$(dir $$@)
+	$(call MSG_L1,Creating install package: $(PKG_FILENAME).p5p)
+	$(VBOX_PATH_SI_SCRATCH_PKG)/makepackage.sh \
+		--ips \
+		$(if-expr defined(VBOX_WITH_HARDENING),--hardened,) \
+		$(VBOX_PATH_SI_SCRATCH_PKG) \
+		$(PKG_FILENAME) \
+		$(KBUILD_TARGET_ARCH) \
+		$(VBOX_SVN_REV)
+
 
 ## List of file list variable names relevant for debug info.
Index: trunk/src/VBox/Installer/solaris/makepackage.sh
===================================================================
--- trunk/src/VBox/Installer/solaris/makepackage.sh	(revision 87034)
+++ trunk/src/VBox/Installer/solaris/makepackage.sh	(revision 87035)
@@ -19,14 +19,20 @@
 #
 # Usage:
-#       makepackage.sh [--hardened] $(PATH_TARGET)/install packagename {$(KBUILD_TARGET_ARCH)|neutral} $(VBOX_SVN_REV) [VBIPackageName]
+#       makepackage.sh [--hardened] [--ips] $(PATH_TARGET)/install packagename {$(KBUILD_TARGET_ARCH)|neutral} $(VBOX_SVN_REV)
 
 
 # Parse options.
 HARDENED=""
-while test $# -ge 1;
+IPS_PACKAGE=""
+PACKAGE_SPEC="prototype"
+while [ $# -ge 1 ];
 do
     case "$1" in
         --hardened)
             HARDENED=1
+            ;;
+        --ips)
+            IPS_PACKAGE=1
+            PACKAGE_SPEC="virtualbox.p5m"
             ;;
     *)
@@ -38,210 +44,252 @@
 
 if [ -z "$4" ]; then
-    echo "Usage: $0 installdir packagename x86|amd64 svnrev [VBIPackage]"
+    echo "Usage: $0 installdir packagename x86|amd64 svnrev"
     echo "-- packagename must not have any extension (e.g. VirtualBox-SunOS-amd64-r28899)"
     exit 1
 fi
 
-PKG_BASE_DIR=$1
-VBOX_INSTALLED_DIR=$1/opt/VirtualBox
-VBOX_PKGFILE=$2.pkg
-VBOX_ARCHIVE=$2.tar.gz
+PKG_BASE_DIR="$1"
+PACKAGE_SPEC="$PKG_BASE_DIR/$PACKAGE_SPEC"
+VBOX_INSTALLED_DIR=/opt/VirtualBox
+if [ -n "$IPS_PACKAGE" ]; then
+    VBOX_PKGFILE="$2".p5p
+else
+    VBOX_PKGFILE="$2".pkg
+fi
 # VBOX_PKG_ARCH is currently unused.
-VBOX_PKG_ARCH=$3
-VBOX_SVN_REV=$4
-
-VBOX_PKGNAME=SUNWvbox
-VBOX_GGREP=/usr/sfw/bin/ggrep
-VBOX_AWK=/usr/bin/awk
-#VBOX_GTAR=/usr/sfw/bin/gtar
+VBOX_PKG_ARCH="$3"
+VBOX_SVN_REV="$4"
+
+if [ -n "$IPS_PACKAGE" ] ; then
+    VBOX_PKGNAME=system/virtualbox
+else
+    VBOX_PKGNAME=SUNWvbox
+fi
+# need GNU grep because Solaris egrep does not support word matching
+VBOX_GGREP=/usr/gnu/bin/grep
+# need dynamic regex support which isn't available in S11 /usr/bin/awk
+VBOX_AWK=/usr/xpg4/bin/awk
 
 # check for GNU grep we use which might not ship with all Solaris
-if test ! -f "$VBOX_GGREP" && test ! -h "$VBOX_GGREP"; then
+if [ ! -f "$VBOX_GGREP" ] && [ ! -h "$VBOX_GGREP" ]; then
     echo "## GNU grep not found in $VBOX_GGREP."
     exit 1
 fi
 
-# check for GNU tar we use which might not ship with all Solaris
-#if test ! -f "$VBOX_GTAR" && test ! -h "$VBOX_GTAR"; then
-#    echo "## GNU tar not found in $VBOX_GTAR."
-#    exit 1
-#fi
-
 # bail out on non-zero exit status
 set -e
 
+if [ -n "$IPS_PACKAGE" ]; then
+
+package_spec_create()
+{
+    > "$PACKAGE_SPEC"
+}
+
+package_spec_append_info()
+{
+    : # provided by vbox-ips.mog
+}
+
+package_spec_append_content()
+{
+    pkgsend generate "$1" | pkgfmt >> "$PACKAGE_SPEC"
+}
+
+package_spec_append_hardlink()
+{
+    if [ -f "$3$4/amd64/$2" -o -f "$3$4/i386/$2" ]; then
+        echo "hardlink path=$4/$2 target=$1" >> "$PACKAGE_SPEC"
+    fi
+}
+
+package_spec_fixup_content()
+{
+    :
+}
+
+package_create()
+{
+    pkgmogrify -DVBOX_PKGNAME="$VBOX_PKGNAME" "$PACKAGE_SPEC" vbox-ips.mog | pkgfmt > "$PACKAGE_SPEC.1"
+
+    pkgdepend generate -m -d "$1" "$PACKAGE_SPEC.1" | pkgfmt > "$PACKAGE_SPEC.2"
+
+    pkgdepend resolve -m -v "$PACKAGE_SPEC.2"
+
+    pkglint "$PACKAGE_SPEC.2.res"
+
+    rm -rf "$1/vbox-repo"
+    pkgrepo create "$1/vbox-repo"
+    pkgrepo -s "$1/vbox-repo" set publisher/prefix=virtualbox
+
+    # Create package in local file repository
+    pkgsend -s "$1/vbox-repo" publish -d "$1" "$PACKAGE_SPEC.2.res"
+
+    pkgrepo -s "$1/vbox-repo" info
+    pkgrepo -s "$1/vbox-repo" list
+
+    # Convert into package archive
+    pkgrecv -s "$1/vbox-repo" -a -d "$2" -m latest "$3"
+    #rm -rf "$1/vbox-repo"
+}
+
+else
+
+package_spec_create()
+{
+    > "$PACKAGE_SPEC"
+}
+
+package_spec_append_info()
+{
+    echo 'i pkginfo=vbox.pkginfo' >> "$PACKAGE_SPEC"
+    echo 'i checkinstall=checkinstall.sh' >> "$PACKAGE_SPEC"
+    echo 'i postinstall=postinstall.sh' >> "$PACKAGE_SPEC"
+    echo 'i preremove=preremove.sh' >> "$PACKAGE_SPEC"
+    echo 'i space=vbox.space' >> "$PACKAGE_SPEC"
+}
+
+# Our package is a non-relocatable package.
+#
+# pkgadd will take care of "relocating" them when they are used for remote installations using
+# $PKG_INSTALL_ROOT and not $BASEDIR. Seems this little subtlety led to it's own page:
+# https://docs.oracle.com/cd/E19253-01/820-4042/package-2/index.html
+
+package_spec_append_content()
+{
+    cd "$1"
+    # Exclude directories to not cause install-time conflicts with existing system directories
+    find . ! -type d | "$VBOX_GGREP" -v -wE 'prototype|makepackage\.sh|vbox\.pkginfo|postinstall\.sh|checkinstall\.sh|preremove\.sh|vbox\.space|virtualbox\.p5m.*' | LC_COLLATE=C sort | pkgproto >> "$PACKAGE_SPEC"
+    cd -
+    "$VBOX_AWK" 'NF == 3 && $1 == "s" && $2 == "none" { $3="/"$3 } { print }' "$PACKAGE_SPEC" > "$PACKAGE_SPEC.tmp"
+    mv -f "$PACKAGE_SPEC.tmp" "$PACKAGE_SPEC"
+    "$VBOX_AWK" 'NF == 6 && ($1 == "f" || $1 == "l") && ($2 == "none" || $2 == "manifest") { $3="/"$3 } { print }' "$PACKAGE_SPEC" > "$PACKAGE_SPEC.tmp"
+    mv -f "$PACKAGE_SPEC.tmp" "$PACKAGE_SPEC"
+
+    cd "$1"
+    # Include opt/VirtualBox and subdirectories as we want uninstall to clean up directory structure.
+    # Include var/svc for manifest class action script does not create them.
+    find . -type d | "$VBOX_GGREP" -E 'opt/VirtualBox|var/svc/manifest/application/virtualbox' | LC_COLLATE=C sort | pkgproto >> "$PACKAGE_SPEC"
+    cd -
+    "$VBOX_AWK" 'NF == 6 && $1 == "d" && $2 == "none" { $3="/"$3 } { print }' "$PACKAGE_SPEC" > "$PACKAGE_SPEC.tmp"
+    mv -f "$PACKAGE_SPEC.tmp" "$PACKAGE_SPEC"
+}
+
+package_spec_append_hardlink()
+{
+    if [ -f "$3$4/amd64/$2" -o -f "$3$4/i386/$2" ]; then
+        echo "l none $4/$2=$1" >> "$PACKAGE_SPEC"
+    fi
+}
+
 # Fixup filelist using awk, the parameters must be in awk syntax
 # params: filename condition action
-filelist_fixup()
-{
-  "$VBOX_AWK" 'NF == 6 && '"$2"' { '"$3"' } { print }' "$1" > "tmp-$1"
-  mv -f "tmp-$1" "$1"
-}
-
-dirlist_fixup()
-{
-  "$VBOX_AWK" 'NF == 6 && $1 == "d" && '"$2"' { '"$3"' } { print }' "$1" > "tmp-$1"
-  mv -f "tmp-$1" "$1"
-}
-
-hardlink_fixup()
-{
-  "$VBOX_AWK" 'NF == 3 && $1=="l" && '"$2"' { '"$3"' } { print }' "$1" > "tmp-$1"
-  mv -f "tmp-$1" "$1"
-}
-
-symlink_fixup()
-{
-  "$VBOX_AWK" 'NF == 3 && $1=="s" && '"$2"' { '"$3"' } { print }' "$1" > "tmp-$1"
-  mv -f "tmp-$1" "$1"
-}
-
-create_hardlink()
-{
-    if test -f "$VBOX_INSTALLED_DIR/amd64/$1" || test -f "$VBOX_INSTALLED_DIR/i386/$1"; then
-        ln -f ./VBoxISAExec "$VBOX_INSTALLED_DIR/$1"
+package_spec_fixup_filelist()
+{
+    "$VBOX_AWK" 'NF == 6 && '"$1"' { '"$2"' } { print }' "$PACKAGE_SPEC" > "$PACKAGE_SPEC.tmp"
+    mv -f "$PACKAGE_SPEC.tmp" "$PACKAGE_SPEC"
+}
+
+package_spec_fixup_dirlist()
+{
+    "$VBOX_AWK" 'NF == 6 && $1 == "d" && '"$1"' { '"$2"' } { print }' "$PACKAGE_SPEC" > "$PACKAGE_SPEC.tmp"
+    mv -f "$PACKAGE_SPEC.tmp" "$PACKAGE_SPEC"
+}
+
+package_spec_fixup_content()
+{
+    # fix up file permissions (owner/group)
+    # don't grok for class-specific files (like sed, if any)
+    package_spec_fixup_filelist '$2 == "none"'                                                                  '$5 = "root"; $6 = "bin"'
+
+    # HostDriver vboxdrv
+    package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/vboxdrv"'                                    '$6 = "sys"'
+    package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/amd64/vboxdrv"'                              '$6 = "sys"'
+
+    # NetFilter vboxflt
+    package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/vboxflt"'                                    '$6 = "sys"'
+    package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/amd64/vboxflt"'                              '$6 = "sys"'
+
+    # NetFilter vboxbow
+    package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/vboxbow"'                                    '$6 = "sys"'
+    package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/amd64/vboxbow"'                              '$6 = "sys"'
+
+    # NetAdapter vboxnet
+    package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/vboxnet"'                                    '$6 = "sys"'
+    package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/amd64/vboxnet"'                              '$6 = "sys"'
+
+    # USBMonitor vboxusbmon
+    package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/vboxusbmon"'                                 '$6 = "sys"'
+    package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/amd64/vboxusbmon"'                           '$6 = "sys"'
+
+    # USB Client vboxusb
+    package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/vboxusb"'                                    '$6 = "sys"'
+    package_spec_fixup_filelist '$3 == "/platform/i86pc/kernel/drv/amd64/vboxusb"'                              '$6 = "sys"'
+
+    # Manifest class action scripts
+    package_spec_fixup_filelist '$3 == "/var/svc/manifest/application/virtualbox/virtualbox-webservice.xml"'    '$2 = "manifest";$6 = "sys"'
+    package_spec_fixup_filelist '$3 == "/var/svc/manifest/application/virtualbox/virtualbox-balloonctrl.xml"'   '$2 = "manifest";$6 = "sys"'
+    package_spec_fixup_filelist '$3 == "/var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml"'    '$2 = "manifest";$6 = "sys"'
+
+    # Use 'root' as group so as to match attributes with the previous installation and prevent a conflict. Otherwise pkgadd bails out thinking
+    # we're violating directory attributes of another (non existing) package
+    package_spec_fixup_dirlist '$3 == "/var/svc/manifest/application/virtualbox"'                               '$6 = "root"'
+
+    # Hardening requires some executables to be marked setuid.
+    if [ -n "$HARDENED" ]; then
+        package_spec_fixup_filelist '(   $3 == "/opt/VirtualBox/amd64/VirtualBoxVM" \
+                                      || $3 == "/opt/VirtualBox/amd64/VBoxHeadless" \
+                                      || $3 == "/opt/VirtualBox/amd64/VBoxSDL" \
+                                      || $3 == "/opt/VirtualBox/i386/VirtualBox" \
+                                      || $3 == "/opt/VirtualBox/i386/VBoxHeadless" \
+                                      || $3 == "/opt/VirtualBox/i386/VBoxSDL" )'                                '$4 = "4755"'
     fi
-}
-
-# Prepare file list
-cd "$PKG_BASE_DIR"
-echo 'i pkginfo=./vbox.pkginfo' > prototype
-echo 'i checkinstall=./checkinstall.sh' >> prototype
-echo 'i postinstall=./postinstall.sh' >> prototype
-echo 'i preremove=./preremove.sh' >> prototype
-echo 'i space=./vbox.space' >> prototype
-if test -f "./vbox.copyright"; then
-    echo 'i copyright=./vbox.copyright' >> prototype
-fi
-
-# Create relative hardlinks for executables to either the 32-bit or 64-bit subfolders
-cd "$VBOX_INSTALLED_DIR"
-create_hardlink VBoxManage
-create_hardlink VBoxSDL
-create_hardlink VBoxAutostart
-create_hardlink vboxwebsrv
-create_hardlink VBoxZoneAccess
-create_hardlink VBoxSVC
-create_hardlink VBoxBugReport
-create_hardlink VBoxBalloonCtrl
-create_hardlink VBoxTestOGL
-create_hardlink VirtualBox
-create_hardlink VirtualBoxVM
-create_hardlink vbox-img
-create_hardlink VBoxHeadless
-
-# Exclude directories to not cause install-time conflicts with existing system directories
-cd "$PKG_BASE_DIR"
-find . ! -type d | $VBOX_GGREP -v -wE 'prototype|makepackage.sh|vbox.pkginfo|postinstall.sh|checkinstall.sh|preremove.sh|ReadMe.txt|vbox.space|vbox.depend|vbox.copyright|VirtualBoxKern' | pkgproto >> prototype
-
-# Include opt/VirtualBox and subdirectories as we want uninstall to clean up directory structure.
-# Include var/svc for manifest class action script does not create them.
-find . -type d | $VBOX_GGREP -E 'opt/VirtualBox|var/svc/manifest/application/virtualbox' | pkgproto >> prototype
-
-# fix up file permissions (owner/group)
-# don't grok for class-specific files (like sed, if any)
-filelist_fixup prototype '$2 == "none"'                                                                '$5 = "root"; $6 = "bin"'
-
-# don't include autoresponse and LICENSE from the base folder into / of
-# the package, it goes into .tar.gz and another one already exists
-# in /opt/VirtualBox
-sed '/f none autoresponse/d' prototype > prototype2
-mv -f prototype2 prototype
-sed '/f none LICENSE/d' prototype > prototype2
-mv -f prototype2 prototype
-
-# HostDriver vboxdrv
-filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/vboxdrv"'                                   '$6 = "sys"'
-filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/amd64/vboxdrv"'                             '$6 = "sys"'
-
-# NetFilter vboxflt
-filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/vboxflt"'                                   '$6 = "sys"'
-filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/amd64/vboxflt"'                             '$6 = "sys"'
-
-# NetFilter vboxbow
-filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/vboxbow"'                                   '$6 = "sys"'
-filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/amd64/vboxbow"'                             '$6 = "sys"'
-
-# NetAdapter vboxnet
-filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/vboxnet"'                                   '$6 = "sys"'
-filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/amd64/vboxnet"'                             '$6 = "sys"'
-
-# USBMonitor vboxusbmon
-filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/vboxusbmon"'                                '$6 = "sys"'
-filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/amd64/vboxusbmon"'                          '$6 = "sys"'
-
-# USB Client vboxusb
-filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/vboxusb"'                                   '$6 = "sys"'
-filelist_fixup prototype '$3 == "platform/i86pc/kernel/drv/amd64/vboxusb"'                             '$6 = "sys"'
-
-# Manifest class action scripts
-filelist_fixup prototype '$3 == "var/svc/manifest/application/virtualbox/virtualbox-webservice.xml"'    '$2 = "manifest";$6 = "sys"'
-filelist_fixup prototype '$3 == "var/svc/manifest/application/virtualbox/virtualbox-balloonctrl.xml"'   '$2 = "manifest";$6 = "sys"'
-filelist_fixup prototype '$3 == "var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml"'    '$2 = "manifest";$6 = "sys"'
-
-# Use 'root' as group so as to match attributes with the previous installation and prevent a conflict. Otherwise pkgadd bails out thinking
-# we're violating directory attributes of another (non existing) package
-dirlist_fixup prototype  '$3 == "var/svc/manifest/application/virtualbox"'                              '$6 = "root"'
-
-# Hardening requires some executables to be marked setuid.
-if test -n "$HARDENED"; then
-    $VBOX_AWK 'NF == 6 \
-        && (    $3 == "opt/VirtualBox/amd64/VirtualBoxVM" \
-            ||  $3 == "opt/VirtualBox/amd64/VBoxHeadless" \
-            ||  $3 == "opt/VirtualBox/amd64/VBoxSDL" \
-            ||  $3 == "opt/VirtualBox/i386/VirtualBox" \
-            ||  $3 == "opt/VirtualBox/i386/VBoxHeadless" \
-            ||  $3 == "opt/VirtualBox/i386/VBoxSDL" \
-            ) \
-       { $4 = "4755" } { print }' prototype > prototype2
-    mv -f prototype2 prototype
-fi
-
-# Other executables that need setuid root (hardened or otherwise)
-$VBOX_AWK 'NF == 6 \
-    && (    $3 == "opt/VirtualBox/amd64/VBoxNetAdpCtl" \
-        ||  $3 == "opt/VirtualBox/i386/VBoxNetAdpCtl" \
-        ||  $3 == "opt/VirtualBox/amd64/VBoxNetDHCP" \
-        ||  $3 == "opt/VirtualBox/i386/VBoxNetDHCP" \
-        ||  $3 == "opt/VirtualBox/amd64/VBoxNetNAT" \
-        ||  $3 == "opt/VirtualBox/i386/VBoxNetNAT" \
-        ) \
-   { $4 = "4755" } { print }' prototype > prototype2
-mv -f prototype2 prototype
-
-# Our package is a non-relocatable package. pkgadd will take care of "relocating" them when they are used for
-# remote installations using $PKG_INSTALL_ROOT and not $BASEDIR. Seems this little subtlety led to it's own page:
-# http://docs.sun.com/app/docs/doc/820-4042/package-2?a=view
-filelist_fixup prototype  '$2 == "none"'                              '$3="/"$3'
-filelist_fixup prototype  '$2 == "manifest"'                          '$3="/"$3'
-symlink_fixup  prototype  '$2 == "none"'                              '$3="/"$3'
-hardlink_fixup prototype  '$2 == "none"'                              '$3="/"$3'
-
-echo " --- start of prototype  ---"
-cat prototype
-echo " --- end of prototype --- "
-
-# Explicitly set timestamp to shutup warning
-VBOXPKG_TIMESTAMP=vbox`date '+%Y%m%d%H%M%S'`_r$VBOX_SVN_REV
-
-# Create the package instance
-pkgmk -p $VBOXPKG_TIMESTAMP -o -r .
-
-# Translate into package datastream
-pkgtrans -s -o /var/spool/pkg "`pwd`/$VBOX_PKGFILE" "$VBOX_PKGNAME"
-
-# $5 if exists would contain the path to the VBI package to include in the .tar.gz
-#if [ -f LICENSE ]; then
-#    VBOX_LICENSEFILE=LICENSE
-#fi
-#if test -f "$5"; then
-#    $VBOX_GTAR zcvf "$VBOX_ARCHIVE" $VBOX_LICENSEFILE "$VBOX_PKGFILE" "$5" autoresponse ReadMe.txt
-#else
-#    $VBOX_GTAR zcvf "$VBOX_ARCHIVE" $VBOX_LICENSEFILE "$VBOX_PKGFILE" autoresponse ReadMe.txt
-#fi
+
+    # Other executables that need setuid root (hardened or otherwise)
+    package_spec_fixup_filelist '(   $3 == "/opt/VirtualBox/amd64/VBoxNetAdpCtl" \
+                                  || $3 == "/opt/VirtualBox/i386/VBoxNetAdpCtl" \
+                                  || $3 == "/opt/VirtualBox/amd64/VBoxNetDHCP" \
+                                  || $3 == "/opt/VirtualBox/i386/VBoxNetDHCP" \
+                                  || $3 == "/opt/VirtualBox/amd64/VBoxNetNAT" \
+                                  || $3 == "/opt/VirtualBox/i386/VBoxNetNAT" )'                                 '$4 = "4755"'
+
+    echo " --- start of $PACKAGE_SPEC  ---"
+    cat "$PACKAGE_SPEC"
+    echo " --- end of $PACKAGE_SPEC --- "
+}
+
+package_create()
+{
+    # Create the package instance
+    pkgmk -o -f "$PACKAGE_SPEC" -r "$1"
+
+    # Translate into package datastream
+    pkgtrans -s -o /var/spool/pkg "$1/$2" "$3"
+
+    rm -rf "/var/spool/pkg/$2"
+}
+
+fi
+
+
+# Prepare package spec
+package_spec_create
+
+# Metadata
+package_spec_append_info "$PKG_BASE_DIR"
+
+# File and direcory list
+package_spec_append_content "$PKG_BASE_DIR"
+
+# Add hardlinks for executables to launch the 32-bit or 64-bit executable
+for f in VBoxManage VBoxSDL VBoxAutostart vboxwebsrv VBoxZoneAccess VBoxSVC VBoxBugReport VBoxBalloonCtrl VBoxTestOGL VirtualBox VirtualBoxVM vbox-img VBoxHeadless; do
+    package_spec_append_hardlink VBoxISAExec    $f  "$PKG_BASE_DIR" "$VBOX_INSTALLED_DIR"
+done
+
+package_spec_fixup_content
+
+package_create "$PKG_BASE_DIR" "$VBOX_PKGFILE" "$VBOX_PKGNAME" "$VBOX_SVN_REV"
 
 echo "## Package file created successfully!"
-rm -rf "/var/spool/pkg/$VBOX_PKGNAME"
 
 exit $?
-
Index: trunk/src/VBox/Installer/solaris/vbox-ips.mog
===================================================================
--- trunk/src/VBox/Installer/solaris/vbox-ips.mog	(revision 87035)
+++ trunk/src/VBox/Installer/solaris/vbox-ips.mog	(revision 87035)
@@ -0,0 +1,46 @@
+# Transmogrification from prepared package directory layout to IPS
+set name=pkg.fmri value=$(VBOX_PKGNAME)@@VBOX_VERSION_STRING@,5.11-0.0.0.@VBOX_SVN_REV@.0.0.0
+set name=pkg.human-version value="@VBOX_VERSION_STRING@r@VBOX_SVN_REV@"
+set name=pkg.summary value="@VBOX_PRODUCT@"
+set name=pkg.description value="A powerful PC virtualization solution"
+set name=variant.arch value=@UNAME_P@
+set name=variant.opensolaris.zone value=global value=nonglobal
+set name=info.classification value=org.opensolaris.category.2008:System/Virtualization
+
+# Drop system directories to not have conflicting permissions
+<transform dir path=etc$->drop>
+<transform dir path=opt$->drop>
+<transform dir path=platform.*$->drop>
+<transform dir path=usr.*$->drop>
+<transform dir path=var$->drop>
+<transform dir path=var/svc$->drop>
+<transform dir path=var/svc/manifest$->drop>
+<transform dir path=var/svc/manifest/application$->drop>
+
+# Drop all files in root, they are for packaging purposes
+<transform file path=[^/]*$->drop>
+
+# Drop STREAMS based NetFilter driver, obsolete for Solaris 11
+<transform file path=platform/i86pc/kernel/drv/amd64/vboxflt$->drop>
+<transform file path=platform/i86pc/kernel/drv/vboxflt\.conf$->drop>
+
+# Drop legacy libraries, needed only for Solaris 10
+<transform dir path=opt/VirtualBox/amd64/legacy$->drop>
+<transform file path=opt/VirtualBox/amd64/legacy/.*$->drop>
+
+# Set the appropriate pkg variant for drivers (global zone only)
+#<transform file path=opt/VirtualBox/.*$->add pkg.depend.runpath $PKGDEPEND_RUNPATH:/opt/VirtualBox/amd64>
+<transform file path=platform/i86pc/kernel/drv/amd64/vboxdrv$->add variant.opensolaris.zone global>
+<transform file path=platform/i86pc/kernel/drv/amd64/vboxbow$->add variant.opensolaris.zone global>
+<transform file path=platform/i86pc/kernel/drv/amd64/vboxnet$->add variant.opensolaris.zone global>
+<transform file path=platform/i86pc/kernel/drv/amd64/vboxusb$->add variant.opensolaris.zone global>
+<transform file path=platform/i86pc/kernel/drv/amd64/vboxusbmon$->add variant.opensolaris.zone global>
+
+# pkg doesn't lookup /kernel/misc/amd64 but looks up /kernel/misc/amd64/misc/amd64. whatever
+# the below transform for drivers fixes where pkg resolves it's dependencies (we link drivers with -N misc/*)
+#<transform file path=platform/i86pc/kernel/drv/amd64/.*$->add pkg.depend.runpath $PKGDEPEND_RUNPATH:/kernel>
+
+# todo:
+# resolve dependencies properly for python
+<transform file path=opt/VirtualBox/vboxshell\.py$->drop>
+<transform file path=opt/VirtualBox/VBoxPython2_[^7].*\.so.*$->drop>
Index: trunk/src/VBox/Installer/solaris/vbox.pkginfo
===================================================================
--- trunk/src/VBox/Installer/solaris/vbox.pkginfo	(revision 87034)
+++ trunk/src/VBox/Installer/solaris/vbox.pkginfo	(revision 87035)
@@ -3,5 +3,5 @@
 SUNW_PRODNAME="@VBOX_PRODUCT@"
 ARCH="@UNAME_P@"
-VERSION="@VBOX_VERSION_STRING@,REV=@VBOX_VERSION_REVSTAMP@.@VBOX_SVN_REV@"
+VERSION="@VBOX_VERSION_STRING@,REV=@VBOX_VERSION_REVSTAMP@"
 SUNW_PRODVERS="@VBOX_VERSION_STRING@"
 SUNW_PKGVERS=1.0
@@ -14,3 +14,3 @@
 CLASSES=none manifest
 DESC="A powerful PC virtualization solution"
-
+PSTAMP="@VBOX_PSTAMP@"
