Index: /trunk/src/VBox/Installer/linux/debian/postinst
===================================================================
--- /trunk/src/VBox/Installer/linux/debian/postinst	(revision 58240)
+++ /trunk/src/VBox/Installer/linux/debian/postinst	(revision 58241)
@@ -17,4 +17,7 @@
 #  abort-remove:      (our version): removing this package failed
 #  abort-deconfigure: (our version): error during resolving conflicts
+
+## @todo Do we really gain anything from not just executing everything
+##       unconditionally?
 
 LOG="/var/log/vbox-install.log"
@@ -78,33 +81,6 @@
 if test "${INSTALL_NO_VBOXDRV}" = 1; then
   POSTINST_START=--nostart
-  # if INSTALL_NO_VBOXDRV is set to 1, remove all shipped modules
-  if [ "$1" = "configure" ]; then
-    rm -f /lib/modules/*/misc/vboxdrv.ko
-    rm -f /lib/modules/*/misc/vboxnetflt.ko
-    rm -f /lib/modules/*/misc/vboxnetadp.ko
-    rm -f /lib/modules/*/misc/vboxpci.ko
-  fi
 else
   POSTINST_START=
-  # Disable module compilation with INSTALL_NO_VBOXDRV=1 in /etc/default/virtualbox
-  if [ ! -f /lib/modules/`uname -r`/misc/vboxdrv.ko ]; then
-    if [ "$1" = "configure" ]; then
-      db_get virtualbox/module-compilation-allowed
-      if [ "$RET" = "false" ]; then
-        cat << EOF
-Unable to find a precompiled module for the current kernel
-though module compilation denied by debconf setting.
-EOF
-        POSTINST_START=--nostart
-      else
-        db_input low virtualbox/module-compilation-allowed || true
-        db_go || true
-        db_get virtualbox/module-compilation-allowed
-        if [ "$RET" = "false" ]; then
-          POSTINST_START=--nostart
-        fi
-      fi
-    fi # $1 = "configure"
-  fi
 fi
 
Index: /trunk/src/VBox/Installer/linux/debian/preinst.in
===================================================================
--- /trunk/src/VBox/Installer/linux/debian/preinst.in	(revision 58240)
+++ /trunk/src/VBox/Installer/linux/debian/preinst.in	(revision 58241)
@@ -61,37 +61,4 @@
   fi
 
