Index: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	(revision 90118)
+++ trunk/debian/changelog	(revision 90354)
@@ -1,2 +1,8 @@
+virtualbox-ose (6.1.97) unstable; urgency=low
+
+  * rebuild Debian package.
+
+ -- Oracle Corporation <info@virtualbox.org>  Tue, 21 Jul 2021 12:00:00 +0200
+
 virtualbox-ose (6.1.4) unstable; urgency=low
 
@@ -11,5 +17,4 @@
  -- Oracle Corporation <info@virtualbox.org>  Tue, 14 Jan 2020 12:00:00 +0200
 
-
 virtualbox-ose (6.1.0) unstable; urgency=low
 
Index: trunk/debian/compat
===================================================================
--- trunk/debian/compat	(revision 90118)
+++ trunk/debian/compat	(revision 90354)
@@ -1,1 +1,1 @@
-5
+9
Index: trunk/debian/rules
===================================================================
--- trunk/debian/rules	(revision 90118)
+++ trunk/debian/rules	(revision 90354)
@@ -18,5 +18,4 @@
 
 #export DH_VERBOSE=1
-export DH_COMPAT=5
 
 # possible overrides:
@@ -28,6 +27,6 @@
 #  NOSUBVER=1       disable generation of the sub-version field (which is
 #                   either the subversion rev [if available] or the build date)
-#  NODOCS=1         don't build docs, use precompiled UserManual.pdf and
-#                   maybe VirtualBox.qch and VirtualBox.qhc from $(vboxroot)/prebuild
+#  NODOCS=1         don't build docs, use precompiled UserManual*.pdf and
+#                   maybe UserManual*.qch and UserManual*.qhc from $(vboxroot)/prebuild
 #  NOMODS=1         don't build any module
 #  NOQT=1           don't build the Qt GUI
@@ -36,26 +35,27 @@
 #  HEADLESS=1       build the headless version
 #  VNC=1            build VNC code
-#  NOWEBSVC=1       don't build the webservice API, default for OSE
+#  NOWEBSVC=1       don't build the webservice API
 #  STAGEDISO=<path> don't build the VBoxAdditions, use the precompiled .iso
-#  STAGEDQHELP=<path> use VirtualBox*.qch and VirtualBox*.qhc from this directory
 #  PKGDIR=<path>    where to store the final package(s)
-#
-# NODOCS will be set if UserManual*.pdf is placed in $(vboxroot)/prebuild.
+#  svn_revision=xxx do not depend on subversion being available, but use this
+#                   hard-coded revision number instead
+#
+# NODOCS will be set if UserManual*.pdf, UserManual*.qch and UserManual*.qhc are
+# placed in $(vboxroot)/prebuild.
 # STAGEDISO will be set if VBoxGuestAdditions.iso is placed there.
-# STAGEDQHELP will be set if VirtualBox*.qch and VirtualBox*.qhc is placed there.
-# VirtualBox*.qch and VirtualBox*.qhc are used if they are provided, but never
-# attempted to be built.
-#
-# Wine will not be required if either NODOCS or STAGEDISO are set.
+#
+# Wine will not be required if STAGEDISO is set.
 
 package  := virtualbox
 verpkg   := virtualbox-ose
-current  := $(shell pwd)
-vboxroot := $(shell pwd)
-pkgdir   := $(if $(PKGDIR),$(PKGDIR),$(shell cd ..; pwd))
-bldbase  := $(if $(PATH_OUT_BASE),$(PATH_OUT_BASE),$(vboxroot))/out/debian
+vboxroot := $(shell while ! test -r configure && ! test "$$PWD" = "/"; do cd ..; done; pwd)
+debroot  := $(vboxroot)
+instlin  := $(vboxroot)/src/VBox/Installer/linux
+pkgdir   := $(if $(PKGDIR),$(PKGDIR),$(shell cd $(vboxroot)/..; pwd))
+outdir   := $(if $(PATH_OUT_BASE),$(PATH_OUT_BASE),$(vboxroot))/out
+bldbase  := $(outdir)/debian
 builddir := $(bldbase)/builddir
 moddir   := $(bldbase)/modules
-prefix   := $(current)/debian/$(verpkg)
+prefix   := $(bldbase)/$(verpkg)
 arch     := $(shell dpkg --print-architecture)
 verfile  := $(builddir)/version-generated.mk
