Index: trunk/src/VBox/Installer/linux/debian/postinst
===================================================================
--- trunk/src/VBox/Installer/linux/debian/postinst	(revision 84450)
+++ trunk/src/VBox/Installer/linux/debian/postinst	(revision 84968)
@@ -69,6 +69,8 @@
     chmod 4511 /usr/lib/virtualbox/VBoxHeadless
   fi
-  if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxSDL > /dev/null 2>&1; then
-    chmod 4511 /usr/lib/virtualbox/VBoxSDL
+  if [ -x /usr/lib/virtualbox/VBoxSDL ]; then
+    if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxSDL > /dev/null 2>&1; then
+      chmod 4511 /usr/lib/virtualbox/VBoxSDL
+    fi
   fi
   if ! dpkg-statoverride --list /usr/lib/virtualbox/VBoxNetDHCP > /dev/null 2>&1; then
Index: trunk/src/VBox/Installer/linux/debian/rules
===================================================================
--- trunk/src/VBox/Installer/linux/debian/rules	(revision 84450)
+++ trunk/src/VBox/Installer/linux/debian/rules	(revision 84968)
@@ -34,7 +34,8 @@
 #                   either the subversion rev [if available] or the build date)
 #  NODOCS=1         don't build docs, use precompiled UserManual.pdf and
-#                   VirtualBox.chm from $HOME
+#                   maybe VirtualBox.chm from $(vboxroot)/prebuild
 #  NOMODS=1         don't build any module
 #  NOQT=1           don't build the Qt GUI
+#  NOSDL=1          don't build VBoxSDL
 #  EFI=1            include the EFI binary from prebuild
 #  VERSUFFIX=<suffix> set a particular package version suffix (e.g. _customer)
@@ -43,16 +44,19 @@
 #  NOWEBSVC=1       don't build the webservice API, default for OSE
 #  STAGEDISO=<path> don't build the VBoxAdditions, use the precompiled .iso
+#  STAGEDCHM=<path> use VirtualBox*.chm from this directory
 #  PKGDIR=<path>    where to store the final package(s)
 #
-# NODOCS will also be set if UserManual*.pdf and VirtualBox*.chm are placed in
-# $(vboxroot)/prebuild.  STAGEDISO will be set if VBoxGuestAdditions.iso is
-# placed there.  Wine will not be required to be available if both NODOCS and
-# STAGEDISO are set.
+# NODOCS will be set if UserManual*.pdf is placed in $(vboxroot)/prebuild.
+# STAGEDISO will be set if VBoxGuestAdditions.iso is placed there.
+# STAGEDCHM will be set if VirtualBox*.chm is placed there.
+# VirtualBox*.chm is used if it is provided, but never attempted to be built.
+#
+# Wine will not be required if either NODOCS or STAGEDISO are set.
 
 package  := virtualbox
 verpkg   := virtualbox-6.1
 current  := $(shell pwd)
-vboxroot := $(shell cd ../../../..; pwd)
-pkgdir   := $(if $(PKGDIR),$(PKGDIR),$(shell cd ../../../../..; pwd))
+vboxroot := $(shell while ! test -r configure && ! test "$PWD" = "/"; do cd ..; done; pwd)
+pkgdir   := $(if $(PKGDIR),$(PKGDIR),$(shell cd $(vboxroot)/..; pwd))
 builddir := $(vboxroot)/out/debian/builddir
 moddir   := $(vboxroot)/out/debian/modules
@@ -64,10 +68,13 @@
 -include $(vboxroot)/SVN_REVISION
 svnrev   :=$(if $(svn_revision),$(svn_revision),)
+
 NOMODS   ?= $(ose)
 NOQT     ?= $(HEADLESS)
+NOSDL    ?= $(HEADLESS)
 NOWEBSVC ?= $(ose)
-NODOCS   ?= $(if $(wildcard $(vboxroot)/prebuild/UserManual*.pdf),$(if $(wildcard $(vboxroot)/prebuild/VirtualBox*.chm),1,),)
+NODOCS   ?= $(if $(wildcard $(vboxroot)/prebuild/UserManual*.pdf),1,)
 STAGEDISO ?= $(if $(wildcard $(vboxroot)/prebuild/VBoxGuestAdditions.iso),$(vboxroot)/prebuild,)
-NOWINE   := $(if $(NODOCS),$(if $(STAGEDISO),1,),)$(ose)
+STAGEDCHM ?= $(if $(wildcard $(vboxroot)/prebuild/VirtualBox*.chm),$(vboxroot)/prebuild,)
+NOWINE   := $(if $(NODOCS),1,$(if $(STAGEDISO),1,$(ose)))
 PYTHON   := $(firstword $(shell which python) $(shell which python3))
 
@@ -100,4 +107,5 @@
 
 cfg_flags := $(if $(NOQT),--disable-qt,) \
+	     $(if $(NOSDL),--disable-vboxsdl,) \
 	     $(if $(ose),--ose,) $(if $(LINUX),--with-linux=$(LINUX),) \
 	     $(if $(HEADLESS),--build-headless,) \
@@ -116,5 +124,5 @@
 	     VBOX_DO_STRIP= \
 	     VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(verpkg)\"" \
-	     $(if $(ose),,VBOX_WITH_DOCS_CHM=1) \
+	     $(if $(STAGEDCHM),VBOX_WITH_DOCS_CHM=1,VBOX_WITH_KCHMVIEWER=) \
 	     VBOX_PACKAGE_DIST=$(debdist) \
 	     $(if $(svnrev),VBOX_SVN_REV=$(svnrev),) \
@@ -134,5 +142,5 @@
 	. debian/env.sh && kmk -C $(vboxroot) $(bld_flags) $(if $(NOPARALLEL),-j1,) all
 	$(if $(NODOCS),cp $(vboxroot)/prebuild/UserManual*.pdf $(builddir)/bin,)
-	$(if $(NODOCS),cp $(vboxroot)/prebuild/VirtualBox*.chm $(builddir)/bin,)
+	$(if $(STAGEDCHM),cp $(STAGEDCHM)/VirtualBox*.chm $(builddir)/bin,)
 	$(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI32.fd $(builddir)/bin,)
 	$(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI64.fd $(builddir)/bin,)
@@ -290,6 +298,6 @@
 	    usr/bin/VBox                        usr/bin/VBoxManage \
 	    usr/bin/VBox                        usr/bin/vboxmanage \
-	    $(if $(HEADLESS),,usr/bin/VBox      usr/bin/VBoxSDL) \
-	    $(if $(HEADLESS),,usr/bin/VBox      usr/bin/vboxsdl) \
+	    $(if $(NOSDL),,usr/bin/VBox         usr/bin/VBoxSDL) \
+	    $(if $(NOSDL),,usr/bin/VBox         usr/bin/vboxsdl) \
 	    $(if $(ose),,usr/bin/VBox           usr/bin/VBoxVRDP) \
 	    usr/bin/VBox                        usr/bin/VBoxHeadless \