-  # check for old vboxdrv modules
-  if [ "$INSTALL_NO_VBOXDRV" != "1" ]; then
-    if find /lib/modules -name "vboxdrv\.*" 2>/dev/null|grep -q vboxdrv; then
-      # old modules found
-      db_get virtualbox/delete-old-modules || true
-      if [ "$RET" = "false" ]; then
-        cat << EOF
-Old vboxdrv kernel modules found in
-EOF
-        find /lib/modules -name "vboxdrv\.*" 2>/dev/null|sed "s+\(.*\)+  \1+g"
-        cat << EOF
-Removing of these modules denied by debconf setting
-EOF
-      else
-        db_input low virtualbox/delete-old-modules || true
-        db_go || true
-        db_get virtualbox/delete-old-modules || true
-        if [ "$RET" = "true" ]; then
-          for i in /lib/modules/*; do
-            if test -e "${i}/misc/vboxdrv.ko"; then
-              rm -f "${i}/misc/vboxdrv.ko" "${i}/misc/vboxnetadp.ko" \
-                    "${i}/misc/vboxnetflt.ko" "${i}/misc/vboxpci.ko"
-              # Remove the kernel version folder if it was empty except for us.
-              test "`echo ${i}/misc/* ${i}/misc/.?* ${i}/* ${i}/.?*`" = \
-                   "${i}/misc/* ${i}/misc/.. ${i}/misc ${i}/.." &&
-                  rmdir "${i}/misc" "${i}"  # We used to leave empty folders.
-            fi
-          done
-        fi
-      fi
-    fi
-  fi
-
 fi # "$1" = "install" -o "$1" = "upgrade"
 
Index: /trunk/src/VBox/Installer/linux/debian/templates
===================================================================
--- /trunk/src/VBox/Installer/linux/debian/templates	(revision 58240)
+++ /trunk/src/VBox/Installer/linux/debian/templates	(revision 58241)
@@ -32,56 +32,4 @@
  mit Root-Rechten aus.
 
-Template: virtualbox/module-compilation-allowed
-Type: boolean
-Default: true
-Description: Should the vboxdrv kernel module be compiled now?
- Unable to find a precompiled module for the current kernel!
- .
- Without a suitable kernel module you will not be able to start any VMs. It is
- strongly recommended that you compile a kernel module now. This requires
- kernel headers and the tools to build kernel modules (gcc, make, binutils, ...).
- However if you know that a suitable kernel module already exists at another
- location, you might want to override the default by setting
- KDIR=<full_path_to_vboxdrv_module> in /etc/default/virtualbox. You can also
- build the module later by executing
-   
-   /sbin/vboxconfig
-   
- as root.
-Description-de.UTF-8: Soll das Kernmodul jetzt compiliert werden?
- Es konnte kein Kernmodul für den aktuellen Linux-Kern gefunden werden!
- .
- Ohne ein passendes Kernmodul können Sie keine VM starten. Daher sollten Sie
- jetzt ein Kernmodul compilieren. Dazu werden die Kern-Header und die Programme
- zum Bauen eines Kernmoduls (gcc, make, binutils, ...) benötigt. Falls Sie
- bereits ein passendes Kernmodul in ein anderes Verzeichnis installiert haben,
- können Sie den Verzeichnisnamen durch Hinzufügen von KDIR=<voller_Pfad_zu_vboxdrv>
- in der Datei /etc/default/virtualbox angeben. Sie können das Kernmodul auch
- später compilieren, indem Sie
-   
-   /sbin/vboxconfig
-   
- mit Root-Rechten ausführen.
-
-Template: virtualbox/delete-old-modules
-Type: boolean
-Default: true
-Description: Delete old vboxdrv kernel modules?
- Old vboxdrv kernel modules found. You should remove these modules as they
- might interfere with this version of VirtualBox. You can force re-compilation
- of the module later by executing
-   
-   /sbin/vboxconfig
-   
- as root.
-Description-de.UTF-8: Alte Kernmodule löschen?
- Es wurden alte vboxdrv-Kernmodule gefunden. Diese sollten gelöscht werden, da sie
- eventuell nicht mit dieser Version von VirtualBox zusammen arbeiten. Das Compilieren
- des Kernmoduls können Sie später durch
-   
-   /sbin/vboxconfig
-   
- erzwingen.
-
 Template: virtualbox/old-installation-found
 Type: note
Index: /trunk/src/VBox/Installer/linux/install.sh
===================================================================
--- /trunk/src/VBox/Installer/linux/install.sh	(revision 58240)
+++ /trunk/src/VBox/Installer/linux/install.sh	(revision 58241)
@@ -364,18 +364,9 @@
     # script set-up.
     if test "${BUILD_MODULE}" = "true"; then
-      for i in /lib/modules/*; do
-        if test -e "${i}/misc/vboxdrv.ko"; then
-          rm -f "${i}/misc/vboxdrv.ko" "${i}/misc/vboxnetadp.ko" \
-                "${i}/misc/vboxnetflt.ko" "${i}/misc/vboxpci.ko"
-          # Remove the kernel version folder if it was empty except for us.
-          test "`echo ${i}/misc/* ${i}/misc/.?* ${i}/* ${i}/.?*`" = \
-               "${i}/misc/* ${i}/misc/.. ${i}/misc ${i}/.." &&
-              rmdir "${i}/misc" "${i}"  # We used to leave empty folders.
-        fi
-      done
       START_SERVICES=
     else
       START_SERVICES="--nostart"
     fi
+    "${INSTALLATION_DIR}/prerm-common.sh" >> "${LOG}"
     "${INSTALLATION_DIR}/postinst-common.sh" ${START_SERVICES} >> "${LOG}"
 
Index: /trunk/src/VBox/Installer/linux/prerm-common.sh
===================================================================
--- /trunk/src/VBox/Installer/linux/prerm-common.sh	(revision 58240)
+++ /trunk/src/VBox/Installer/linux/prerm-common.sh	(revision 58241)
@@ -55,4 +55,6 @@
 delrunlevel vboxdrv
 remove_init_script vboxdrv
+# And do final clean-up
+"${MY_PATH}/vboxdrv.sh" cleanup
 # Stop host networking and uninstall runlevel script (obsolete)
 stop_init_script vboxnet 2>/dev/null
Index: /trunk/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec
===================================================================
--- /trunk/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec	(revision 58240)
+++ /trunk/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec	(revision 58241)
@@ -236,12 +236,4 @@
 fi
 
-# XXX remove old modules from previous versions (disable with INSTALL_NO_VBOXDRV=1 in /etc/default/virtualbox)
-if [ "$INSTALL_NO_VBOXDRV" != "1" ]; then
-  find /lib/modules -name "vboxdrv\.*" 2>/dev/null|xargs rm -f 2> /dev/null || true
-  find /lib/modules -name "vboxnetflt\.*" 2>/dev/null|xargs rm -f 2> /dev/null || true
-  find /lib/modules -name "vboxnetadp\.*" 2>/dev/null|xargs rm -f 2> /dev/null || true
-  find /lib/modules -name "vboxpci\.*" 2>/dev/null|xargs rm -f 2> /dev/null || true
-fi
-
 
 %post
@@ -287,22 +279,6 @@
 if test "${INSTALL_NO_VBOXDRV}" = 1; then
   POSTINST_START=--nostart
-  if lsmod | grep -q "vboxdrv[^_-]"; then
-    /usr/lib/virtualbox/vboxdrv.sh stop || true
-  fi
-  # if INSTALL_NO_VBOXDRV is set to 1, remove all shipped modules
-  rm -f /lib/modules/*/misc/vboxdrv.ko
-  rm -f /lib/modules/*/misc/vboxnetflt.ko
-  rm -f /lib/modules/*/misc/vboxnetadp.ko
-  rm -f /lib/modules/*/misc/vboxpci.ko
 else
   POSTINST_START=
-  if [ ! -f /lib/modules/`uname -r`/misc/vboxdrv.ko ]; then
-    # compile problem
-    cat << EOF
-No precompiled module for this kernel found -- trying to build one.  If this
-fails, check the messages logged to $LOG during module compilation.
-
-EOF
-  fi
 fi
 # Install and start the new service scripts.
Index: /trunk/src/VBox/Installer/linux/vboxdrv.sh
===================================================================
--- /trunk/src/VBox/Installer/linux/vboxdrv.sh	(revision 58240)
+++ /trunk/src/VBox/Installer/linux/vboxdrv.sh	(revision 58241)
@@ -376,29 +376,23 @@
 }
 
+cleanup()
+{
+    for i in /lib/modules/*; do
+        if test -e "${i}/misc/vboxdrv.ko"; then
+            rm -f "${i}/misc/vboxdrv.ko" "${i}/misc/vboxnetadp.ko" \
+                  "${i}/misc/vboxnetflt.ko" "${i}/misc/vboxpci.ko"
+            # Remove the kernel version folder if it was empty except for us.
+            test   "`echo ${i}/misc/* ${i}/misc/.?* ${i}/* ${i}/.?*`" \
+                 = "${i}/misc/* ${i}/misc/.. ${i}/misc ${i}/.." &&
+                rmdir "${i}/misc" "${i}"  # We used to leave empty folders.
+        fi
+    done
+}
+
 # setup_script
 setup()
 {
     begin_msg "Building VirtualBox kernel modules" console
-    if find /lib/modules/`uname -r` -name "vboxpci\.*" 2>/dev/null|grep -q vboxpci; then
-        begin_msg "Removing old VirtualBox pci kernel module"
-        find /lib/modules/`uname -r` -name "vboxpci\.*" 2>/dev/null|xargs rm -f 2>/dev/null
-        succ_msg
-    fi  
-    if find /lib/modules/`uname -r` -name "vboxnetadp\.*" 2>/dev/null|grep -q vboxnetadp; then
-        begin_msg "Removing old VirtualBox netadp kernel module"
-        find /lib/modules/`uname -r` -name "vboxnetadp\.*" 2>/dev/null|xargs rm -f 2>/dev/null
-        succ_msg
-    fi  
-    if find /lib/modules/`uname -r` -name "vboxnetflt\.*" 2>/dev/null|grep -q vboxnetflt; then
-        begin_msg "Removing old VirtualBox netflt kernel module"
-        find /lib/modules/`uname -r` -name "vboxnetflt\.*" 2>/dev/null|xargs rm -f 2>/dev/null
-        succ_msg
-    fi  
-    if find /lib/modules/`uname -r` -name "vboxdrv\.*" 2>/dev/null|grep -q vboxdrv; then
-        begin_msg "Removing old VirtualBox kernel module"
-        find /lib/modules/`uname -r` -name "vboxdrv\.*" 2>/dev/null|xargs rm -f 2>/dev/null
-        succ_msg
-    fi
-    begin_msg "Recompiling VirtualBox kernel modules"
+    cleanup
     if ! $BUILDINTMP \
         --save-module-symvers /tmp/vboxdrv-Module.symvers \
@@ -475,4 +469,10 @@
     stop && start
     ;;
+setup)
+    stop && setup
+    ;;
+cleanup)
+    stop && cleanup
+    ;;
 force-reload)
     stop