@@ -65,16 +65,12 @@
 NOQT     ?= $(HEADLESS)
 NOSDL    ?= $(HEADLESS)
-NOWEBSVC ?= $(ose)
-NODOCS   ?= $(if $(wildcard $(vboxroot)/prebuild/UserManual*.pdf),1,)
+NOWEBSVC ?=
+EFI      ?= $(if $(wildcard $(vboxroot)/prebuild/VBoxEFI32.fd $(vboxroot)/prebuild/VBoxEFI64.fd),1,)
+NODOCS   ?= $(if $(wildcard $(addprefix $(vboxroot)/prebuild/,UserManual*.pdf UserManual*.qch UserManual.qhc)),1,)
 STAGEDISO ?= $(if $(wildcard $(vboxroot)/prebuild/VBoxGuestAdditions.iso),$(vboxroot)/prebuild,)
-STAGEDQHELP ?= $(if $(and $(wildcard $(vboxroot)/prebuild/VirtualBox*.qch),$(wildcard $(vboxroot)/prebuild/VirtualBox*.qhc)),$(vboxroot)/prebuild,)
-NOWINE   := $(if $(NODOCS),1,$(if $(STAGEDISO),1,$(ose)))
-PYTHON   := $(firstword $(shell which python) $(shell which python3))
-
-ifneq ($(wildcard $(verfile)),)
-include $(verfile)
-ver      := $(VBOX_VERSION_STRING)
-archdir  := $(prefix)/opt/VirtualBox-$(ver)
-endif
+NOWINE   := $(if $(STAGEDISO),1,$(ose))
+PYTHON   := $(firstword $(shell which python3) $(shell which python))
+
+DEBPKGFILES := changelog compat control dirs postinst postrm preinst prerm rules templates
 
 ifneq ($(STAGEDISO),)
@@ -84,48 +80,67 @@
 endif
 
-debrel  := $(if $(shell which lsb_release),_$(shell lsb_release -si)_$(shell lsb_release -sc),unknown)
+# Replicate debian package buildfiles to $(bldbase)
+ifneq ($(shell pwd),$(outdir))
+cmd := $(filter-out all Makefile,$(MAKECMDGOALS))
+all:
+	mkdir -p $(bldbase)
+	ln -sf $(addprefix $(debroot)/debian/,$(DEBPKGFILES)) $(bldbase)
+	+$(MAKE) -C $(outdir) -f debian/rules $(cmd)
+
+Makefile:
+
+$(cmd): all
+
+.PHONY: all $(MAKECMDGOALS)
+
+else
+ ifneq ($(wildcard $(verfile)),)
+include $(verfile)
+ver      := $(VBOX_VERSION_STRING)
+archdir  := $(prefix)/opt/VirtualBox-$(ver)
+ endif
 
 cfg_flags := $(if $(NOQT),--disable-qt,) \
-	     $(if $(NOSDL),--disable-vboxsdl,) \
-	     $(if $(ose),--ose,) $(if $(LINUX),--with-linux=$(LINUX),) \
-	     $(if $(HEADLESS),--build-headless,) \
-	     $(if $(DEBUG),--build-debug,) \
-	     $(if $(NOWINE),,--setup-wine) \
-	     $(if $(NOWEBSVC),,$(if $(ose),--enable-webservice,)) \
-	     $(if $(VNC),--enable-vnc,) \
-	     $(if $(PATH_OUT_BASE),--out-base-dir=$(PATH_OUT_BASE),) \
-	     --disable-extpack
-
-bld_flags := AUTOCFG=$(current)/debian/AutoConfig.kmk \
-	     LOCALCFG=$(current)/debian/LocalConfig.kmk \
-	     PATH_OUT=$(builddir) \
-	     VBOX_WITHOUT_EXTPACK_PUEL_PACKING=1 \
-	     VBOX_WITHOUT_EXTPACK_VNC_PACKING=1 \
-	     VBOX_WITH_VMSVGA3D=1 \
-	     VBOX_DO_STRIP= \
-	     VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(verpkg)\"" \
-	     $(if $(STAGEDQHELP),VBOX_WITH_DOCS_QHELP=1,) \
-	     $(if $(svnrev),VBOX_SVN_REV=$(svnrev),) \
-	     $(if $(NODOCS),VBOX_WITH_DOCS= ,) \
-	     $(if $(VERBOSE),--print-directory KBUILD_VERBOSE=2,--no-print-directory) \
-	     $(if $(STAGEDISO),VBOX_WITHOUT_ADDITIONS=1,)
-
-configure: debian/configure-stamp
-debian/configure-stamp:
+    $(if $(NOSDL),--disable-vboxsdl,) \
+    $(if $(ose),--ose,) $(if $(LINUX),--with-linux=$(LINUX),) \
+    $(if $(HEADLESS),--build-headless,) \
+    $(if $(DEBUG),--build-debug,) \
+    $(if $(NOWINE),,--setup-wine) \
+    $(if $(VNC),--enable-vnc,) \
+    $(if $(PATH_OUT_BASE),--out-base-dir=$(PATH_OUT_BASE),) \
+    --disable-extpack
+
+bld_flags := AUTOCFG=$(bldbase)/AutoConfig.kmk \
+    LOCALCFG=$(debroot)/debian/LocalConfig.kmk \
+    PATH_OUT=$(builddir) \
+    VBOX_WITHOUT_EXTPACK_PUEL_PACKING=1 \
+    VBOX_WITHOUT_EXTPACK_VNC_PACKING=1 \
+    VBOX_WITH_VMSVGA3D=1 \
+    VBOX_DO_STRIP= \
+    VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(verpkg)\"" \
+    $(if $(svnrev),VBOX_SVN_REV=$(svnrev),) \
+    $(if $(NODOCS),VBOX_WITH_DOCS= ,) \
+    $(if $(VERBOSE),--print-directory KBUILD_VERBOSE=2,--no-print-directory) \
+    $(if $(STAGEDISO),VBOX_WITHOUT_ADDITIONS=1,)
+
+configure: $(bldbase)/configure-stamp
+$(bldbase)/configure-stamp:
 	dh_testdir
+	mkdir -p $(bldbase)
 	cd $(vboxroot) && ./configure --odir=$(bldbase) $(cfg_flags)
-	touch debian/configure-stamp
-
-build: debian/configure-stamp debian/build-stamp
-debian/build-stamp $(verfile):
+	touch $@
+
+build: $(bldbase)/configure-stamp $(bldbase)/build-stamp
+$(bldbase)/build-stamp $(verfile): $(bldbase)/configure-stamp
 	dh_testdir
-	. debian/env.sh && kmk -C $(vboxroot) $(bld_flags) $(if $(NOPARALLEL),-j1,) all
-	$(if $(NODOCS),cp $(vboxroot)/prebuild/UserManual*.pdf $(builddir)/bin,)
-	$(if $(STAGEDQHELP),cp $(STAGEDQHELP)/VirtualBox*.qch $(STAGEDQHELP)/VirtualBox*.qhc $(builddir)/bin,)
+	. $(bldbase)/env.sh && kmk -C $(vboxroot) $(bld_flags) $(if $(NOPARALLEL),-j1,) all
+	# Files from prebuild go to (builddir)/bin to be used during the
+	# packing stage, overriding what the build did/would produce.
+	$(if $(NODOCS),cp $(addprefix $(vboxroot)/prebuild/,UserManual*.pdf UserManual*.qch UserManual.qhc) $(builddir)/bin,)
 	$(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI32.fd $(builddir)/bin,)
 	$(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI64.fd $(builddir)/bin,)
 	mkdir -p $(builddir)/bin/additions
 	$(if $(STAGEDISO),cp $(STAGEDISO)/VBoxGuestAdditions.iso $(builddir)/bin/additions,)
-	. debian/env.sh && kmk -C $(vboxroot) $(bld_flags) \
+	. $(bldbase)/env.sh && kmk -C $(vboxroot) $(bld_flags) \
 	    VBOX_NO_LINUX_RUN_INSTALLER=1 \
 	    VBOX_LNX_ADD_ARCHIVE.x86=$(builddir)/bin/additions/VBoxGuestAdditions-x86.tar.bz2 \
@@ -134,9 +149,8 @@
 	    VBOX_PATH_ADDITIONS.linux.amd64=$(builddir)/bin/additions \
 	    packing
-	touch debian/build-stamp
+	touch $(bldbase)/build-stamp
 
 # Build modules for every kernel we find in /lib/modules/*
-modules: debian/build-stamp debian/modules-stamp
-debian/modules-stamp: debian/build-stamp
+$(bldbase)/modules-stamp: $(bldbase)/build-stamp
 	rm -rf $(moddir)
 	mkdir $(moddir)
@@ -157,26 +171,33 @@
 	    fi; \
 	done
-	touch debian/modules-stamp
+	touch $@
 
 clean:
 	dh_testdir
 	dh_testroot
-	rm -f debian/AutoConfig.kmk debian/configure.log debian/env.sh
-	rm -f debian/modules-stamp debian/build-stamp debian/configure-stamp
-	rm -f debian/virtualbox-*.substvars debian/virtualbox*.debhelper
-	rm -f debian/$(verpkg).mime
-	rm -rf $(builddir) $(moddir)
-	rm -rf debian/wine.*
 	dh_clean
-
-ifeq ($(VBOX_VERSION_MAJOR),)
-binary binary-arch binary-indep: build $(verfile)
-	$(MAKE) -f debian/rules binary
-else
+	rm -rf $(archdir)
+	rm -rf $(builddir)
+	rm -rf $(moddir)
+	rm -rf $(bldbase)/wine.*
+	rm -rf $(bldbase)/VirtualBox-*
+	rm -f $(bldbase)/VirtualBox.tar $(bldbase)/VirtualBox.tar.bz2
+	rm -f $(bldbase)/virtualbox-*.substvars $(bldbase)/virtualbox*.debhelper
+	rm -f $(bldbase)/$(verpkg).mime $(bldbase)/$(verpkg).sharedmimeinfo
+	rm -f $(bldbase)/modules-stamp $(bldbase)/build-stamp $(bldbase)/configure-stamp
+	rm -f $(bldbase)/AutoConfig.kmk $(bldbase)/configure.log $(bldbase)/env.sh
+	rm -f $(addprefix $(bldbase)/,$(DEBPKGFILES))
+	if [ -d $(bldbase) ]; then rmdir $(bldbase); fi
+
+ ifeq ($(VBOX_VERSION_MAJOR),)
+binary: build $(verfile)
+	+$(MAKE) -f debian/rules binary
+
+ else
 # Build architecture-dependent files here.
-binary binary-arch binary-indep: build $(if $(NOMODS),,modules)
+binary: build $(if $(NOMODS),,$(bldbase)/modules-stamp)
 	dh_testdir
 	dh_testroot
-	dh_clean -k
+	dh_prep
 	dh_installdirs
 	tar -xC $(prefix)/opt -f $(builddir)/bin/VirtualBox.tar
@@ -207,9 +228,9 @@
 	done)
 	$(if $(NOQT),,rmdir $(archdir)/icons)
-	$(if $(NOQT),,mv $(archdir)/virtualbox.xml debian/$(verpkg).sharedmimeinfo)
+	$(if $(NOQT),,mv $(archdir)/virtualbox.xml $(bldbase)/$(verpkg).sharedmimeinfo)
 	install -d -g 0 -o 0 $(prefix)/usr/share/lintian/overrides
 	sed \
 	    -e 's|%VERPKG%|$(verpkg)|g' \
-	    debian/lintian-override.in > \
+	    $(vboxroot)/debian/lintian-override.in > \
 	   $(prefix)/usr/share/lintian/overrides/$(verpkg)
 	mv $(archdir)/VBox.png \
@@ -217,5 +238,5 @@
 	mv $(archdir)/src  $(prefix)/usr/share/$(package)
 	rm $(archdir)/VBox.sh
-	install -D -g 0 -o 0 -m 644 $(vboxroot)/src/VBox/Installer/linux/VBox.sh $(prefix)/usr/bin/VBox
+	install -D -g 0 -o 0 -m 644 $(instlin)/VBox.sh $(prefix)/usr/bin/VBox
 	mv $(archdir)/VBoxSysInfo.sh $(prefix)/usr/share/$(package)
 	if [ -r $(archdir)/VBoxDTrace ]; then \
@@ -237,21 +258,8 @@
 	    fi \
 	    done)
-ifeq ($(ose),)
-	dh_installdocs \
-	    $(addprefix $(archdir)/,UserManual*.pdf VirtualBox*.qch VirtualBox*.qhc \
-	    LICENSE)
-	rm $(addprefix $(archdir)/,UserManual*.pdf VirtualBox*.qch VirtualBox*.qhc \
-	    LICENSE)
-	for i in rdesktop-vrdp.tar.gz additions/VBoxGuestAdditions.iso; do \
-	    mv $(archdir)/$$i $(prefix)/usr/share/$(package); done
+	dh_installdocs $(addprefix $(archdir)/,UserManual*.pdf LICENSE)
+	mv $(addprefix $(archdir)/,$(if $(HEADLESS),,rdesktop-vrdp.tar.gz) additions/VBoxGuestAdditions.iso) $(prefix)/usr/share/$(package)
 	$(if $(HEADLESS),,mv $(archdir)/rdesktop-vrdp $(prefix)/usr/bin)
 	$(if $(HEADLESS),,mv $(archdir)/rdesktop-vrdp-keymaps $(prefix)/usr/share/$(package))
-else
-	dh_installdocs \
-	    $(archdir)/UserManual*.pdf
-	rm $(addprefix $(archdir)/,UserManual*.pdf)
-	for i in additions/VBoxGuestAdditions.iso; do \
-	    mv $(archdir)/$$i $(prefix)/usr/share/$(package); done
-endif
 	mv $(archdir) $(prefix)/usr/lib/$(package)
 	if [ -f $(prefix)/usr/lib/$(package)/libQt5CoreVBox.so.5 ]; then \
@@ -260,4 +268,7 @@
 	        $(prefix)/usr/lib/$(package)/*.so.5 \
 	        $(prefix)/usr/lib/$(package)/plugins/platforms/*.so; \
+	        $(prefix)/usr/lib/$(package)/plugins/platformthemes/*.so; \
+	        $(prefix)/usr/lib/$(package)/plugins/sqldrivers/*.so; \
+	        $(prefix)/usr/lib/$(package)/plugins/styles/*.so; \
 	        $(prefix)/usr/lib/$(package)/plugins/xcbglintegrations/*.so; \
 	    echo "[Paths]" > $(prefix)/usr/lib/$(package)/qt.conf; \
@@ -279,5 +290,4 @@
 	    $(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 \
 	    usr/bin/VBox                        usr/bin/vboxheadless \
@@ -298,17 +308,16 @@
 	dh_installmime
 	dh_link
-ifeq ($(DEBUG),)
+  ifeq ($(DEBUG),)
 	dh_strip --keep-debug \
 	    $(addprefix --exclude=lib,$(addsuffix VBox.so.5,\
-	      Qt5Core Qt5Gui Qt5Widgets Qt5PrintSupport Qt5OpenGL Qt5DBus Qt5XcbQpa Qt5X11Extras)) \
-	    --exclude=libqxcb.so --exclude=libqxcb-glx-integration.so
-endif
-	mkdir -p $(current)/debian/$(verpkg)-dbg/usr/lib/$(package)
-	mv $(prefix)/usr/lib/$(package)/*.debug $(current)/debian/$(verpkg)-dbg/usr/lib/$(package)
-ifeq ($(DEBUG),)
-	mv $(prefix)/usr/lib/debug $(current)/debian/$(verpkg)-dbg/usr/lib
-endif
-	$(firstword $(shell which dh_python2) $(shell which dh_python3))
-	dh_compress -X.pdf -X LICENSE -X.py
+	      Qt5Core Qt5Gui Qt5Widgets Qt5PrintSupport Qt5OpenGL Qt5DBus Qt5XcbQpa Qt5X11Extras))
+  endif
+	mkdir -p $(bldbase)/$(verpkg)-dbg/usr/lib/$(package)
+	mv $(prefix)/usr/lib/$(package)/*.debug $(bldbase)/$(verpkg)-dbg/usr/lib/$(package)
+  ifeq ($(DEBUG),)
+	mv $(prefix)/usr/lib/debug $(bldbase)/$(verpkg)-dbg/usr/lib
+  endif
+	$(firstword $(shell which dh_python3) $(shell which dh_python2))
+	dh_compress -X.pdf -X.qch -X.qhc -X LICENSE -X.py
 	dh_fixperms
 	dh_makeshlibs
@@ -323,5 +332,6 @@
 	dh_md5sums
 	dh_builddeb --destdir $(pkgdir) -- -Zxz
+ endif
+
+.PHONY: binary configure build clean
 endif
-
-.PHONY: binary modules binary-arch binary-indep clean checkroot
