summaryrefslogtreecommitdiffstats
path: root/src/VBox/Installer/linux
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-11 08:17:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-11 08:17:27 +0000
commitf215e02bf85f68d3a6106c2a1f4f7f063f819064 (patch)
tree6bb5b92c046312c4e95ac2620b10ddf482d3fa8b /src/VBox/Installer/linux
parentInitial commit. (diff)
downloadvirtualbox-f215e02bf85f68d3a6106c2a1f4f7f063f819064.tar.xz
virtualbox-f215e02bf85f68d3a6106c2a1f4f7f063f819064.zip
Adding upstream version 7.0.14-dfsg.upstream/7.0.14-dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/VBox/Installer/linux')
-rw-r--r--src/VBox/Installer/linux/Makefile-footer.gmk145
-rw-r--r--src/VBox/Installer/linux/Makefile-header.gmk301
-rw-r--r--src/VBox/Installer/linux/Makefile.kmk595
-rw-r--r--src/VBox/Installer/linux/README.testing35
-rwxr-xr-xsrc/VBox/Installer/linux/VBox.sh158
-rwxr-xr-xsrc/VBox/Installer/linux/VBoxCreateUSBNode.sh61
-rwxr-xr-xsrc/VBox/Installer/linux/VBoxSysInfo.sh142
-rwxr-xr-xsrc/VBox/Installer/linux/check_module_dependencies.sh227
-rwxr-xr-xsrc/VBox/Installer/linux/deffiles615
-rw-r--r--src/VBox/Installer/linux/distributions_deb8
-rw-r--r--src/VBox/Installer/linux/distributions_rpm11
-rwxr-xr-xsrc/VBox/Installer/linux/install.sh448
-rwxr-xr-xsrc/VBox/Installer/linux/postinst-common.sh125
-rwxr-xr-xsrc/VBox/Installer/linux/prerm-common.sh81
-rw-r--r--src/VBox/Installer/linux/routines.sh471
-rw-r--r--src/VBox/Installer/linux/rpm/LocalConfig.kmk44
-rw-r--r--src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec371
-rwxr-xr-xsrc/VBox/Installer/linux/rpm/rules282
-rwxr-xr-xsrc/VBox/Installer/linux/runasroot.sh188
-rwxr-xr-xsrc/VBox/Installer/linux/scripts/VBoxHeadlessXOrg.sh369
-rw-r--r--src/VBox/Installer/linux/testcase/Makefile.kmk37
-rwxr-xr-xsrc/VBox/Installer/linux/testcase/tstHeadlessXOrg.sh315
-rwxr-xr-xsrc/VBox/Installer/linux/uninstall.sh166
-rwxr-xr-xsrc/VBox/Installer/linux/vboxautostart-service.sh184
-rwxr-xr-xsrc/VBox/Installer/linux/vboxballoonctrl-service.sh218
-rwxr-xr-xsrc/VBox/Installer/linux/vboxdrv.sh899
-rwxr-xr-xsrc/VBox/Installer/linux/vboxweb-service.sh234
27 files changed, 6730 insertions, 0 deletions
diff --git a/src/VBox/Installer/linux/Makefile-footer.gmk b/src/VBox/Installer/linux/Makefile-footer.gmk
new file mode 100644
index 00000000..82093fe5
--- /dev/null
+++ b/src/VBox/Installer/linux/Makefile-footer.gmk
@@ -0,0 +1,145 @@
+# $Id: Makefile-footer.gmk $
+## @file
+# VirtualBox Guest Additions kernel module Makefile, common parts.
+#
+# See Makefile-header.gmk for details of how to use this.
+#
+
+#
+# Copyright (C) 2006-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+VBOXMOD_0_TARGET = $(VBOXMOD_NAME)
+
+KBUILD_VERBOSE ?= 1 # Variable belongs to our kBuild, not the linux one.
+VBOX_LNX_VERBOSE = $(if $(KBUILD_VERBOSE),1,)
+
+#
+# Compiler options
+#
+VBOXMOD_0_KFLAGS := -D__KERNEL__ -DMODULE -DRT_WITHOUT_PRAGMA_ONCE $(addprefix -D,$(VBOXMOD_DEFS))
+ifeq ($(VBOX_KBUILD_TARGET_ARCH),amd64)
+VBOXMOD_0_KFLAGS += -DRT_ARCH_AMD64
+else
+VBOXMOD_0_KFLAGS += -DRT_ARCH_X86
+endif
+
+ifeq ($(VBOX_KBUILD_TYPE),debug)
+# The -Wno-array-bounds is because of a bug in gcc 4.something, see
+# https://sourceware.org/bugzilla/show_bug.cgi?id=10001
+ VBOXMOD_0_KFLAGS += -DDEBUG -DDEBUG_$(subst $(subst _, ,_),_,$(USERNAME)) -DDEBUG_USERNAME=$(subst $(subst _, ,_),_,$(USERNAME))
+ ifeq ($(shell expr $(KERN_VER) : '[23]\.'),0)
+ VBOXMOD_0_KFLAGS += -Werror -Wall -Wno-array-bounds
+# clang objects to calls to __builtin_frame_address with a non-zero argument
+# on general principles in -Wall mode. The x86 linux kernel has two such calls
+# in the thread_info.h / arch_within_stack_frames(), though probably safe.
+ ifndef ($(LLVM),) # (This is how the Linux root Makefile (since 5.7) does the test.)
+ VBOXMOD_0_KFLAGS += -Wno-frame-address
+ endif
+ endif
+endif
+
+ifeq ($(VBOX_KERN_GROKS_EXTMOD),)
+#
+# Pre 2.6.6
+#
+# Note: While pre 2.6.6 kernels could also do "proper" builds from kbuild, the
+# make script needed to support it was somewhat different from 2.6. Since this
+# script works and pre-2.6.6 is not a moving target we will not try do do things
+# the "proper" way.
+#
+VBOXMOD_EXT := o
+
+ ifeq ($(VBOX_KBUILD_TARGET_ARCH),amd64)
+VBOXMOD_0_KFLAGS += -mcmodel=kernel
+ endif
+ ifeq ($(KERN_VERSION),24)
+VBOXMOD_0_KFLAGS += -DVBOX_LINUX_2_4
+ endif
+
+CFLAGS := -O2 $(VBOXMOD_CFLAGS) $(addprefix -I,$(KERN_INCL) $(VBOXMOD_INCL)) $(VBOXMOD_0_KFLAGS) $(KDEBUG)
+
+# 2.4 Module linking
+$(VBOXMOD_0_TARGET).$(VBOXMOD_EXT): $(VBOXMOD_OBJS)
+ $(LD) -o $@ -r $(VBOXMOD_OBJS)
+
+all: $(VBOXMOD_0_TARGET)
+$(VBOXMOD_0_TARGET): $(VBOXMOD_0_TARGET).$(VBOXMOD_EXT)
+
+install: $(VBOXMOD_0_TARGET)
+ @mkdir -p $(MODULE_DIR); \
+ install -m 0644 -o root -g root $(VBOXMOD_0_TARGET).$(VBOXMOD_EXT) $(MODULE_DIR); \
+ PATH="$(PATH):/bin:/sbin" depmod -a; sync
+
+clean:
+ for f in $(sort $(dir $(VBOXMOD_OBJS))); do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
+ rm -rf .$(VBOXMOD_NAME)* .tmp_ver* $(VBOXMOD_NAME).* Modules.symvers modules.order
+
+.PHONY: all $(VBOXMOD_0_TARGET) install clean
+
+else # VBOX_KERN_GROKS_EXTMOD
+#
+# 2.6.6 and later
+#
+VBOXMOD_EXT := ko
+
+# build defs
+EXTRA_CFLAGS += $(VBOXMOD_CFLAGS) $(addprefix -I,$(KERN_INCL) $(VBOXMOD_INCL)) $(VBOXMOD_0_KFLAGS) $(KDEBUG)
+$(VBOXMOD_0_TARGET)-y := $(VBOXMOD_OBJS)
+obj-m += $(VBOXMOD_0_TARGET).o
+
+# Trigger parallel make job.
+ ifndef VBOX_NOJOBS
+JOBS := $(shell (getconf _NPROCESSORS_ONLN || grep -Ec '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null)
+ ifeq ($(JOBS),0)
+ override JOBS := 1
+ endif
+ else
+JOBS :=
+ endif
+
+VBOX_SUBDIR_VAR=$(if $(VBOX_KERN_GROKS_SUBDIRS),SUBDIRS,M)
+
+# OL/UEK: CONFIG_MODULE_SIG= disables module signing for external modules.
+# Ubuntu 18.04.3: CONFIG_MODULE_SIG_ALL= disables signing of all modules.
+# We disable signing because we don't have any private key and want to leave
+# the key handling and secure boot config to the user.
+ ifndef VBOX_ALLOW_MODULE_SIGNING
+VBOX_DISABLE_SIGN=CONFIG_MODULE_SIG= CONFIG_MODULE_SIG_ALL=
+ endif
+
+# rules:
+all: $(VBOXMOD_0_TARGET)
+
+$(VBOXMOD_0_TARGET):
+ $(MAKE) V=$(VBOX_LNX_VERBOSE) $(VBOX_DISABLE_SIGN) -C $(KERN_DIR) $(VBOX_SUBDIR_VAR)=$(CURDIR) SRCROOT=$(CURDIR) $(if $(JOBS),-j$(JOBS),) modules
+
+install: $(VBOXMOD_0_TARGET)
+ $(MAKE) V=$(VBOX_LNX_VERBOSE) $(VBOX_DISABLE_SIGN) -C $(KERN_DIR) $(VBOX_SUBDIR_VAR)=$(CURDIR) SRCROOT=$(CURDIR) INSTALL_MOD_PATH=$(INSTALL_MOD_PATH) INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) modules_install
+
+modules_install: install
+
+clean:
+ $(MAKE) V=$(VBOX_LNX_VERBOSE) $(VBOX_DISABLE_SIGN) -C $(KERN_DIR) $(VBOX_SUBDIR_VAR)=$(CURDIR) SRCROOT=$(CURDIR) clean
+
+.PHONY: all $(VBOXMOD_0_TARGET) install modules_install clean
+endif # VBOX_KERN_GROKS_EXTMOD
+
diff --git a/src/VBox/Installer/linux/Makefile-header.gmk b/src/VBox/Installer/linux/Makefile-header.gmk
new file mode 100644
index 00000000..b71f46cf
--- /dev/null
+++ b/src/VBox/Installer/linux/Makefile-header.gmk
@@ -0,0 +1,301 @@
+# $Id: Makefile-header.gmk $
+## @file
+# VirtualBox Guest Additions kernel module Makefile, common parts.
+#
+# (For 2.6.x, the main file must be called 'Makefile'!)
+#
+
+#
+# Copyright (C) 2006-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+# Testing:
+# * Building with KERN_DIR set uses the value specified and
+# the default value for the unspecified one if any.
+
+#
+# These file should be included by the Makefiles for any kernel modules we
+# build as part of the Guest Additions. The intended way of doing this is as
+# follows:
+#
+# # Linux kbuild sets this to our source directory if we are called from there
+# obj ?= $(CURDIR)
+# include $(obj)/Makefile-header.gmk
+# VBOXMOD_NAME = <name of the module to be built, without extension>
+# VBOXMOD_OBJS = <list of object files which should be included>
+# VBOXMOD_DEFS = <any additional defines which this module needs>
+# VBOXMOD_INCL = <any additional include paths which this module needs>
+# VBOXMOD_CFLAGS = <any additional CFLAGS which this module needs>
+# include $(obj)/Makefile-footer.gmk
+#
+# To avoid potential confusion between kmk/kBuild and linux/kbuild,
+# we use VBOX_KBUILD_TARGET_ARCH instead of KBUILD_TARGET_ARCH and
+# VBOX_KBUILD_TYPE instead of KBUILD_TYPE. The VBOX_KBUILD_ variable
+# variant takes percedence over the kmk/kBuild ones.
+#
+
+
+#
+# First, figure out which architecture we're targeting and the build type.
+# (We have to support basic cross building (ARCH=i386|x86_64).)
+# While at it, warn about *BUILD_* vars found to help with user problems.
+#
+
+# VBOX_KBUILD_TARGET_ARCH = amd64|x86
+ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
+ VBOX_KBUILD_TARGET_ARCH_DEFAULT := amd64
+else
+ VBOX_KBUILD_TARGET_ARCH_DEFAULT := x86
+endif
+ifdef VBOX_KBUILD_TARGET_ARCH
+ ifneq ($(filter-out amd64 x86,$(VBOX_KBUILD_TARGET_ARCH)),)
+ $(warning Ignoring unknown VBOX_KBUILD_TARGET_ARCH value '$(VBOX_KBUILD_TARGET_ARCH)'.)
+ VBOX_KBUILD_TARGET_ARCH :=
+ endif
+else
+ ifdef KBUILD_TARGET_ARCH
+ ifneq ($(filter-out amd64 x86,$(KBUILD_TARGET_ARCH)),)
+ $(warning Ignoring unknown KBUILD_TARGET_ARCH value '$(KBUILD_TARGET_ARCH)'.)
+ VBOX_KBUILD_TARGET_ARCH :=
+ endif
+ else
+ ifdef BUILD_TARGET_ARCH
+ $(warning BUILD_TARGET_ARCH is deprecated, use VBOX_KBUILD_TARGET_ARCH instead.)
+ ifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
+ $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
+ VBOX_KBUILD_TARGET_ARCH :=
+ endif
+ endif
+ endif
+endif
+ifeq ($(VBOX_KBUILD_TARGET_ARCH),)
+ ifeq ($(ARCH),x86_64)
+ VBOX_KBUILD_TARGET_ARCH := amd64
+ else
+ ifeq ($(ARCH),i386)
+ VBOX_KBUILD_TARGET_ARCH := x86
+ else
+ VBOX_KBUILD_TARGET_ARCH := $(VBOX_KBUILD_TARGET_ARCH_DEFAULT)
+ endif
+ endif
+else
+ ifneq ($(VBOX_KBUILD_TARGET_ARCH),$(VBOX_KBUILD_TARGET_ARCH_DEFAULT))
+ $(warning Using VBOX_KBUILD_TARGET_ARCH='$(VBOX_KBUILD_TARGET_ARCH)' from the $(origin VBOX_KBUILD_TARGET_ARCH).)
+ endif
+endif
+
+# VBOX_KBUILD_TYPE = release|debug|profile|strict|asan
+ifdef VBOX_KBUILD_TYPE
+ VBOX_KBUILD_TYPE_VAR := VBOX_KBUILD_TYPE
+ ifneq ($(filter-out release profile debug strict asan,$(VBOX_KBUILD_TYPE)),)
+ $(warning Ignoring unknown VBOX_KBUILD_TYPE value '$(VBOX_KBUILD_TYPE)'.)
+ VBOX_KBUILD_TYPE :=
+ endif
+else
+ ifdef KBUILD_TYPE
+ VBOX_KBUILD_TYPE_VAR := KBUILD_TYPE
+ VBOX_KBUILD_TYPE := $(KBUILD_TYPE)
+ ifneq ($(filter-out release profile debug strict asan,$(KBUILD_TYPE)),)
+ $(warning Ignoring unknown KBUILD_TYPE value '$(KBUILD_TYPE)'.)
+ VBOX_KBUILD_TYPE :=
+ endif
+ else
+ ifdef BUILD_TYPE
+ $(warning BUILD_TYPE is deprecated, use VBOX_KBUILD_TYPE instead.)
+ VBOX_KBUILD_TYPE_VAR := BUILD_TYPE
+ VBOX_KBUILD_TYPE := $(BUILD_TYPE)
+ ifneq ($(filter-out release profile debug strict asan,$(BUILD_TYPE)),)
+ $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
+ VBOX_KBUILD_TYPE :=
+ endif
+ endif
+ endif
+endif
+ifeq ($(VBOX_KBUILD_TYPE),)
+ VBOX_KBUILD_TYPE_VAR = VBOX_KBUILD_TYPE
+ VBOX_KBUILD_TYPE := release
+else
+ ifneq ($(VBOX_KBUILD_TYPE),release)
+ ifndef VBOX_KERN_QUIET
+ $(warning Using VBOX_KBUILD_TYPE='$(VBOX_KBUILD_TYPE)' from the $(origin $(VBOX_KBUILD_TYPE_VAR)) ($(VBOX_KBUILD_TYPE_VAR)).)
+ endif
+ endif
+endif
+
+ifeq ($(USERNAME),)
+ USERNAME := noname
+endif
+
+ifeq ($(KERNELRELEASE),)
+
+ #
+ # building from this directory
+ #
+
+ # kernel base directory
+ ifdef KERN_DIR
+ ifndef KERN_VER
+ ifeq ($(filter %/build,$(KERN_DIR)),)
+ $(error The variable KERN_DIR must be a kernel build folder and end with /build without a trailing slash, or KERN_VER must be set)
+ endif
+ endif
+ endif
+
+ ifndef KERN_VER
+ ifdef KERN_DIR
+ KERN_VER = $(notdir $(patsubst %/build,%,$(KERN_DIR)))
+ ifeq ($(shell expr $(KERN_VER) : '[0-9]*\.[0-9]*.[0-9]*'),0)
+ $(error The kernel build folder path must end in <version>/build, or the variable KERN_VER must be set)
+ endif
+ endif
+ KERN_VER ?= $(shell uname -r)
+ endif
+
+ ifeq ($(KERN_DIR),)
+ KERN_DIR := /lib/modules/$(KERN_VER)/build
+ endif
+
+ # Is this 2.4 or < 2.6.6? The UTS_RELEASE "2.x.y.z" define is present in the header until 2.6.1x something.
+ ifeq ($(shell if grep '"2\.4\.' $(KERN_DIR)/include/linux/version.h > /dev/null 2>&1; then echo yes; fi),yes)
+ KERN_VERSION := 24
+ VBOX_KERN_GROKS_EXTMOD :=
+ else
+ KERN_VERSION := 26
+ VBOX_KERN_GROKS_EXTMOD := yes
+ ifeq ($(shell if grep '"2\.6\.[012345][."]' $(KERN_DIR)/include/linux/version.h > /dev/null 2>&1; then echo yes; fi),yes)
+ VBOX_KERN_GROKS_EXTMOD :=
+ endif
+ VBOX_KERN_GROKS_SUBDIRS :=
+ ifeq ($(shell if grep '"[432]\.' $(KERN_DIR)/include/linux/version.h > /dev/null 2>&1; then echo yes; fi),yes)
+ VBOX_KERN_GROKS_SUBDIRS := yes
+ endif
+ endif
+
+ #
+ # Hack for Ubuntu 4.10 where we determine 2.6.8.1-3-generic-amd64 here, but the
+ # the next invocation (M/SUBDIR) ends up with KERNELRELEASE=2.6.8.1-3.
+ #
+ ifeq ($(shell if grep '"[2]\.' $(KERN_DIR)/include/linux/version.h > /dev/null 2>&1; then echo yes; fi),yes)
+ export KERN_VER KERN_DIR
+ else
+ # This makefile received some variables in the command line which should
+ # not be passed to the recursive make invocations (of the Linux makefile
+ # for building kernel modules), since they should derive KERN_DIR from the
+ # respective command line variables to come up with the value they expect.
+ unexport KERN_VER KERN_DIR
+ MAKEOVERRIDES := $(filter-out KERN_VER=% KERN_DIR=%,$(MAKEOVERRIDES))
+ endif
+
+else # neq($(KERNELRELEASE),)
+
+ #
+ # building from kbuild (make -C <kernel_directory> M=`pwd`)
+ #
+
+ # guess kernel version (24 or 26)
+ ifeq ($(VERSION).$(PATCHLEVEL),2.4)
+ KERN_VERSION := 24
+ VBOX_KERN_GROKS_EXTMOD :=
+ else
+ KERN_VERSION := 26
+ VBOX_KERN_GROKS_EXTMOD := yes
+ ifeq ($(VERSION).$(PATCHLEVEL),2.6)
+ ifeq ($(findstring @$(SUBLEVEL)@,@0@1@2@3@4@5@),@$(SUBLEVEL)@)
+ VBOX_KERN_GROKS_EXTMOD :=
+ endif
+ endif
+ VBOX_KERN_GROKS_SUBDIRS :=
+ ifeq ($(VERSION),2)
+ VBOX_KERN_GROKS_SUBDIRS := yes
+ endif
+ ifeq ($(VERSION),3)
+ VBOX_KERN_GROKS_SUBDIRS := yes
+ endif
+ ifeq ($(VERSION),4)
+ VBOX_KERN_GROKS_SUBDIRS := yes
+ endif
+ endif
+
+ KERN_VER := $(KERNELRELEASE)
+
+ ifeq ($(KERN_DIR),)
+ ifneq ($(srctree),)
+ KERN_DIR := $(srctree)
+ else
+ KERN_DIR := /lib/modules/$(KERN_VER)/build
+ endif
+ endif
+endif # neq($(KERNELRELEASE),)
+
+# Kernel build folder
+ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
+ $(error Error: unable to find the headers of the Linux kernel to build against (KERN_DIR=$(KERN_DIR)). \
+ Specify KERN_VER=<version> (currently $(KERN_VER)) and run Make again)
+endif
+# Kernel include folder
+KERN_INCL := $(KERN_DIR)/include
+# module install folder
+INSTALL_MOD_DIR ?= misc
+MODULE_DIR := $(INSTALL_MOD_PATH)/lib/modules/$(KERN_VER)/$(INSTALL_MOD_DIR)
+
+# For VBOX_GCC_CHECK_CC
+VBOX_CLOSEPAR := )
+VBOX_DOLLAR := $$
+## Modified VBOX_GCC_CHECK_EX_CC_CXX macro from /Config.kmk.
+# @param 1 The option to test for.
+# @param 2 The return value when supported.
+# @param 3 The return value when NOT supported.
+VBOX_GCC_CHECK_CC = $(shell \
+ > /tmp/$(VBOX_DOLLAR)$(VBOX_DOLLAR).check.c; \
+ if $(CC) $(subst -Wno-,-W,$(1)) -Werror -c -o /dev/null /tmp/$(VBOX_DOLLAR)$(VBOX_DOLLAR).check.c > /dev/null 2>&1; then \
+ case "`LC_ALL=C $(CC) $(subst -Wno-,-W,$(1)) -Werror -c -o /dev/null /tmp/$(VBOX_DOLLAR)$(VBOX_DOLLAR).check.c 2>&1`" in \
+ "error: unknown warning option"*$(VBOX_CLOSEPAR) echo "$(3)";; \
+ *$(VBOX_CLOSEPAR) echo "$(2)";; \
+ esac; \
+ else echo "$(3)"; fi; \
+ rm -f /tmp/$(VBOX_DOLLAR)$(VBOX_DOLLAR).check.c; )
+
+#
+# Guess the module directory ASSUMING that this file is located in that directory.
+# Note! The special MAKEFILE_LIST variable was introduced in GNU make 3.80.
+#
+ifndef VBOX_MODULE_SRC_DIR
+ ifdef MAKEFILE_LIST
+ VBOX_MODULE_SRC_DIR := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
+ else
+ VBOX_MODULE_SRC_DIR := $(CURDIR)/
+ endif
+endif
+
+
+# debug - show guesses.
+ifdef DEBUG
+ ifndef VBOX_KERN_QUIET
+$(warning dbg: INSTALL_MOD_PATH = $(INSTALL_MOD_PATH))
+$(warning dbg: INSTALL_MOD_DIR = $(INSTALL_MOD_DIR))
+$(warning dbg: KERN_DIR = $(KERN_DIR))
+$(warning dbg: KERN_INCL = $(KERN_INCL))
+$(warning dbg: KERN_VERSION = $(KERN_VERSION))
+$(warning dbg: MODULE_DIR = $(MODULE_DIR))
+$(warning dbg: VBOX_MODULE_SRC_DIR = $(VBOX_MODULE_SRC_DIR))
+ endif
+endif
+
diff --git a/src/VBox/Installer/linux/Makefile.kmk b/src/VBox/Installer/linux/Makefile.kmk
new file mode 100644
index 00000000..d2ca34e9
--- /dev/null
+++ b/src/VBox/Installer/linux/Makefile.kmk
@@ -0,0 +1,595 @@
+# $Id: Makefile.kmk $
+## @file
+# Makefile for the Linux installer.
+#
+
+#
+# Copyright (C) 2006-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+SUB_DEPTH = ../../../..
+include $(KBUILD_PATH)/subheader.kmk
+
+# Include sub-makefiles.
+
+# We do not install VBoxHeadlessXOrg.sh any more, so this is not needed.
+#
+# ifdef VBOX_WITH_TESTCASES
+# include $(PATH_SUB_CURRENT)/testcase/Makefile.kmk
+# endif
+
+ifneq ($(KBUILD_HOST),linux)
+ $(error "The Linux installer can only be built on Linux!")
+endif
+
+#
+# Globals and targets.
+#
+VBOX_LNX_APP_PRIVATE := $(if $(VBOX_PATH_APP_PRIVATE),$(VBOX_PATH_APP_PRIVATE),/opt/VirtualBox)
+VBOX_LNX_APP_DOCS := $(if $(VBOX_PATH_PACKAGE_DOCS),$(VBOX_PATH_PACKAGE_DOCS), \
+ $(if $(VBOX_PATH_APP_DOCS),$(VBOX_PATH_APP_DOCS),/opt/VirtualBox))
+VBOX_PATH_LNX_INST_SRC := $(PATH_SUB_CURRENT)
+VBOX_LNX_INST_OUT_DIR := $(PATH_TARGET)/Installer/linux
+VBOX_LNX_INST_STAGE_DIR := $(PATH_TARGET)/Installer/linux/install
+VBOX_LNX_INST_STAGE_DIR_REL := obj/Installer/linux/install
+VBOX_LNX_DBG_PATH := usr/lib/debug/$(VBOX_LNX_APP_PRIVATE)
+VBOX_LNX_PACKAGE_NAME = VirtualBox-$(VBOX_VERSION_STRING)-r$(VBOX_SVN_REV).run
+
+# Unset this to speed up things during makefile hacking.
+VBOX_LNX_INST_DEP_ON_MAKEFILE := $(MAKEFILE_CURRENT)
+
+BLDDIRS += $(VBOX_LNX_INST_OUT_DIR) $(VBOX_LNX_INST_STAGE_DIR)
+if !defined(VBOX_NO_LINUX_RUN_INSTALLER)
+ PACKING += $(PATH_STAGE_BIN)/$(VBOX_LNX_PACKAGE_NAME) \
+ $(PATH_STAGE_BIN)/VirtualBox-dbg.tar.bz2
+else
+ PACKING += $(PATH_STAGE_BIN)/VirtualBox.tar
+endif
+
+OTHER_CLEAN += \
+ $(addprefix $(VBOX_LNX_INST_STAGE_DIR)/, \
+ install.sh \
+ VirtualBox.tar.bz2 \
+ LICENSE) \
+ $(wildcard $(VBOX_LNX_INST_OUT_DIR)/VirtualBox-*) \
+ $(VBOX_LNX_INST_OUT_DIR)/install.sh
+
+#
+# Linux installs.
+#
+INSTALLS += linux-bin
+linux-bin_INST = bin/
+linux-bin_MODE = a+rx,u+w
+linux-bin_SOURCES = \
+ check_module_dependencies.sh \
+ postinst-common.sh \
+ prerm-common.sh \
+ routines.sh \
+ VBoxSysInfo.sh \
+ vboxautostart-service.sh \
+ vboxballoonctrl-service.sh \
+ VBoxCreateUSBNode.sh \
+ vboxdrv.sh \
+ vboxweb-service.sh \
+ VBox.sh=>VBox.sh \
+ $(if $(VBOX_WITH_PYTHON),$(PATH_ROOT)/src/VBox/Frontends/VBoxShell/vboxshell.py=>vboxshell.py,)
+
+INSTALLS += linux-scripts
+linux-scripts_INST = $(VBOX_LNX_INST_STAGE_DIR_REL)/
+linux-scripts_MODE = a+rx,u+w
+linux-scripts_SOURCES = \
+ deffiles \
+ postinst-common.sh \
+ prerm-common.sh \
+ routines.sh \
+ uninstall.sh \
+ vboxautostart-service.sh \
+ vboxballoonctrl-service.sh \
+ vboxdrv.sh \
+ vboxweb-service.sh
+
+INSTALLS += linux-misc
+linux-misc_INST = bin/
+linux-misc_MODE = a+r,u+w
+linux-misc_SOURCES = \
+ $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/$(if $(VBOX_OSE),OSE,NonOSE)/VirtualBox_32px.png=>VBox.png \
+ $(VBOX_PATH_INST_COMMON_SRC)/virtualbox.xml \
+ $(if $(VBOX_OSE),,$(VBOX_BRAND_LICENSE_TXT)=>LICENSE) \
+ $(linux-misc_0_OUTDIR)/generated.sh=>scripts/generated.sh \
+ $(if $(VBOX_WITH_QTGUI),$(linux-misc_0_OUTDIR)/virtualbox.desktop,) \
+ $(if $(VBOX_WITH_QTGUI),$(linux-misc_0_OUTDIR)/virtualboxvm.desktop,)
+ifeq ($(KBUILD_TYPE),asan)
+ linux-misc_SOURCES += $(foreach lib,$(VBOX_GCC_SANITIZER_SO_FILES) \
+ ,$(lib)=>$(notdir $(lib)) $(lib)=>testcase/$(notdir $(lib)) $(lib)=>tools/$(notdir $(lib)) )
+endif
+linux-misc_CLEAN = \
+ $(linux-misc_0_OUTDIR)/generated.sh \
+ $(linux-misc_0_OUTDIR)/virtualbox.desktop \
+ $(linux-misc_0_OUTDIR)/virtualboxvm.desktop
+
+$$(linux-misc_0_OUTDIR)/generated.sh: $(VBOX_VERSION_STAMP) $(VBOX_LNX_INST_DEP_ON_MAKEFILE) | $$(dir $$@)
+ $(call MSG_GENERATE,,$@,$<)
+ $(QUIET)$(RM) -f '$@'
+ $(QUIET)$(APPEND) '$@' 'VBOX_PRODUCT="$(VBOX_PRODUCT)"'
+ $(QUIET)$(APPEND) '$@' 'VBOX_VERSION_STRING="$(VBOX_VERSION_STRING)"'
+ $(QUIET)$(APPEND) '$@' 'VBOX_C_YEAR="$(VBOX_C_YEAR)"'
+ $(QUIET)$(APPEND) '$@' 'VBOX_VENDOR="$(VBOX_VENDOR)"'
+
+$$(linux-misc_0_OUTDIR)/virtualbox.desktop: $(VBOX_PATH_INST_COMMON_SRC)/virtualbox.desktop.in $(VBOX_VERSION_STAMP) | $$(dir $$@)
+ $(call MSG_GENERATE,,$@,$<)
+ $(QUIET)$(SED) -e "s+@VBOX_PRODUCT@+$(VBOX_PRODUCT)+" \
+ --output $@ $<
+
+$$(linux-misc_0_OUTDIR)/virtualboxvm.desktop: $(VBOX_PATH_INST_COMMON_SRC)/virtualboxvm.desktop.in $(VBOX_VERSION_STAMP) | $$(dir $$@)
+ $(call MSG_GENERATE,,$@,$<)
+ $(QUIET)$(SED) -e "s+@VBOX_PRODUCT@+$(VBOX_PRODUCT)+" \
+ --output $@ $<
+
+INSTALLS += linux-icons
+linux-icons_INST = bin/icons/
+linux-icons_MODE = a+r,u+w
+linux-icons_SOURCES = $(VBOX_MIME_ICONS) $(VBOX_DESKTOP_ICONS)
+
+
+#
+# The files residing in bin/ that we'll ship.
+#
+
+# Strip these binaries
+VBOX_LNX_STRIP_BIN = \
+ VBoxDD.so \
+ VBoxDD2.so \
+ VBoxDDU.so \
+ VBoxVMM.so \
+ VBoxRT.so \
+ $(if $(VBOX_WITH_LIBSSH),VBoxLibSsh.so,) \
+ $(if $(VBOX_WITH_VBOXSDL),VBoxSDL $(if $(VBOX_WITH_HARDENING),VBoxSDL.so),) \
+ $(if $(VBOX_WITH_SHARED_CLIPBOARD), VBoxSharedClipboard.so,) \
+ $(if $(VBOX_WITH_SHARED_FOLDERS), VBoxSharedFolders.so,) \
+ $(if $(VBOX_WITH_GUEST_PROPS),VBoxGuestPropSvc.so,) \
+ $(if $(VBOX_WITH_GUEST_CONTROL),VBoxGuestControlSvc.so,) \
+ VBoxHostChannel.so \
+ $(if $(VBOX_WITH_DRAG_AND_DROP),VBoxDragAndDropSvc.so,) \
+ $(if $(VBOX_WITH_MAIN), \
+ VBoxAutostart \
+ VBoxBalloonCtrl \
+ VBoxBugReport \
+ VBoxManage \
+ VBoxNetDHCP $(if $(VBOX_WITH_HARDENING),VBoxNetDHCP.so,) \
+ $(if $(VBOX_WITH_LWIP_NAT),VBoxNetNAT $(if $(VBOX_WITH_HARDENING),VBoxNetNAT.so,),) \
+ VBoxNetAdpCtl \
+ $(if $(VBOX_WITH_DEVMAPPER),VBoxVolInfo,) \
+ VBoxSVC \
+ VBoxXPCOM.so \
+ VBoxXPCOMC.so \
+ VBoxXPCOMIPCD \
+ components/VBoxXPCOMIPCC.so \
+ components/VBoxSVCM.so \
+ components/VBoxC.so,) \
+ $(if $(VBOX_WITH_QTGUI),VBoxTestOGL,) \
+ $(if $(VBOX_WITH_VMSVGA3D),VBoxSVGA3D.so,) \
+ $(if $(VBOX_WITH_DXVK), VBoxDxVk.so,) \
+ $(if $(VBOX_WITH_PYTHON),$(notdir $(wildcard $(PATH_STAGE_BIN)/VBoxPython*.so)),) \
+ $(if $(VBOX_WITH_JXPCOM),libvboxjxpcom.so,) \
+ $(if $(and $(VBOX_WITH_EXTPACK_VNC),$(VBOX_WITHOUT_EXTPACK_VNC_PACKING)), \
+ ExtensionPacks/VNC/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/VBoxVNC.so \
+ ExtensionPacks/VNC/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)/VBoxVNCMain.so,) \
+ $(if $(VBOX_WITH_DTRACE),VBoxDTrace,) \
+ $(if $(VBOX_WITH_HOST_SHIPPING_AUDIO_TEST),VBoxAudioTest,)
+
+# Do not remove relocation information of these binaries
+VBOX_LNX_STRIP_OBJ = \
+ VBoxDDR0.r0 \
+ VMMR0.r0
+ifdef VBOX_NO_LINUX_RUN_INSTALLER
+ VBOX_LNX_STRIP_OBJ += \
+ VBoxDDR0.debug \
+ VMMR0.debug
+else
+ VBOX_LNX_DBG_BIN = \
+ VBoxDDR0.debug \
+ VMMR0.debug
+endif
+
+ifdef VBOX_WITH_RAW_MODE
+ VBOX_LNX_STRIP_OBJ += \
+ VBoxDDRC.rc \
+ VMMRC.rc
+ ifdef VBOX_NO_LINUX_RUN_INSTALLER
+ VBOX_LNX_STRIP_OBJ += \
+ VBoxDDRC.debug \
+ VMMRC.debug
+ else
+ VBOX_LNX_DBG_BIN += \
+ VBoxDDRC.debug \
+ VMMRC.debug
+ endif
+endif
+
+# Do not strip anything of these files
+VBOX_LNX_NO_STRIP = \
+ $(if $(VBOX_OSE),,LICENSE) \
+ $(if $(VBOX_WITH_MAIN), \
+ components/VBoxXPCOMBase.xpt \
+ components/VirtualBox_XPCOM.xpt) \
+ $(if $(VBOX_WITH_PYTHON),vboxshell.py,) \
+ $(if $(and $(VBOX_WITH_EXTPACK_VNC),$(VBOX_WITHOUT_EXTPACK_VNC_PACKING)), \
+ ExtensionPacks/VNC/ExtPack.xml \
+ ExtensionPacks/VNC/ExtPack-license.html \
+ ExtensionPacks/VNC/ExtPack-license.rtf \
+ ExtensionPacks/VNC/ExtPack-license.txt,) \
+ check_module_dependencies.sh \
+ postinst-common.sh \
+ prerm-common.sh \
+ routines.sh \
+ VBoxSysInfo.sh \
+ vboxautostart-service.sh \
+ vboxballoonctrl-service.sh \
+ VBoxCreateUSBNode.sh \
+ vboxdrv.sh \
+ VBox.sh \
+ vboxweb-service.sh \
+ VBox.png \
+ $(addprefix UnattendedTemplates/,$(VBOX_UNATTENDED_TEMPLATES))
+
+ifdef VBOX_WITH_EXTPACK
+ VBOX_LNX_STRIP_BIN += \
+ VBoxExtPackHelperApp
+endif
+
+# Qt GUI
+ifdef VBOX_WITH_QTGUI
+ include $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/nls/ApprovedLanguages.kmk
+ VBOX_LNX_STRIP_BIN += \
+ VBoxKeyboard.so \
+ VirtualBox \
+ VirtualBoxVM \
+ UICommon.so \
+ $(if $(VBOX_WITH_DEBUGGER_GUI),VBoxDbg.so DbgPlugInDiggers.so)
+ ifdef VBOX_WITH_HARDENING
+ VBOX_LNX_STRIP_BIN += \
+ VirtualBoxVM.so
+ endif
+ VBOX_LNX_NO_STRIP += \
+ virtualbox.desktop \
+ virtualboxvm.desktop \
+ virtualbox.xml \
+ $(VBOX_LICENSE_FILES) \
+ $(if $(VBOX_WITH_ORACLE_QT),$(notdir $(wildcard $(PATH_STAGE_BIN)/lib*VBox*)),) \
+ $(if $(VBOX_WITH_ORACLE_QT),$(VBOX_QT_PLUGINS)) \
+ $(foreach f,$(VBOX_APPROVED_GUI_LANGUAGES),nls/VirtualBox_$(f).qm nls/qt_$(f).qm) \
+ icons
+endif
+
+# Guest Additions
+ifdef VBOX_WITH_ADDITIONS_PACKING
+ VBOX_LNX_NO_STRIP += \
+ additions/VBoxGuestAdditions.iso
+endif
+
+# Documentation
+ifdef VBOX_WITH_DOCS_PACKING
+ VBOX_LNX_NO_STRIP += \
+ UserManual.pdf \
+ $(foreach f,$(VBOX_MANUAL_ADD_LANGUAGES),UserManual_$(f).pdf)
+ ifdef VBOX_WITH_DOCS_CHM_PACKING
+ VBOX_LNX_NO_STRIP += \
+ VirtualBox.chm \
+ $(foreach f,$(VBOX_MANUAL_ADD_LANGUAGES),VirtualBox_$(f).chm)
+ endif
+ ifdef VBOX_WITH_DOCS_QHELP_PACKING
+ VBOX_LNX_NO_STRIP += \
+ UserManual.qch UserManual.qhc \
+ $(foreach f,$(VBOX_MANUAL_ADD_LANGUAGES),UserManual_$(f).qch ,UserManual_$(f).qhc)
+ endif
+endif
+
+# auth stuff
+VBOX_LNX_STRIP_BIN += \
+ $(if $(VBOX_WITH_PAM),VBoxAuth.so,) \
+ VBoxAuthSimple.so
+
+# VRDP
+ifdef VBOX_WITH_VRDP
+ ifndef VBOX_WITH_EXTPACK_PUEL
+ VBOX_LNX_STRIP_BIN += \
+ VBoxVRDP.so
+ endif
+endif
+
+# Python XPCOM glue
+ifdef VBOX_WITH_PYTHON
+ VBOX_LNX_NO_STRIP += \
+ $(VBOXINST_SDK_BINDINGS_XPCOM_PYTHON_FILES) \
+ $(VBOXINST_SDK_INSTALLER_PYTHON_FILES)
+endif
+
+# Java XPCOM bridge
+ifdef VBOX_WITH_JXPCOM
+ VBOX_LNX_NO_STRIP += \
+ sdk/bindings/xpcom/java/vboxjxpcom.jar
+endif
+
+# Headless
+ifdef VBOX_WITH_HEADLESS
+ VBOX_LNX_STRIP_BIN += \
+ VBoxHeadless \
+ $(if $(VBOX_WITH_HARDENING),VBoxHeadless.so)
+endif
+
+# Webservices
+ifdef VBOX_WITH_WEBSERVICES
+ VBOX_LNX_STRIP_BIN += \
+ vboxwebsrv
+endif
+
+# vbox-img
+if defined(VBOX_WITH_TESTCASES) || defined(VBOX_WITH_VBOX_IMG)
+ VBOX_LNX_STRIP_BIN += \
+ vbox-img
+endif
+
+# vboximg-mount
+if defined(VBOX_WITH_VBOXIMGMOUNT)
+ VBOX_LNX_STRIP_BIN += \
+ vboximg-mount
+endif
+
+# EFI firmware
+ifdef VBOX_WITH_EFIFW_PACKING
+ VBOX_LNX_NO_STRIP += \
+ VBoxEFI32.fd \
+ VBoxEFI64.fd
+endif
+
+# DTrace library and scripts.
+ifdef VBOX_WITH_DTRACE
+ VBOX_LNX_NO_STRIP += \
+ $(addprefix dtrace/lib/$(KBUILD_TARGET_ARCH)/,$(VBOXINST_DTRACE_LIB_ARCH_FILES)) \
+ $(addprefix dtrace/testcase/$(KBUILD_TARGET_ARCH)/,$(VBOXINST_DTRACE_TESTCASE_ARCH_FILES)) \
+ $(addprefix dtrace/scripts/,$(VBOXINST_DTRACE_SCRIPTS_FILES))
+endif
+
+# The sanitizer shared objects match the compiler we're using (HACK).
+ifeq ($(KBUILD_TYPE),asan)
+ VBOX_LNX_NO_STRIP += $(notdir $(VBOX_GCC_SANITIZER_SO_FILES))
+endif
+
+# Icons
+VBOX_MIME_ICONS = \
+ $(addprefix $(PATH_ROOT)/src/VBox/Artwork/other/, \
+ $(foreach f,ova ovf vbox vbox-extpack vdi vmdk vhd hdd, \
+ $(foreach s,16 20 24 32 48 64 72 96 128 256, \
+ virtualbox-$(f)-$(s)px.png=>$(s)x$(s)/virtualbox-$(f).png)))
+
+VBOX_DESKTOP_ICONS = \
+ $(addprefix $(PATH_ROOT)/src/VBox/Artwork/$(if $(VBOX_OSE),OSE,NonOSE)/, \
+ $(foreach s,16 20 32 40 48 64 128, \
+ virtualbox-$(s)px.png=>$(s)x$(s)/virtualbox.png) \
+ virtualbox.svg=>scalable/virtualbox.svg)
+
+#
+# All the bin files that goes into the archives.
+#
+VBOX_LNX_ARCH_FILES := $(VBOX_LNX_STRIP_BIN) $(VBOX_LNX_STRIP_OBJ) $(VBOX_LNX_NO_STRIP) src
+
+# Cleanup of the files we copy/symlink from bin.
+OTHER_CLEAN += $(addprefix $(VBOX_LNX_INST_OUT_DIR)/archive/,$(filter-out src,$(VBOX_LNX_ARCH_FILES)) src/vboxhost) \
+ $(addprefix $(VBOX_LNX_INST_OUT_DIR)/archive-dbg/$(VBOX_LNX_DBG_PATH)/, \
+ $(VBOX_LNX_STRIP_BIN) $(VBOX_LNX_DBG_BIN))
+
+#
+# The generic installer.
+#
+$(PATH_STAGE_BIN)/$(VBOX_LNX_PACKAGE_NAME): \
+ $(VBOX_LNX_INST_STAGE_DIR)/VirtualBox.tar.bz2 \
+ $(VBOX_VERSION_STAMP) \
+ $(if $(VBOX_OSE),,$(VBOX_BRAND_LICENSE_TXT)) \
+ $(VBOX_LNX_INST_OUT_DIR)/install.sh \
+ $$(linux-scripts_2_STAGE_TARGETS)
+ $(call MSG_TOOL,makeself,,$@)
+ $(QUIET)$(RM) -f $(wildcard $(PATH_STAGE_BIN)/VirtualBox-*.run)
+ $(QUIET)$(if $(VBOX_OSE),,$(INSTALL) -m 0644 $(VBOX_BRAND_LICENSE_TXT) $(VBOX_LNX_INST_STAGE_DIR)/LICENSE)
+ $(QUIET)$(INSTALL) -m 0755 $(VBOX_LNX_INST_OUT_DIR)/install.sh $(VBOX_LNX_INST_STAGE_DIR)/
+ $(QUIET)$(RM) -f $@
+ $(QUIET)$(VBOX_MAKESELF) --follow --nocomp $(VBOX_LNX_INST_STAGE_DIR) $@ \
+ "VirtualBox for Linux installation" ./install.sh "\$$0 1> /dev/null"
+
+$(VBOX_LNX_INST_OUT_DIR)/install.sh: $(VBOX_PATH_LNX_INST_SRC)/install.sh $(VBOX_VERSION_STAMP) $(wildcard $(VBOX_SVN_REV_KMK).ts) | $$(dir $$@)
+ $(QUIET)$(SED) \
+ -e "s;_VERSION_;$(VBOX_VERSION_STRING);g" \
+ -e "s;_SVNREV_;$(VBOX_SVN_REV);g" \
+ -e "s;_BUILD_;$(date-utc );g" \
+ -e "s;_ARCH_;$(KBUILD_TARGET_ARCH);g" \
+ -e "s;_HARDENED_;$(VBOX_WITH_HARDENING);g" \
+ -e "s;_BUILDTYPE_;$(KBUILD_TYPE);g" \
+ -e "s;_USERNAME_;$(USERNAME);g" \
+ -e "s;_INSTALLATION_DIR_;$(VBOX_LNX_APP_PRIVATE);g" \
+ -e "s;_PYTHON_;$(VBOX_WITH_PYTHON);g" \
+ --output $@ \
+ $<
+
+#
+# The files that the tar archives depend on.
+#
+
+include $(PATH_ROOT)/src/VBox/HostDrivers/Support/linux/files_vboxdrv
+VBOX_LNX_INST_FILES_VBOXDRV = $(patsubst =>%,$(PATH_STAGE_BIN)/src/vboxdrv/%,$(filter =>%,$(subst =>, =>,$(subst $(DQUOTE),,$(FILES_VBOXDRV_NOBIN)))))
+include $(PATH_ROOT)/src/VBox/HostDrivers/VBoxNetFlt/linux/files_vboxnetflt
+VBOX_LNX_INST_FILES_VBOXNETFLT = $(patsubst =>%,$(PATH_STAGE_BIN)/src/vboxnetflt/%,$(filter =>%,$(subst =>, =>,$(subst $(DQUOTE),,$(VBOX_VBOXNETFLT_SOURCES)))))
+include $(PATH_ROOT)/src/VBox/HostDrivers/VBoxNetAdp/linux/files_vboxnetadp
+VBOX_LNX_INST_FILES_VBOXNETADP = $(patsubst =>%,$(PATH_STAGE_BIN)/src/vboxnetadp/%,$(filter =>%,$(subst =>, =>,$(subst $(DQUOTE),,$(VBOX_VBOXNETADP_SOURCES)))))
+
+ifdef VBOX_WITH_PCI_PASSTHROUGH
+ include $(PATH_ROOT)/src/VBox/HostDrivers/VBoxPci/linux/files_vboxpci
+ VBOX_LNX_INST_FILES_VBOXPCI = $(patsubst =>%,$(PATH_STAGE_BIN)/src/vboxpci/%,$(filter =>%,$(subst =>, =>,$(subst $(DQUOTE),,$(VBOX_VBOXPCI_SOURCES)))))
+endif
+
+VBOX_LNX_INST_ARCH_DEPS := \
+ $(addprefix $(VBOX_LNX_INST_OUT_DIR)/archive/, $(VBOX_LNX_ARCH_FILES)) \
+ $(VBOX_LNX_INST_DEP_ON_MAKEFILE) \
+ $(VBOX_VERSION_STAMP) \
+ $(VBOX_LNX_INST_FILES_VBOXDRV) \
+ $(VBOX_LNX_INST_FILES_VBOXNETFLT) \
+ $(VBOX_LNX_INST_FILES_VBOXNETADP) \
+ $(if $(VBOX_WITH_PCI_PASSTHROUGH),$(VBOX_LNX_INST_FILES_VBOXPCI),)
+
+#
+# .tar.bz2 for converting into .run
+#
+$(VBOX_LNX_INST_STAGE_DIR)/VirtualBox.tar.bz2: $(VBOX_LNX_INST_ARCH_DEPS)
+ $(call MSG_L1,Packing $@)
+ $(QUIET)$(RM) -f -- $@ $(patsubst %.bz2,%,$@)
+ $(QUIET)$(MKDIR) -p $(@D)
+ifdef VBOX_USE_PBZIP2
+ $(QUIET)tar --dereference --owner 0 --group 0 \
+ -cRhf $(patsubst %.bz2,%,$@) -C $(VBOX_LNX_INST_OUT_DIR)/archive $(VBOX_LNX_ARCH_FILES)
+ $(QUIET)pbzip2 $(patsubst %.bz2,%,$@)
+else
+ $(QUIET)tar --dereference --owner 0 --group 0 \
+ -cjRhf $@ -C $(VBOX_LNX_INST_OUT_DIR)/archive $(VBOX_LNX_ARCH_FILES)
+endif
+ $(QUIET)$(CHMOD) 0644 $@
+
+#
+# .tar for distribution with the files under VirtualBox-<ver>/.
+#
+$(PATH_STAGE_BIN)/VirtualBox.tar: $(VBOX_LNX_INST_ARCH_DEPS)
+ $(call MSG_L1,Packing $@)
+ $(QUIET)$(RM) -f -- $(VBOX_LNX_INST_OUT_DIR)/VirtualBox-$(VBOX_VERSION_STRING) $@ $(patsubst %.bz2,%,$@)
+ $(QUIET)$(LN_SYMLINK) $(VBOX_LNX_INST_OUT_DIR)/archive/ $(VBOX_LNX_INST_OUT_DIR)/VirtualBox-$(VBOX_VERSION_STRING)
+ $(QUIET)tar --dereference --owner 0 --group 0 \
+ -cRhf $@ -C $(VBOX_LNX_INST_OUT_DIR) \
+ $(addprefix VirtualBox-$(VBOX_VERSION_STRING)/,$(VBOX_LNX_ARCH_FILES))
+ $(QUIET)$(RM) -f -- $(VBOX_LNX_INST_OUT_DIR)/VirtualBox-$(VBOX_VERSION_STRING)
+
+
+# pattern rule for stripping and copying the VBOX_LNX_STRIP_BIN files to archive/
+$(addprefix $(VBOX_LNX_INST_OUT_DIR)/archive/,$(VBOX_LNX_STRIP_BIN)): \
+ $(VBOX_LNX_INST_OUT_DIR)/archive/% : $(PATH_STAGE_BIN)/% \
+ $(if $(VBOX_NO_LINUX_RUN_INSTALLER),, \
+ $(VBOX_LNX_INST_OUT_DIR)/archive-dbg/$(VBOX_LNX_DBG_PATH)/%) \
+ | $$(dir $$@)
+ $(call MSG_INST_FILE,$<,$@)
+ $(QUIET)$(INSTALL) -m 0755 $(if $(VBOX_DO_STRIP),-s,) $< $@
+ $(QUIET)$(if $(VBOX_NO_LINUX_RUN_INSTALLER),,objcopy --add-gnu-debuglink=$(subst $(VBOX_LNX_INST_OUT_DIR)/archive,$(VBOX_LNX_INST_OUT_DIR)/archive-dbg/$(VBOX_LNX_DBG_PATH),$@) $@)
+
+# pattern rule for copying VBOX_LNX_DBG_BIN files to archive-dbg/
+$(addprefix $(VBOX_LNX_INST_OUT_DIR)/archive-dbg/$(VBOX_LNX_DBG_PATH)/,$(VBOX_LNX_DBG_BIN)): \
+ $(VBOX_LNX_INST_OUT_DIR)/archive-dbg/$(VBOX_LNX_DBG_PATH)/% : $(PATH_STAGE_BIN)/% | $$(dir $$@)
+ $(call MSG_INST_FILE,$<,$@)
+ $(QUIET)$(CP) $< $@
+
+# pattern rule for striping and copying the VBOX_LNX_STRIP_OBJ files to archive/
+$(addprefix $(VBOX_LNX_INST_OUT_DIR)/archive/,$(VBOX_LNX_STRIP_OBJ)): \
+ $(VBOX_LNX_INST_OUT_DIR)/archive/% : $(PATH_STAGE_BIN)/% | $$(dir $$@)
+ $(call MSG_INST_FILE,$<,$@)
+ifeq ($(VBOX_DO_STRIP),)
+ $(QUIET)$(INSTALL) -m 0644 $< $@
+else # strip to temp file because of umask.
+ $(QUIET)objcopy --strip-unneeded -R .comment $< $@.tmp
+ $(QUIET)$(INSTALL) -m 0644 $@.tmp $@
+ $(QUIET)$(RM) -f -- $@.tmp
+endif
+
+# pattern rule for linking the VBOX_LNX_NO_STRIP into archive/
+$(addprefix $(VBOX_LNX_INST_OUT_DIR)/archive/,$(VBOX_LNX_NO_STRIP)): \
+ $(VBOX_LNX_INST_OUT_DIR)/archive/% : $(PATH_STAGE_BIN)/% | $$(dir $$@)
+ $(call MSG_INST_SYM,$<,$@)
+ $(QUIET)$(RM) -f $@
+ $(QUIET)$(LN_SYMLINK) $< $@
+
+# special rule for the kernel modules
+$(VBOX_LNX_INST_OUT_DIR)/archive/src: $(PATH_STAGE_BIN)/src | $(dir $@)
+ $(call MSG_INST_SYM,$<,$@)
+ $(QUIET)$(RM) -Rf $@
+ $(QUIET)$(MKDIR) $@
+ $(QUIET)$(LN_SYMLINK) $< $@/vboxhost
+
+# rules for creating directories in archive (the pattern rules depends on these).
+BLDDIRS += $(foreach d, \
+ archive \
+ archive/components \
+ archive/nls \
+ $(if $(VBOX_WITH_UNATTENDED),archive/unattended_templates,) \
+ $(if $(VBOX_WITH_ORACLE_QT), \
+ archive/plugins/platforms \
+ archive/plugins/platformthemes \
+ archive/plugins/sqldrivers \
+ archive/plugins/styles \
+ archive/plugins/xcbglintegrations,) \
+ $(if $(VBOX_WITH_PYTHON), \
+ archive/sdk/installer \
+ archive/sdk/installer/vboxapi \
+ archive/sdk/bindings/xpcom/python/xpcom \
+ archive/sdk/bindings/xpcom/python/xpcom/client \
+ archive/sdk/bindings/xpcom/python/xpcom/server,) \
+ $(if $(VBOX_WITH_JXPCOM), \
+ archive/sdk/bindings/xpcom/java,) \
+ $(if $(and $(VBOX_WITH_EXTPACK_VNC),$(VBOX_WITHOUT_EXTPACK_VNC_PACKING)), \
+ archive/ExtensionPacks/VNC \
+ archive/ExtensionPacks/VNC/$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH),) \
+ archive/additions \
+ $(if-expr defined(VBOX_UNATTENDED_TEMPLATES),archive/UnattendedTemplates,) \
+ install \
+ $(if $(VBOX_WITH_DTRACE), \
+ archive/dtrace \
+ archive/dtrace/lib \
+ archive/dtrace/lib/$(KBUILD_TARGET_ARCH) \
+ archive/dtrace/testcase/ \
+ archive/dtrace/testcase/$(KBUILD_TARGET_ARCH) \
+ archive/dtrace/scripts,) \
+ ,$(VBOX_LNX_INST_OUT_DIR)/$(d)/)
+
+
+#
+# .tar.bz2 for with the debug info.
+#
+$(PATH_STAGE_BIN)/VirtualBox-dbg.tar.bz2: \
+ $(addprefix $(VBOX_LNX_INST_OUT_DIR)/archive-dbg/$(VBOX_LNX_DBG_PATH)/, \
+ $(VBOX_LNX_STRIP_BIN) $(VBOX_LNX_DBG_BIN))
+ $(call MSG_L1,Packing $@)
+ $(QUIET)$(RM) -f -- $@ $(patsubst %.bz2,%,$@)
+ifdef VBOX_USE_PBZIP2
+ $(QUIET)tar --dereference --owner 0 --group 0 \
+ -cRhf $(patsubst %.bz2,%,$@) -C $(VBOX_LNX_INST_OUT_DIR)/archive-dbg \
+ $(addprefix $(VBOX_LNX_DBG_PATH)/,$(VBOX_LNX_STRIP_BIN) $(VBOX_LNX_DBG_BIN))
+ $(QUIET)pbzip2 $(patsubst %.bz2,%,$@)
+else
+ $(QUIET)tar --dereference --owner 0 --group 0 \
+ -cjRhf $@ -C $(VBOX_LNX_INST_OUT_DIR)/archive-dbg \
+ $(addprefix $(VBOX_LNX_DBG_PATH)/,$(VBOX_LNX_STRIP_BIN) $(VBOX_LNX_DBG_BIN))
+endif
+
+# pattern rule for copying the debug info from the VBOX_LNX_STRIP_BIN files into archive-dbg/$(VBOX_LNX_DBG_PATH)/
+$(addprefix $(VBOX_LNX_INST_OUT_DIR)/archive-dbg/$(VBOX_LNX_DBG_PATH)/,$(VBOX_LNX_STRIP_BIN)): \
+ $(VBOX_LNX_INST_OUT_DIR)/archive-dbg/$(VBOX_LNX_DBG_PATH)/% : $(PATH_STAGE_BIN)/% | $$(dir $$@)
+ $(call MSG_TOOL,copydbg,$<,$@)
+ $(QUIET)objcopy --only-keep-debug $< $@
+
+# rules for creating directories in archive-dbg (the pattern rules depends on these).
+BLDDIRS += $(foreach d, \
+ $(VBOX_LNX_DBG_PATH) \
+ $(VBOX_LNX_DBG_PATH)/components \
+ ,$(VBOX_LNX_INST_OUT_DIR)/archive-dbg/$(d)/)
+
+include $(FILE_KBUILD_SUB_FOOTER)
+
diff --git a/src/VBox/Installer/linux/README.testing b/src/VBox/Installer/linux/README.testing
new file mode 100644
index 00000000..bfa161e5
--- /dev/null
+++ b/src/VBox/Installer/linux/README.testing
@@ -0,0 +1,35 @@
+$Id: README.testing $
+This file documents things which need testing when updating the Linux host
+installers or anything which might indirectly affect them. This should be
+updated as we discover new things which could break.
+
+General:
+
+ * Test building, installing and running the run, RPM and Debian packages.
+ * Test removing the packages - any errors? Any files left behind? Can the
+ package be re-installed and run after removal?
+ * Test upgrading them from any version we are likely to want to upgrade from.
+ Make sure we can start.
+ * Make sure that RPM/deb packages will not install if the run package is
+ installed and vice-versa.
+
+USB:
+
+ * Make sure that /dev/vboxusb and /etc/udev/rules.d/60-vboxdrv.rules exist
+ after installation with service start and do not exist after removal. They
+ should disappear when the vboxdrv service is stopped and re-appear when it
+ is re-started. This should also work when distribution packages are switched
+ for run and vice-versa.
+
+Services:
+
+ * Make sure that the services start correctly on different types of system.
+ Known supported cases:
+ * old Redhat (e.g. RHEL 5 and earlier): sysvinit and chkconfig
+ * old SUSE (12.0 and earlier): sysvinit and insserv
+ * Gentoo: open-rc
+ * very old Debian (5 and earlier): sysvinit, update-rc.d, non-dependency-based
+ * old Debian (6 and 7): sysvinit, update-rc.d, dependency-based
+ * Ubuntu (9.10 to 14.10): upstart
+ * Ubuntu 14.10: systemd installed, upstart used
+ * Recent non-Gentoo distributions: systemd
diff --git a/src/VBox/Installer/linux/VBox.sh b/src/VBox/Installer/linux/VBox.sh
new file mode 100755
index 00000000..fb584d48
--- /dev/null
+++ b/src/VBox/Installer/linux/VBox.sh
@@ -0,0 +1,158 @@
+#!/bin/sh
+## @file
+# Oracle VM VirtualBox startup script, Linux hosts.
+#
+
+#
+# Copyright (C) 2006-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+PATH="/usr/bin:/bin:/usr/sbin:/sbin"
+
+# The below is GNU-specific. See slightly further down for a version which
+# works on Solaris and OS X.
+TARGET=`readlink -e -- "${0}"` || exit 1
+MY_DIR="${TARGET%/[!/]*}"
+
+# (
+# path="${0}"
+# while test -n "${path}"; do
+# # Make sure we have at least one slash and no leading dash.
+# expr "${path}" : / > /dev/null || path="./${path}"
+# # Filter out bad characters in the path name.
+# expr "${path}" : ".*[*?<>\\]" > /dev/null && exit 1
+# # Catch embedded new-lines and non-existing (or path-relative) files.
+# # $0 should always be absolute when scripts are invoked through "#!".
+# test "`ls -l -d "${path}" 2> /dev/null | wc -l`" -eq 1 || exit 1
+# # Change to the folder containing the file to resolve relative links.
+# folder=`expr "${path}" : "\(.*/\)[^/][^/]*/*$"` || exit 1
+# path=`expr "x\`ls -l -d "${path}"\`" : "[^>]* -> \(.*\)"`
+# cd "${folder}"
+# # If the last path was not a link then we are in the target folder.
+# test -n "${path}" || pwd
+# done
+# )
+
+if test -f /usr/lib/virtualbox/VirtualBox &&
+ test -x /usr/lib/virtualbox/VirtualBox; then
+ INSTALL_DIR=/usr/lib/virtualbox
+elif test -f "${MY_DIR}/VirtualBox" && test -x "${MY_DIR}/VirtualBox"; then
+ INSTALL_DIR="${MY_DIR}"
+else
+ echo "Could not find VirtualBox installation. Please reinstall."
+ exit 1
+fi
+
+# Note: This script must not fail if the module was not successfully installed
+# because the user might not want to run a VM but only change VM params!
+
+if [ "$1" = "shutdown" ]; then
+ SHUTDOWN="true"
+elif ! lsmod|grep -q vboxdrv; then
+ cat << EOF
+WARNING: The vboxdrv kernel module is not loaded. Either there is no module
+ available for the current kernel (`uname -r`) or it failed to
+ load. Please recompile the kernel module and install it by
+
+ sudo /sbin/vboxconfig
+
+ You will not be able to start VMs until this problem is fixed.
+EOF
+elif [ ! -c /dev/vboxdrv ]; then
+ cat << EOF
+WARNING: The character device /dev/vboxdrv does not exist. Try
+
+ sudo /sbin/vboxconfig
+
+ and if that is not successful, try to re-install the package.
+
+ You will not be able to start VMs until this problem is fixed.
+EOF
+fi
+
+if [ -f /etc/vbox/module_not_compiled ]; then
+ cat << EOF
+WARNING: The compilation of the vboxdrv.ko kernel module failed during the
+ installation for some reason. Starting a VM will not be possible.
+ Please consult the User Manual for build instructions.
+EOF
+fi
+
+SERVER_PID=`ps -U \`whoami\` | grep VBoxSVC | awk '{ print $1 }'`
+if [ -z "$SERVER_PID" ]; then
+ # Server not running yet/anymore, cleanup socket path.
+ # See IPC_GetDefaultSocketPath()!
+ if [ -n "$LOGNAME" ]; then
+ rm -rf /tmp/.vbox-$LOGNAME-ipc > /dev/null 2>&1
+ else
+ rm -rf /tmp/.vbox-$USER-ipc > /dev/null 2>&1
+ fi
+fi
+
+if [ "$SHUTDOWN" = "true" ]; then
+ if [ -n "$SERVER_PID" ]; then
+ kill -TERM $SERVER_PID
+ sleep 2
+ fi
+ exit 0
+fi
+
+APP=`basename $0`
+case "$APP" in
+ VirtualBox|virtualbox)
+ exec "$INSTALL_DIR/VirtualBox" "$@"
+ ;;
+ VirtualBoxVM|virtualboxvm)
+ exec "$INSTALL_DIR/VirtualBoxVM" "$@"
+ ;;
+ VBoxManage|vboxmanage)
+ exec "$INSTALL_DIR/VBoxManage" "$@"
+ ;;
+ VBoxSDL|vboxsdl)
+ exec "$INSTALL_DIR/VBoxSDL" "$@"
+ ;;
+ VBoxVRDP|VBoxHeadless|vboxheadless)
+ exec "$INSTALL_DIR/VBoxHeadless" "$@"
+ ;;
+ VBoxAutostart|vboxautostart)
+ exec "$INSTALL_DIR/VBoxAutostart" "$@"
+ ;;
+ VBoxBalloonCtrl|vboxballoonctrl)
+ exec "$INSTALL_DIR/VBoxBalloonCtrl" "$@"
+ ;;
+ VBoxBugReport|vboxbugreport)
+ exec "$INSTALL_DIR/VBoxBugReport" "$@"
+ ;;
+ VBoxDTrace|vboxdtrace)
+ exec "$INSTALL_DIR/VBoxDTrace" "$@"
+ ;;
+ VBoxAudioTest|vboxaudiotest|vkat)
+ exec "$INSTALL_DIR/VBoxAudioTest" "$@"
+ ;;
+ vboxwebsrv)
+ exec "$INSTALL_DIR/vboxwebsrv" "$@"
+ ;;
+ *)
+ echo "Unknown application - $APP"
+ exit 1
+ ;;
+esac
+exit 0
diff --git a/src/VBox/Installer/linux/VBoxCreateUSBNode.sh b/src/VBox/Installer/linux/VBoxCreateUSBNode.sh
new file mode 100755
index 00000000..6893a6c0
--- /dev/null
+++ b/src/VBox/Installer/linux/VBoxCreateUSBNode.sh
@@ -0,0 +1,61 @@
+#! /bin/sh
+# $Id: VBoxCreateUSBNode.sh $ */
+## @file
+# VirtualBox USB Proxy Service, Linux Specialization.
+# udev helper for creating and removing device nodes for VirtualBox USB devices
+#
+
+#
+# Copyright (C) 2010-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+# Constant, from the USB specifications
+usb_class_hub=09
+
+do_remove=0
+case "$1" in "--remove")
+ do_remove=1; shift;;
+esac
+bus=`expr "$2" '/' 128 + 1`
+device=`expr "$2" '%' 128 + 1`
+class="$3"
+group="$4"
+devdir="`printf "/dev/vboxusb/%.3d" $bus`"
+devpath="`printf "/dev/vboxusb/%.3d/%.3d" $bus $device`"
+case "$do_remove" in
+ 0)
+ if test -n "$class" -a "$class" = "$usb_class_hub"
+ then
+ exit 0
+ fi
+ case "$group" in "") group="vboxusers";; esac
+ mkdir /dev/vboxusb -m 0750 2>/dev/null
+ chown root:$group /dev/vboxusb 2>/dev/null
+ mkdir "$devdir" -m 0750 2>/dev/null
+ chown root:$group "$devdir" 2>/dev/null
+ mknod "$devpath" c $1 $2 -m 0660 2>/dev/null
+ chown root:$group "$devpath" 2>/dev/null
+ ;;
+ 1)
+ rm -f "$devpath"
+ ;;
+esac
+
diff --git a/src/VBox/Installer/linux/VBoxSysInfo.sh b/src/VBox/Installer/linux/VBoxSysInfo.sh
new file mode 100755
index 00000000..ee197954
--- /dev/null
+++ b/src/VBox/Installer/linux/VBoxSysInfo.sh
@@ -0,0 +1,142 @@
+#!/bin/sh
+
+# @file
+#
+# Installer (Unix-like)
+# Information about the host system/Linux distribution
+
+#
+# Copyright (C) 2006-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+# Print information about a Linux system
+# @param distribution name of the distribution
+# @param version version of the distribution
+print_linux_info () {
+ # The following regex is not quite correct for an e-mail address, as
+ # the local part may not start or end with a dot. Please correct if
+ # this upsets you.
+ kern_ver=`cat /proc/version | sed -e 's/ ([a-zA-Z0-9.!#$%*/?^{}\`+=_-]*@[a-zA-Z0-9.-]*)//'`
+ echo "Distribution: $1 | Version: $2 | Kernel: $kern_ver"
+}
+
+# Determine the distribution name and release for a Linux system and print
+# send the information to stdout using the print_linux_info function.
+# For practical reasons (i.e. lack of time), this function only gives
+# information for distribution releases considered "of interest" and reports
+# others as unknown. It can be extended later if other distributions are
+# found to be "of interest".
+get_linux_info () {
+ if which lsb_release > /dev/null 2>&1
+ then
+ # LSB-compliant system
+ print_linux_info `lsb_release -i -s` `lsb_release -r -s`
+ elif [ -r /etc/debian_version ]
+ then
+ # Debian-based system
+ release=`cat /etc/debian_version`
+ print_linux_info "Debian" $release
+ elif [ -r /etc/mandriva-release ]
+ then
+ # Mandriva-based system
+ release=`cat /etc/mandriva-release | sed -e 's/[A-Za-z ]* release //'`
+ print_linux_info "Mandriva" $release
+ elif [ -r /etc/fedora-release ]
+ then
+ # Fedora-based
+ release=`cat /etc/fedora-release | sed -e 's/[A-Za-z ]* release //'`
+ print_linux_info "Fedora" $release
+ elif [ -r /etc/SuSE-release ]
+ then
+ # SUSE-based.
+ release=`cat /etc/SuSE-release | grep "VERSION" | sed -e 's/VERSION = //'`
+ if grep openSUSE /etc/SuSE-release
+ then
+ # Is it worth distinguishing here? I did it mainly to prevent
+ # confusion with the version number
+ print_linux_info "openSUSE" $release
+ else
+ print_linux_info "SUSE" $release
+ fi
+ elif [ -r /etc/gentoo-release ]
+ then
+ # Gentoo-based
+ release=`cat /etc/gentoo-release | sed -e 's/[A-Za-z ]* release //'`
+ print_linux_info "Gentoo" $release
+ elif [ -r /etc/slackware-version ]
+ then
+ # Slackware
+ release=`cat /etc/slackware-version | sed -e 's/Slackware //'`
+ print_linux_info "Slackware" $release
+ elif [ -r /etc/arch-release ]
+ then
+ # Arch Linux
+ print_linux_info "Arch Linux" "none"
+ elif [ -r /etc/redhat-release ]
+ then
+ # Redhat-based. This should come near the end, as it other
+ # distributions may give false positives.
+ release=`cat /etc/redhat-release | sed -e 's/[A-Za-z ]* release //'`
+ print_linux_info "Redhat" $release
+ else
+ print_linux_info "unknown" "unknown"
+ fi
+}
+
+# Print information about a Solaris system. FIXME.
+get_solaris_info () {
+ kernel=`uname -v`
+ echo "Kernel: $kernel"
+}
+
+# Print information about a MacOS system. FIXME.
+get_macos_info () {
+ machine=`uname -m`
+ kernel=`uname -v`
+ echo "Machine: $machine | Kernel: $kernel"
+}
+
+# Print information about a FreeBSD system. FIXME.
+get_freebsd_info () {
+ kernel=`uname -v`
+ echo "Kernel: $kernel"
+}
+
+system=`uname -s`
+case "$system" in
+Linux|linux)
+ get_linux_info
+ ;;
+SunOS)
+ get_solaris_info
+ ;;
+Darwin)
+ get_macos_info
+ ;;
+FreeBSD)
+ get_freebsd_info
+ ;;
+*)
+ echo "System unknown"
+ exit 1
+ ;;
+esac
+exit 0
diff --git a/src/VBox/Installer/linux/check_module_dependencies.sh b/src/VBox/Installer/linux/check_module_dependencies.sh
new file mode 100755
index 00000000..968bfd2b
--- /dev/null
+++ b/src/VBox/Installer/linux/check_module_dependencies.sh
@@ -0,0 +1,227 @@
+#!/bin/sh
+#
+# Oracle VM VirtualBox
+# VirtualBox linux installation script
+
+#
+# Copyright (C) 2007-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+set -e
+
+# Usage:
+USAGE_MESSAGE=\
+'Usage: `basename ${0}` [-h|--help|
+ --test [<uname -r output> rpm|dpkg [<base expected> <versioned expected>]]]
+This script tests whether a Linux system is set up to build kernel modules,
+and if not prints a guess as to which distribution packages need to be
+installed to do so, and what commands to use. It uses the output of the
+"uname -r" command to guess the packages and searches for packaging tools
+by checking for packaging databases.
+
+For testing you can specify the output of "uname -r" which will be used
+instead of the real one and the package type, and optionally the expected
+output. --test without parameters will test a number of known inputs.'
+
+# General theory of operation (valid Nov 19 2016): we check whether this is an
+# rpm or dpkg system by checking for the respective non-empty database directory
+# (we assert that only one is present), and based on that we map uname -r output
+# to a kernel package name. Here is a textual description of known mappings
+# (not all of these are currently implemented) for both the general package name
+# and the version-specific package name. Keeping this here as it took some time
+# and pain to research.
+#
+# Debian/Ubuntu (dpkg): <version>-<flavour> -> linux-headers-<flavour>,
+# linux-headers-<version>-<flavour>
+DEBIAN_FLAVOURS="generic lowlatency virtual 486 686-pae amd64 rt-686-pae \
+ rt-amd64 i386 586 grsec-686-pae grsec-amd64 686"
+# SUSE (rpm): <version>-<flavour> -> kernel-<flavour>-devel,
+# kernel-<flavour>-devel-<version>
+SUSE_FLAVOURS="debug default ec2 pae trace vanilla vmi xen"
+# OL/RHEL/CentOS (rpm): <version><flavour>[.i686|.x86_64] -> kernel-<flavour>-devel,
+# kernel-<flavour>-devel-<`uname -r`>, where <version> ends in el*.
+EL_FLAVOURS="uek xen"
+# Fedora (rpm): <version> -> kernel-devel, kernel-devel-<version>, where <version>
+# ends in fc*.
+#
+# OUTPUT NOT YET TESTED ON REAL SYSTEMS
+#
+# Mageia (rpm): <version>-*.mga* -> kernel-linus-latest,
+# kernel-linus-<`uname -r`>
+# <version>-<flavour>-*.mga* -> kernel-<flavour>-latest,
+# kernel-<flavour>-<`uname -r`>
+MAGEIA_FLAVOURS="desktop desktop586 server tmb-desktop"
+# PCLinuxOS (dpkg): <version>-pclos* -> kernel-devel, kernel-devel-<`uname -r`>
+
+PATH=$PATH:/bin:/sbin:/usr/sbin
+
+HAVE_TOOLS=
+HAVE_HEADERS=
+PACKAGE_TYPE=
+UNAME=
+BASE_PACKAGE=
+VERSIONED_PACKAGE=
+TOOLS="gcc make perl"
+TEST=
+UNIT_TEST=
+
+case "${1}" in
+"")
+ # Return immediately successfully if everything is installed
+ type ${TOOLS} >/dev/null 2>&1 && HAVE_TOOLS=yes
+ test -d "/lib/modules/`uname -r`/build/include" && HAVE_HEADERS=yes
+ test -n "${HAVE_TOOLS}" && test -n "${HAVE_HEADERS}" && exit 0
+ UNAME=`uname -r`
+ for i in rpm dpkg; do
+ for j in /var/lib/${i}/*; do
+ test -e "${j}" || break
+ if test -z "${PACKAGE_TYPE}"; then
+ PACKAGE_TYPE="${i}"
+ else
+ PACKAGE_TYPE=unknown
+ fi
+ break
+ done
+ done
+ ;;
+-h|--help)
+ echo "${USAGE_MESSAGE}"
+ exit 0 ;;
+*)
+ ERROR=""
+ UNAME="${2}"
+ PACKAGE_TYPE="${3}"
+ BASE_EXPECTED="${4}"
+ VERSIONED_EXPECTED="${5}"
+ test "${1}" = --test || ERROR=yes
+ test -n "${UNAME}" && test -n "${PACKAGE_TYPE}" || test -z "${UNAME}" ||
+ ERROR=yes
+ test -n "${BASE_EXPECTED}" && test -n "${VERSIONED_EXPECTED}" ||
+ test -z "${BASE_EXPECTED}" || ERROR=yes
+ case "${ERROR}" in ?*)
+ echo "${USAGE_MESSAGE}" >&2
+ exit 1
+ esac
+ TEST=yes
+ TEST_PARAMS="${2} ${3} ${4} ${5}"
+ test -z "${UNAME}" && UNIT_TEST=yes
+ ;;
+esac
+
+case "${PACKAGE_TYPE}" in
+rpm)
+ for i in ${SUSE_FLAVOURS}; do
+ case "${UNAME}" in *-"${i}")
+ BASE_PACKAGE="kernel-${i}-devel"
+ VERSIONED_PACKAGE="kernel-${i}-devel-${UNAME%-${i}}"
+ break
+ esac
+ done
+ for i in ${EL_FLAVOURS} ""; do
+ case "${UNAME}" in *.el5"${i}"|*.el*"${i}".i686|*.el*"${i}".x86_64)
+ test -n "${i}" && i="${i}-" # Hack to handle empty flavour.
+ BASE_PACKAGE="kernel-${i}devel"
+ VERSIONED_PACKAGE="kernel-${i}devel-${UNAME}"
+ break
+ esac
+ done
+ case "${UNAME}" in *.fc*.i686|*.fc*.x86_64) # Fedora
+ BASE_PACKAGE="kernel-devel"
+ VERSIONED_PACKAGE="kernel-devel-${UNAME}"
+ esac
+ for i in ${MAGEIA_FLAVOURS} ""; do # Mageia
+ case "${UNAME}" in *-"${i}"*.mga*)
+ if test -z "${i}"; then
+ BASE_PACKAGE="kernel-linus-devel"
+ VERSIONED_PACKAGE="kernel-linus-devel-${UNAME}"
+ else
+ BASE_PACKAGE="kernel-${i}-devel"
+ VERSIONED_PACKAGE="kernel-${i}-devel-${UNAME%-${i}*}${UNAME#*${i}}"
+ fi
+ break
+ esac
+ done
+ ;;
+dpkg)
+ for i in ${DEBIAN_FLAVOURS}; do # Debian/Ubuntu
+ case "${UNAME}" in *-${i})
+ BASE_PACKAGE="linux-headers-${i}"
+ VERSIONED_PACKAGE="linux-headers-${UNAME}"
+ break
+ esac
+ done
+ case "${UNAME}" in *-pclos*) # PCLinuxOS
+ BASE_PACKAGE="kernel-devel"
+ VERSIONED_PACKAGE="kernel-devel-${UNAME}"
+ esac
+esac
+
+case "${UNIT_TEST}${BASE_EXPECTED}" in "")
+ echo "This system is currently not set up to build kernel modules." >&2
+ test -n "${HAVE_TOOLS}" ||
+ echo "Please install the ${TOOLS} packages from your distribution." >&2
+ test -n "${HAVE_HEADERS}" && exit 1
+ echo "Please install the Linux kernel \"header\" files matching the current kernel" >&2
+ echo "for adding new hardware support to the system." >&2
+ if test -n "${BASE_PACKAGE}${VERSIONED_PACKAGE}"; then
+ echo "The distribution packages containing the headers are probably:" >&2
+ echo " ${BASE_PACKAGE} ${VERSIONED_PACKAGE}" >&2
+ fi
+ test -z "${TEST}" && exit 1
+ exit 0
+esac
+
+case "${BASE_EXPECTED}" in ?*)
+ case "${BASE_EXPECTED} ${VERSIONED_EXPECTED}" in
+ "${BASE_PACKAGE} ${VERSIONED_PACKAGE}")
+ exit 0
+ esac
+ echo "Test: ${TEST_PARAMS}" >&2
+ echo "Result: ${BASE_PACKAGE} ${VERSIONED_PACKAGE}"
+ exit 1
+esac
+
+# Unit test as of here.
+# Test expected correct results.
+for i in \
+ "4.1.12-37.5.1.el6uek.x86_64 rpm kernel-uek-devel kernel-uek-devel-4.1.12-37.5.1.el6uek.x86_64" \
+ "2.6.32-642.el6.x86_64 rpm kernel-devel kernel-devel-2.6.32-642.el6.x86_64" \
+ "4.1.12-vanilla rpm kernel-vanilla-devel kernel-vanilla-devel-4.1.12" \
+ "4.8.8-pclos1 dpkg kernel-devel kernel-devel-4.8.8-pclos1" \
+ "4.8.8-desktop-1.mga6 rpm kernel-desktop-devel kernel-desktop-devel-4.8.8-1.mga6" \
+ "3.19.8-2.mga5 rpm kernel-linus-devel kernel-linus-devel-3.19.8-2.mga5" \
+ "4.8.0-27-generic dpkg linux-headers-generic linux-headers-4.8.0-27-generic"
+do
+ "${0}" --test ${i} || exit 1
+done
+
+# Test argument combinations expected to fail.
+for i in \
+ "--test NOT_EMPTY" \
+ "--test NOT_EMPTY NOT_EMPTY NOT_EMPTY" \
+ "--wrong" \
+ "--test 4.8.8-pclos1 dpkg kernel-devel kernel-devel-WRONG" \
+ "--test 4.8.8-pclos1 dpkg kernel-WRONG kernel-devel-4.8.8-pclos1"
+do
+ "${0}" ${i} >/dev/null 2>&1 && echo "Bad argument test failed:" &&
+ echo " ${i}" && exit 1
+done
+exit 0
diff --git a/src/VBox/Installer/linux/deffiles b/src/VBox/Installer/linux/deffiles
new file mode 100755
index 00000000..7d5cbbf5
--- /dev/null
+++ b/src/VBox/Installer/linux/deffiles
@@ -0,0 +1,615 @@
+#!/bin/sh
+# $Id$
+## @file
+# Oracle VM VirtualBox - linux default files list.
+#
+
+#
+# Copyright (C) 2007-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+# No entries should ever be removed from this file, as it is used
+# for uninstalling old installations of VirtualBox which did not
+# keep track of the names of their files. Similarly it should not
+# be necessary to add new entries to the list (in fact all of the
+# entries added after the file was first created are probably
+# redundant). Actually though it can't hurt, in case something goes
+# wrong with an installation...
+
+DEFAULT_FILE_NAMES=" \
+ VBoxDD.so \
+ VBoxDD2.so \
+ VBoxDTrace \
+ VBoxKeyboard.so \
+ VBoxManage \
+ VBoxNetDHCP \
+ VBoxNetDHCP.so \
+ VBoxRT.so \
+ VBoxSDL \
+ VBoxSDL.so \
+ VBoxSVC \
+ VBoxSVCM.so \
+ VBoxDDU.so \
+ VBoxVMM.so \
+ VBoxXPCOM.so \
+ VBoxXPCOMC.so \
+ VBoxXPCOMIPCD \
+ VirtualBox \
+ VirtualBoxVM \
+ VirtualBox.so \
+ VBoxSettings.so \
+ VBoxSharedFolders.so \
+ VBoxSharedClipboard.so \
+ VBoxGuestPropSvc.so \
+ VBoxGuestControlSvc.so \
+ VBoxHostChannel.so \
+ VBoxDragAndDropSvc.so \
+ VBoxAuth.so \
+ VBoxAuthSimple.so \
+ VBoxDbg.so \
+ VBoxDbg3.so \
+ DbgPlugInDiggers.so \
+ DBGCPlugInDiggers.so \
+ VBoxHeadless \
+ VBoxHeadless.so \
+ VBoxDD2RC.rc \
+ VBoxDD2R0.r0 \
+ VBoxDD2GC.gc \
+ VBoxDDRC.rc \
+ VBoxDDR0.r0 \
+ VBoxDDGC.gc \
+ VMMRC.rc \
+ VMMR0.r0 \
+ VMMGC.gc \
+ vboxefi.fv \
+ vboxefi64.fv \
+ vboxwebsrv \
+ vbox-img \
+ vboximg-mount \
+ components/comreg.dat \
+ components/xpti.dat \
+ components/VBoxC.so \
+ components/VBoxDDU.so \
+ components/VBoxRT.so \
+ components/VBoxVMM.so \
+ components/VBoxXPCOM.so \
+ components/VBoxXPCOMBase.xpt \
+ components/VBoxXPCOMIPCC.so \
+ components/VirtualBox_XPCOM.xpt \
+ dtrace/lib/amd64/vbox-types.d \
+ dtrace/lib/amd64/vbox-arch-types.d \
+ dtrace/lib/amd64/vm.d \
+ dtrace/lib/amd64/cpumctx.d \
+ dtrace/lib/amd64/CPUMInternal.d \
+ dtrace/lib/amd64/x86.d \
+ dtrace/lib/x86/vbox-types.d \
+ dtrace/lib/x86/vbox-arch-types.d \
+ dtrace/lib/x86/vm.d \
+ dtrace/lib/x86/cpumctx.d \
+ dtrace/lib/x86/CPUMInternal.d \
+ dtrace/lib/x86/x86.d \
+ dtrace/testcase/amd64/vbox-vm-struct-test.d \
+ dtrace/testcase/x86/vbox-vm-struct-test.d \
+ VBox.sh \
+ VBox.png \
+ virtualbox.desktop \
+ virtualboxvm.desktop \
+ src/ \
+ src/include/ \
+ src/include/iprt/ \
+ src/include/iprt/alloc.h \
+ src/include/iprt/asm.h \
+ src/include/iprt/assert.h \
+ src/include/iprt/cdefs.h \
+ src/include/iprt/err.h \
+ src/include/iprt/log.h \
+ src/include/iprt/mem.h \
+ src/include/iprt/param.h \
+ src/include/iprt/semaphore.h \
+ src/include/iprt/spinlock.h \
+ src/include/iprt/stdarg.h \
+ src/include/iprt/stdint.h \
+ src/include/iprt/string.h \
+ src/include/iprt/thread.h \
+ src/include/iprt/types.h \
+ src/include/iprt/uuid.h \
+ src/include/iprt/x86.h \
+ src/include/internal/initterm.h \
+ src/include/internal/magics.h \
+ src/include/internal/thread.h \
+ src/include/VBox/ \
+ src/include/VBox/cdefs.h \
+ src/include/VBox/err.h \
+ src/include/VBox/log.h \
+ src/include/VBox/sup.h \
+ src/include/VBox/hwaccm_svm.h \
+ src/include/VBox/hwaccm_vmx.h \
+ src/include/VBox/x86.h \
+ src/include/VBox/types.h \
+ src/linux/ \
+ src/linux/SUPDrv-linux.c \
+ src/Makefile \
+ src/r0drv/ \
+ src/r0drv/alloc-r0drv.c \
+ src/r0drv/alloc-r0drv.h \
+ src/r0drv/linux/ \
+ src/r0drv/linux/alloc-r0drv-linux.c \
+ src/r0drv/linux/semaphore-r0drv-linux.c \
+ src/r0drv/linux/spinlock-r0drv-linux.c \
+ src/r0drv/linux/string.h \
+ src/r0drv/linux/thread-r0drv-linux.c \
+ src/r0drv/linux/the-linux-kernel.h \
+ src/SUPDRVIOC.h \
+ src/SUPDRVShared.c \
+ src/SUPDrv.c \
+ src/SUPDrvAgnostic.c \
+ src/SUPDrvIDC.h \
+ src/SUPDrvIOC.h \
+ src/SUPDrvInternal.h \
+ src/SUPDrvSem.c \
+ src/Modules.symvers \
+ src/version-generated.h \
+ nls/qt_de.qm \
+ nls/VirtualBox_de.qm \
+ nls/qt_fr.qm \
+ nls/VirtualBox_fr.qm \
+ nls/qt_it.qm \
+ nls/VirtualBox_it.qm \
+ nls/qt_ro.qm \
+ nls/VirtualBox_ro.qm \
+ nls/qt_zh_CN.qm \
+ nls/VirtualBox_zh_CN.qm \
+ nls/qt_ja.qm \
+ nls/VirtualBox_ja.qm \
+ nls/qt_es.ts \
+ nls/VirtualBox_es.ts \
+ nls/qt_ru.ts \
+ nls/VirtualBox_ru.ts \
+ nls/qt_pl.ts \
+ nls/VirtualBox_pl.ts \
+ nls/qt_pt_BR.ts \
+ nls/VirtualBox_pt_BR.ts \
+ nls/qt_ko.ts \
+ nls/VirtualBox_ko.ts \
+ nls/qt_sv.ts \
+ nls/VirtualBox_sv.ts \
+ nls/qt_fi.ts \
+ nls/VirtualBox_fi.ts \
+ nls/qt_hu.ts \
+ nls/VirtualBox_hu.ts \
+ nls/qt_cs.ts \
+ nls/VirtualBox_cs.ts \
+ sdk/ \
+ sdk/include/ \
+ sdk/include/xpcom/ \
+ sdk/include/xpcom/nsprpub/ \
+ sdk/include/xpcom/nsprpub/md/ \
+ sdk/include/xpcom/nsprpub/md/prosdep.h \
+ sdk/include/xpcom/nsprpub/md/_pth.h \
+ sdk/include/xpcom/nsprpub/md/_unix_errors.h \
+ sdk/include/xpcom/nsprpub/md/_unixos.h \
+ sdk/include/xpcom/nsprpub/md/_l4v2.h \
+ sdk/include/xpcom/nsprpub/md/_linux.h \
+ sdk/include/xpcom/nsprpub/obsolete/ \
+ sdk/include/xpcom/nsprpub/obsolete/prsem.h \
+ sdk/include/xpcom/nsprpub/obsolete/protypes.h \
+ sdk/include/xpcom/nsprpub/obsolete/probslet.h \
+ sdk/include/xpcom/nsprpub/obsolete/pralarm.h \
+ sdk/include/xpcom/nsprpub/private/ \
+ sdk/include/xpcom/nsprpub/private/prpriv.h \
+ sdk/include/xpcom/nsprpub/private/pprthred.h \
+ sdk/include/xpcom/nsprpub/private/pprio.h \
+ sdk/include/xpcom/nsprpub/prcpucfg.h \
+ sdk/include/xpcom/nsprpub/_linuxcfg.h \
+ sdk/include/xpcom/nsprpub/_l4v2cfg.h \
+ sdk/include/xpcom/nsprpub/prwin16.h \
+ sdk/include/xpcom/nsprpub/prvrsion.h \
+ sdk/include/xpcom/nsprpub/prtypes.h \
+ sdk/include/xpcom/nsprpub/prtrace.h \
+ sdk/include/xpcom/nsprpub/prtpool.h \
+ sdk/include/xpcom/nsprpub/prtime.h \
+ sdk/include/xpcom/nsprpub/prthread.h \
+ sdk/include/xpcom/nsprpub/prsystem.h \
+ sdk/include/xpcom/nsprpub/prshma.h \
+ sdk/include/xpcom/nsprpub/prshm.h \
+ sdk/include/xpcom/nsprpub/prrwlock.h \
+ sdk/include/xpcom/nsprpub/prrng.h \
+ sdk/include/xpcom/nsprpub/prproces.h \
+ sdk/include/xpcom/nsprpub/prprf.h \
+ sdk/include/xpcom/nsprpub/prpdce.h \
+ sdk/include/xpcom/nsprpub/prolock.h \
+ sdk/include/xpcom/nsprpub/prnetdb.h \
+ sdk/include/xpcom/nsprpub/prmwait.h \
+ sdk/include/xpcom/nsprpub/prmon.h \
+ sdk/include/xpcom/nsprpub/prmem.h \
+ sdk/include/xpcom/nsprpub/prlong.h \
+ sdk/include/xpcom/nsprpub/prlog.h \
+ sdk/include/xpcom/nsprpub/prlock.h \
+ sdk/include/xpcom/nsprpub/prlink.h \
+ sdk/include/xpcom/nsprpub/pripcsem.h \
+ sdk/include/xpcom/nsprpub/prio.h \
+ sdk/include/xpcom/nsprpub/prinrval.h \
+ sdk/include/xpcom/nsprpub/prinit.h \
+ sdk/include/xpcom/nsprpub/prinet.h \
+ sdk/include/xpcom/nsprpub/prerror.h \
+ sdk/include/xpcom/nsprpub/prerr.h \
+ sdk/include/xpcom/nsprpub/prenv.h \
+ sdk/include/xpcom/nsprpub/prdtoa.h \
+ sdk/include/xpcom/nsprpub/prcvar.h \
+ sdk/include/xpcom/nsprpub/prcountr.h \
+ sdk/include/xpcom/nsprpub/prcmon.h \
+ sdk/include/xpcom/nsprpub/prclist.h \
+ sdk/include/xpcom/nsprpub/prbit.h \
+ sdk/include/xpcom/nsprpub/pratom.h \
+ sdk/include/xpcom/nsprpub/plstr.h \
+ sdk/include/xpcom/nsprpub/plresolv.h \
+ sdk/include/xpcom/nsprpub/plhash.h \
+ sdk/include/xpcom/nsprpub/plgetopt.h \
+ sdk/include/xpcom/nsprpub/plerror.h \
+ sdk/include/xpcom/nsprpub/plbase64.h \
+ sdk/include/xpcom/nsprpub/plarenas.h \
+ sdk/include/xpcom/nsprpub/plarena.h \
+ sdk/include/xpcom/nsprpub/nspr.h \
+ sdk/include/xpcom/string/ \
+ sdk/include/xpcom/string/string-template-undef.h \
+ sdk/include/xpcom/string/string-template-def-unichar.h \
+ sdk/include/xpcom/string/string-template-def-char.h \
+ sdk/include/xpcom/string/nsXPIDLString.h \
+ sdk/include/xpcom/string/nsUTF8Utils.h \
+ sdk/include/xpcom/string/nsTSubstringTuple.h \
+ sdk/include/xpcom/string/nsTSubstring.h \
+ sdk/include/xpcom/string/nsTString.h \
+ sdk/include/xpcom/string/nsTPromiseFlatString.h \
+ sdk/include/xpcom/string/nsTObsoleteAString.h \
+ sdk/include/xpcom/string/nsTDependentSubstring.h \
+ sdk/include/xpcom/string/nsTDependentString.h \
+ sdk/include/xpcom/string/nsTAString.h \
+ sdk/include/xpcom/string/nsSubstringTuple.h \
+ sdk/include/xpcom/string/nsSubstring.h \
+ sdk/include/xpcom/string/nsStringIterator.h \
+ sdk/include/xpcom/string/nsStringFwd.h \
+ sdk/include/xpcom/string/nsStringAPI.h \
+ sdk/include/xpcom/string/nsString.h \
+ sdk/include/xpcom/string/nsReadableUtils.h \
+ sdk/include/xpcom/string/nsPromiseFlatString.h \
+ sdk/include/xpcom/string/nsPrintfCString.h \
+ sdk/include/xpcom/string/nsObsoleteAString.h \
+ sdk/include/xpcom/string/nsLiteralString.h \
+ sdk/include/xpcom/string/nsEmbedString.h \
+ sdk/include/xpcom/string/nsDependentSubstring.h \
+ sdk/include/xpcom/string/nsDependentString.h \
+ sdk/include/xpcom/string/nsCharTraits.h \
+ sdk/include/xpcom/string/nsAlgorithm.h \
+ sdk/include/xpcom/string/nsAString.h \
+ sdk/include/xpcom/xpcom/ \
+ sdk/include/xpcom/xpcom/xpcom-config.h \
+ sdk/include/xpcom/xpcom/xptinfo.h \
+ sdk/include/xpcom/xpcom/xptcstubsdef.inc \
+ sdk/include/xpcom/xpcom/xptcstubsdecl.inc \
+ sdk/include/xpcom/xpcom/xptcall.h \
+ sdk/include/xpcom/xpcom/xpt_xdr.h \
+ sdk/include/xpcom/xpcom/xpt_struct.h \
+ sdk/include/xpcom/xpcom/xpt_arena.h \
+ sdk/include/xpcom/xpcom/xcDll.h \
+ sdk/include/xpcom/xpcom/plevent.h \
+ sdk/include/xpcom/xpcom/pldhash.h \
+ sdk/include/xpcom/xpcom/nscore.h \
+ sdk/include/xpcom/xpcom/nsXPCOMGlue.h \
+ sdk/include/xpcom/xpcom/nsXPCOMCID.h \
+ sdk/include/xpcom/xpcom/nsXPCOM.h \
+ sdk/include/xpcom/xpcom/nsWeakReference.h \
+ sdk/include/xpcom/xpcom/nsWeakPtr.h \
+ sdk/include/xpcom/xpcom/nsVoidArray.h \
+ sdk/include/xpcom/xpcom/nsVariant.h \
+ sdk/include/xpcom/xpcom/nsValueArray.h \
+ sdk/include/xpcom/xpcom/nsUnitConversion.h \
+ sdk/include/xpcom/xpcom/nsTraceRefcntImpl.h \
+ sdk/include/xpcom/xpcom/nsTraceRefcnt.h \
+ sdk/include/xpcom/xpcom/nsTime.h \
+ sdk/include/xpcom/xpcom/nsTextFormatter.h \
+ sdk/include/xpcom/xpcom/nsTHashtable.h \
+ sdk/include/xpcom/xpcom/nsSupportsPrimitives.h \
+ sdk/include/xpcom/xpcom/nsSupportsArray.h \
+ sdk/include/xpcom/xpcom/nsStringStream.h \
+ sdk/include/xpcom/xpcom/nsStringIO.h \
+ sdk/include/xpcom/xpcom/nsStringEnumerator.h \
+ sdk/include/xpcom/xpcom/nsStreamUtils.h \
+ sdk/include/xpcom/xpcom/nsStorageStream.h \
+ sdk/include/xpcom/xpcom/nsStaticNameTable.h \
+ sdk/include/xpcom/xpcom/nsStaticComponent.h \
+ sdk/include/xpcom/xpcom/nsStaticAtom.h \
+ sdk/include/xpcom/xpcom/nsScriptableInputStream.h \
+ sdk/include/xpcom/xpcom/nsRefPtrHashtable.h \
+ sdk/include/xpcom/xpcom/nsRecyclingAllocator.h \
+ sdk/include/xpcom/xpcom/nsQuickSort.h \
+ sdk/include/xpcom/xpcom/nsProxyRelease.h \
+ sdk/include/xpcom/xpcom/nsProxyEvent.h \
+ sdk/include/xpcom/xpcom/nsProxiedService.h \
+ sdk/include/xpcom/xpcom/nsProcess.h \
+ sdk/include/xpcom/xpcom/nsObsoleteModuleLoading.h \
+ sdk/include/xpcom/xpcom/nsObserverService.h \
+ sdk/include/xpcom/xpcom/nsNativeComponentLoader.h \
+ sdk/include/xpcom/xpcom/nsNativeCharsetUtils.h \
+ sdk/include/xpcom/xpcom/nsMultiplexInputStream.h \
+ sdk/include/xpcom/xpcom/nsModule.h \
+ sdk/include/xpcom/xpcom/nsMemory.h \
+ sdk/include/xpcom/xpcom/nsLocalFileUnix.h \
+ sdk/include/xpcom/xpcom/nsLocalFile.h \
+ sdk/include/xpcom/xpcom/nsLinebreakConverter.h \
+ sdk/include/xpcom/xpcom/nsInterfaceHashtable.h \
+ sdk/include/xpcom/xpcom/nsInt64.h \
+ sdk/include/xpcom/xpcom/nsIWeakReferenceUtils.h \
+ sdk/include/xpcom/xpcom/nsIUnicharInputStream.h \
+ sdk/include/xpcom/xpcom/nsIUnicharBuffer.h \
+ sdk/include/xpcom/xpcom/nsISupportsUtils.h \
+ sdk/include/xpcom/xpcom/nsISupportsObsolete.h \
+ sdk/include/xpcom/xpcom/nsISupportsImpl.h \
+ sdk/include/xpcom/xpcom/nsISupportsBase.h \
+ sdk/include/xpcom/xpcom/nsIServiceManagerUtils.h \
+ sdk/include/xpcom/xpcom/nsIServiceManagerObsolete.h \
+ sdk/include/xpcom/xpcom/nsIInterfaceRequestorUtils.h \
+ sdk/include/xpcom/xpcom/nsIID.h \
+ sdk/include/xpcom/xpcom/nsIGenericFactory.h \
+ sdk/include/xpcom/xpcom/nsID.h \
+ sdk/include/xpcom/xpcom/nsIByteBuffer.h \
+ sdk/include/xpcom/xpcom/nsIAllocator.h \
+ sdk/include/xpcom/xpcom/nsHashtable.h \
+ sdk/include/xpcom/xpcom/nsHashSets.h \
+ sdk/include/xpcom/xpcom/nsHashKeys.h \
+ sdk/include/xpcom/xpcom/nsGenericFactory.h \
+ sdk/include/xpcom/xpcom/nsFixedSizeAllocator.h \
+ sdk/include/xpcom/xpcom/nsFastLoadService.h \
+ sdk/include/xpcom/xpcom/nsFastLoadPtr.h \
+ sdk/include/xpcom/xpcom/nsEventQueueUtils.h \
+ sdk/include/xpcom/xpcom/nsEscape.h \
+ sdk/include/xpcom/xpcom/nsError.h \
+ sdk/include/xpcom/xpcom/nsEnumeratorUtils.h \
+ sdk/include/xpcom/xpcom/nsDoubleHashtable.h \
+ sdk/include/xpcom/xpcom/nsDirectoryServiceUtils.h \
+ sdk/include/xpcom/xpcom/nsDirectoryServiceDefs.h \
+ sdk/include/xpcom/xpcom/nsDirectoryService.h \
+ sdk/include/xpcom/xpcom/nsDeque.h \
+ sdk/include/xpcom/xpcom/nsDebugImpl.h \
+ sdk/include/xpcom/xpcom/nsDebug.h \
+ sdk/include/xpcom/xpcom/nsDataHashtable.h \
+ sdk/include/xpcom/xpcom/nsCppSharedAllocator.h \
+ sdk/include/xpcom/xpcom/nsComponentManagerUtils.h \
+ sdk/include/xpcom/xpcom/nsComponentManagerObsolete.h \
+ sdk/include/xpcom/xpcom/nsCom.h \
+ sdk/include/xpcom/xpcom/nsClassHashtable.h \
+ sdk/include/xpcom/xpcom/nsCheapSets.h \
+ sdk/include/xpcom/xpcom/nsCategoryManagerUtils.h \
+ sdk/include/xpcom/xpcom/nsCRT.h \
+ sdk/include/xpcom/xpcom/nsCOMPtr.h \
+ sdk/include/xpcom/xpcom/nsCOMArray.h \
+ sdk/include/xpcom/xpcom/nsBaseHashtable.h \
+ sdk/include/xpcom/xpcom/nsAutoPtr.h \
+ sdk/include/xpcom/xpcom/nsAutoLock.h \
+ sdk/include/xpcom/xpcom/nsAutoBuffer.h \
+ sdk/include/xpcom/xpcom/nsAtomService.h \
+ sdk/include/xpcom/xpcom/nsArrayEnumerator.h \
+ sdk/include/xpcom/xpcom/nsArray.h \
+ sdk/include/xpcom/xpcom/nsAppDirectoryServiceDefs.h \
+ sdk/include/xpcom/xpcom/nsAgg.h \
+ sdk/include/xpcom/ipcd/ \
+ sdk/include/xpcom/ipcd/ipcdclient.h \
+ sdk/include/xpcom/ipcd/ipcModuleUtil.h \
+ sdk/include/xpcom/ipcd/ipcModule.h \
+ sdk/include/xpcom/ipcd/ipcMessageWriter.h \
+ sdk/include/xpcom/ipcd/ipcMessageReader.h \
+ sdk/include/xpcom/ipcd/ipcLockCID.h \
+ sdk/include/xpcom/ipcd/ipcCID.h \
+ sdk/include/xpcom/.keep \
+ sdk/include/nsIDebug.h \
+ sdk/include/nsIInterfaceRequestor.h \
+ sdk/include/nsIMemory.h \
+ sdk/include/nsIProgrammingLanguage.h \
+ sdk/include/nsISupports.h \
+ sdk/include/nsITraceRefcnt.h \
+ sdk/include/nsIWeakReference.h \
+ sdk/include/nsIConsoleMessage.h \
+ sdk/include/nsIConsoleService.h \
+ sdk/include/nsIConsoleListener.h \
+ sdk/include/nsIErrorService.h \
+ sdk/include/nsIException.h \
+ sdk/include/nsIExceptionService.h \
+ sdk/include/nsrootidl.h \
+ sdk/include/nsIClassInfo.h \
+ sdk/include/nsIComponentRegistrar.h \
+ sdk/include/nsIFactory.h \
+ sdk/include/nsIModule.h \
+ sdk/include/nsIServiceManager.h \
+ sdk/include/nsIComponentManager.h \
+ sdk/include/nsICategoryManager.h \
+ sdk/include/nsIComponentLoader.h \
+ sdk/include/nsINativeComponentLoader.h \
+ sdk/include/nsIComponentManagerObsolete.h \
+ sdk/include/nsIComponentLoaderManager.h \
+ sdk/include/nsISupportsArray.h \
+ sdk/include/nsICollection.h \
+ sdk/include/nsISerializable.h \
+ sdk/include/nsIEnumerator.h \
+ sdk/include/nsISimpleEnumerator.h \
+ sdk/include/nsIObserverService.h \
+ sdk/include/nsIObserver.h \
+ sdk/include/nsIAtom.h \
+ sdk/include/nsIAtomService.h \
+ sdk/include/nsIProperties.h \
+ sdk/include/nsIPersistentProperties2.h \
+ sdk/include/nsIRecyclingAllocator.h \
+ sdk/include/nsIStringEnumerator.h \
+ sdk/include/nsISupportsPrimitives.h \
+ sdk/include/nsISupportsIterators.h \
+ sdk/include/nsIVariant.h \
+ sdk/include/nsITimelineService.h \
+ sdk/include/nsIArray.h \
+ sdk/include/nsIPropertyBag.h \
+ sdk/include/nsIDirectoryService.h \
+ sdk/include/nsIFile.h \
+ sdk/include/nsILocalFile.h \
+ sdk/include/nsIInputStream.h \
+ sdk/include/nsIObjectInputStream.h \
+ sdk/include/nsIBinaryInputStream.h \
+ sdk/include/nsIObjectOutputStream.h \
+ sdk/include/nsIBinaryOutputStream.h \
+ sdk/include/nsIOutputStream.h \
+ sdk/include/nsIStreamBufferAccess.h \
+ sdk/include/nsIByteArrayInputStream.h \
+ sdk/include/nsISeekableStream.h \
+ sdk/include/nsIFastLoadFileControl.h \
+ sdk/include/nsIFastLoadService.h \
+ sdk/include/nsIInputStreamTee.h \
+ sdk/include/nsIMultiplexInputStream.h \
+ sdk/include/nsIPipe.h \
+ sdk/include/nsIAsyncInputStream.h \
+ sdk/include/nsIAsyncOutputStream.h \
+ sdk/include/nsIScriptableInputStream.h \
+ sdk/include/nsIStorageStream.h \
+ sdk/include/nsIStringStream.h \
+ sdk/include/nsILineInputStream.h \
+ sdk/include/nsIProxyObjectManager.h \
+ sdk/include/nsIEventQueueService.h \
+ sdk/include/nsIEventQueue.h \
+ sdk/include/nsIEventTarget.h \
+ sdk/include/nsIRunnable.h \
+ sdk/include/nsIThread.h \
+ sdk/include/nsITimer.h \
+ sdk/include/nsIEnvironment.h \
+ sdk/include/nsITimerInternal.h \
+ sdk/include/nsITimerManager.h \
+ sdk/include/nsIProcess.h \
+ sdk/include/nsIInterfaceInfo.h \
+ sdk/include/nsIInterfaceInfoManager.h \
+ sdk/include/nsIXPTLoader.h \
+ sdk/include/ipcIService.h \
+ sdk/include/ipcIMessageObserver.h \
+ sdk/include/ipcIClientObserver.h \
+ sdk/include/ipcILockService.h \
+ sdk/include/ipcITransactionService.h \
+ sdk/include/ipcIDConnectService.h \
+ sdk/include/ipcITransactionObserver.h \
+ sdk/include/VirtualBox_XPCOM.h \
+ sdk/include/VBoxAuth.h \
+ sdk/installer/build/lib/vboxapi/VirtualBox_constants.py
+ sdk/installer/build/lib/vboxapi/__init__.py
+ sdk/idl/ \
+ sdk/idl/nsIDebug.idl \
+ sdk/idl/nsIInterfaceRequestor.idl \
+ sdk/idl/nsIMemory.idl \
+ sdk/idl/nsIProgrammingLanguage.idl \
+ sdk/idl/nsISupports.idl \
+ sdk/idl/nsITraceRefcnt.idl \
+ sdk/idl/nsIWeakReference.idl \
+ sdk/idl/nsIConsoleMessage.idl \
+ sdk/idl/nsIConsoleService.idl \
+ sdk/idl/nsIConsoleListener.idl \
+ sdk/idl/nsIErrorService.idl \
+ sdk/idl/nsIException.idl \
+ sdk/idl/nsIExceptionService.idl \
+ sdk/idl/nsrootidl.idl \
+ sdk/idl/nsIClassInfo.idl \
+ sdk/idl/nsIComponentRegistrar.idl \
+ sdk/idl/nsIFactory.idl \
+ sdk/idl/nsIModule.idl \
+ sdk/idl/nsIServiceManager.idl \
+ sdk/idl/nsIComponentManager.idl \
+ sdk/idl/nsICategoryManager.idl \
+ sdk/idl/nsIComponentLoader.idl \
+ sdk/idl/nsINativeComponentLoader.idl \
+ sdk/idl/nsIComponentManagerObsolete.idl \
+ sdk/idl/nsIComponentLoaderManager.idl \
+ sdk/idl/nsISupportsArray.idl \
+ sdk/idl/nsICollection.idl \
+ sdk/idl/nsISerializable.idl \
+ sdk/idl/nsIEnumerator.idl \
+ sdk/idl/nsISimpleEnumerator.idl \
+ sdk/idl/nsIObserverService.idl \
+ sdk/idl/nsIObserver.idl \
+ sdk/idl/nsIAtom.idl \
+ sdk/idl/nsIAtomService.idl \
+ sdk/idl/nsIProperties.idl \
+ sdk/idl/nsIPersistentProperties2.idl \
+ sdk/idl/nsIRecyclingAllocator.idl \
+ sdk/idl/nsIStringEnumerator.idl \
+ sdk/idl/nsISupportsPrimitives.idl \
+ sdk/idl/nsISupportsIterators.idl \
+ sdk/idl/nsIVariant.idl \
+ sdk/idl/nsITimelineService.idl \
+ sdk/idl/nsIArray.idl \
+ sdk/idl/nsIPropertyBag.idl \
+ sdk/idl/nsIDirectoryService.idl \
+ sdk/idl/nsIFile.idl \
+ sdk/idl/nsILocalFile.idl \
+ sdk/idl/nsIInputStream.idl \
+ sdk/idl/nsIObjectInputStream.idl \
+ sdk/idl/nsIBinaryInputStream.idl \
+ sdk/idl/nsIObjectOutputStream.idl \
+ sdk/idl/nsIBinaryOutputStream.idl \
+ sdk/idl/nsIOutputStream.idl \
+ sdk/idl/nsIStreamBufferAccess.idl \
+ sdk/idl/nsIByteArrayInputStream.idl \
+ sdk/idl/nsISeekableStream.idl \
+ sdk/idl/nsIFastLoadFileControl.idl \
+ sdk/idl/nsIFastLoadService.idl \
+ sdk/idl/nsIInputStreamTee.idl \
+ sdk/idl/nsIMultiplexInputStream.idl \
+ sdk/idl/nsIPipe.idl \
+ sdk/idl/nsIAsyncInputStream.idl \
+ sdk/idl/nsIAsyncOutputStream.idl \
+ sdk/idl/nsIScriptableInputStream.idl \
+ sdk/idl/nsIStorageStream.idl \
+ sdk/idl/nsIStringStream.idl \
+ sdk/idl/nsILineInputStream.idl \
+ sdk/idl/nsIProxyObjectManager.idl \
+ sdk/idl/nsIEventQueueService.idl \
+ sdk/idl/nsIEventQueue.idl \
+ sdk/idl/nsIEventTarget.idl \
+ sdk/idl/nsIRunnable.idl \
+ sdk/idl/nsIThread.idl \
+ sdk/idl/nsITimer.idl \
+ sdk/idl/nsIEnvironment.idl \
+ sdk/idl/nsITimerInternal.idl \
+ sdk/idl/nsITimerManager.idl \
+ sdk/idl/nsIProcess.idl \
+ sdk/idl/nsIInterfaceInfo.idl \
+ sdk/idl/nsIInterfaceInfoManager.idl \
+ sdk/idl/nsIXPTLoader.idl \
+ sdk/idl/ipcIService.idl \
+ sdk/idl/ipcIMessageObserver.idl \
+ sdk/idl/ipcIClientObserver.idl \
+ sdk/idl/ipcILockService.idl \
+ sdk/idl/ipcITransactionService.idl \
+ sdk/idl/ipcIDConnectService.idl \
+ sdk/idl/ipcITransactionObserver.idl \
+ sdk/idl/VirtualBox_XPCOM.idl \
+ sdk/lib/ \
+ sdk/lib/VBoxXPCOMGlue.a \
+ sdk/webservice/vboxweb.wsdl \
+ sdk/webservice/vboxwebService.wsdl \
+ sdk/samples/ \
+ sdk/samples/auth/ \
+ sdk/samples/auth/pam.cpp \
+ sdk/samples/API/ \
+ sdk/samples/API/tstVBoxAPILinux.cpp \
+ sdk/samples/API/makefile.tstVBoxAPILinux \
+ sdk/samples/API/tstVBoxAPILinux \
+ additions/VBoxGuestAdditions.iso \
+ UserManual.pdf "
diff --git a/src/VBox/Installer/linux/distributions_deb b/src/VBox/Installer/linux/distributions_deb
new file mode 100644
index 00000000..072f3323
--- /dev/null
+++ b/src/VBox/Installer/linux/distributions_deb
@@ -0,0 +1,8 @@
+_Debian_sid = DEBIAN_12_0
+_Debian_bookworm = DEBIAN_12_0
+_Debian_bullseye = DEBIAN_11_0
+_Debian_buster = DEBIAN_10_0
+_Ubuntu_jammy = UBUNTU_22_04
+_Ubuntu_focal = UBUNTU_20_04
+_Ubuntu_eoan = UBUNTU_19_10
+_Ubuntu_bionic = UBUNTU_18_04
diff --git a/src/VBox/Installer/linux/distributions_rpm b/src/VBox/Installer/linux/distributions_rpm
new file mode 100644
index 00000000..cb33dbd0
--- /dev/null
+++ b/src/VBox/Installer/linux/distributions_rpm
@@ -0,0 +1,11 @@
+openSUSETW = OPENSUSE_TW
+openSUSE155 = OPENSUSE_15_5
+openSUSE154 = OPENSUSE_15_4
+openSUSE153 = OPENSUSE_15_3
+fedora38 = FEDORA_38
+fedora37 = FEDORA_37
+fedora36 = FEDORA_36
+fedora35 = FEDORA_35
+el9 = EL_9
+el8 = EL_8
+el7 = EL_7
diff --git a/src/VBox/Installer/linux/install.sh b/src/VBox/Installer/linux/install.sh
new file mode 100755
index 00000000..9c11eb9b
--- /dev/null
+++ b/src/VBox/Installer/linux/install.sh
@@ -0,0 +1,448 @@
+#!/bin/sh
+#
+# Oracle VM VirtualBox
+# VirtualBox linux installation script
+
+#
+# Copyright (C) 2007-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+# Testing:
+# * After successful installation, 0 is returned if the vboxdrv module version
+# built matches the one loaded.
+# * If the kernel modules cannot be built (run the installer with KERN_VER=none)
+# or loaded (run with KERN_VER=<installed non-current version>)
+# then 1 is returned.
+
+PATH=$PATH:/bin:/sbin:/usr/sbin
+
+# Include routines and utilities needed by the installer
+. ./routines.sh
+
+LOG="/var/log/vbox-install.log"
+VERSION="_VERSION_"
+SVNREV="_SVNREV_"
+BUILD="_BUILD_"
+ARCH="_ARCH_"
+HARDENED="_HARDENED_"
+# The "BUILD_" prefixes prevent the variables from being overwritten when we
+# read the configuration from the previous installation.
+BUILD_VBOX_KBUILD_TYPE="_BUILDTYPE_"
+BUILD_USERNAME="_USERNAME_"
+CONFIG_DIR="/etc/vbox"
+CONFIG="vbox.cfg"
+CONFIG_FILES="filelist"
+DEFAULT_FILES=`pwd`/deffiles
+GROUPNAME="vboxusers"
+INSTALLATION_DIR="_INSTALLATION_DIR_"
+LICENSE_ACCEPTED=""
+PREV_INSTALLATION=""
+PYTHON="_PYTHON_"
+ACTION=""
+SELF=$1
+RC_SCRIPT=0
+if [ -n "$HARDENED" ]; then
+ VBOXDRV_MODE=0600
+ VBOXDRV_GRP="root"
+else
+ VBOXDRV_MODE=0660
+ VBOXDRV_GRP=$GROUPNAME
+fi
+VBOXUSB_MODE=0664
+VBOXUSB_GRP=$GROUPNAME
+
+## Were we able to stop any previously running Additions kernel modules?
+MODULES_STOPPED=1
+
+
+##############################################################################
+# Helper routines #
+##############################################################################
+
+usage() {
+ info ""
+ info "Usage: install | uninstall"
+ info ""
+ info "Example:"
+ info "$SELF install"
+ exit 1
+}
+
+module_loaded() {
+ lsmod | grep -q "vboxdrv[^_-]"
+}
+
+# This routine makes sure that there is no previous installation of
+# VirtualBox other than one installed using this install script or a
+# compatible method. We do this by checking for any of the VirtualBox
+# applications in /usr/bin. If these exist and are not symlinks into
+# the installation directory, then we assume that they are from an
+# incompatible previous installation.
+
+## Helper routine: test for a particular VirtualBox binary and see if it
+## is a link into a previous installation directory
+##
+## Arguments: 1) the binary to search for and
+## 2) the installation directory (if any)
+## Returns: false if an incompatible version was detected, true otherwise
+check_binary() {
+ binary=$1
+ install_dir=$2
+ test ! -e $binary 2>&1 > /dev/null ||
+ ( test -n "$install_dir" &&
+ readlink $binary 2>/dev/null | grep "$install_dir" > /dev/null
+ )
+}
+
+## Main routine
+##
+## Argument: the directory where the previous installation should be
+## located. If this is empty, then we will assume that any
+## installation of VirtualBox found is incompatible with this one.
+## Returns: false if an incompatible installation was found, true otherwise
+check_previous() {
+ install_dir=$1
+ # These should all be symlinks into the installation folder
+ check_binary "/usr/bin/VirtualBox" "$install_dir" &&
+ check_binary "/usr/bin/VBoxManage" "$install_dir" &&
+ check_binary "/usr/bin/VBoxSDL" "$install_dir" &&
+ check_binary "/usr/bin/VBoxVRDP" "$install_dir" &&
+ check_binary "/usr/bin/VBoxHeadless" "$install_dir" &&
+ check_binary "/usr/bin/VBoxDTrace" "$install_dir" &&
+ check_binary "/usr/bin/VBoxBugReport" "$install_dir" &&
+ check_binary "/usr/bin/VBoxBalloonCtrl" "$install_dir" &&
+ check_binary "/usr/bin/VBoxAutostart" "$install_dir" &&
+ check_binary "/usr/bin/vboxwebsrv" "$install_dir" &&
+ check_binary "/usr/bin/vbox-img" "$install_dir" &&
+ check_binary "/usr/bin/vboximg-mount" "$install_dir" &&
+ check_binary "/sbin/rcvboxdrv" "$install_dir"
+}
+
+##############################################################################
+# Main script #
+##############################################################################
+
+info "VirtualBox Version $VERSION r$SVNREV ($BUILD) installer"
+
+
+# Make sure that we were invoked as root...
+check_root
+
+# Set up logging before anything else
+create_log $LOG
+
+log "VirtualBox $VERSION r$SVNREV installer, built $BUILD."
+log ""
+log "Testing system setup..."
+
+# Sanity check: figure out whether build arch matches uname arch
+cpu=`uname -m`;
+case "$cpu" in
+ i[3456789]86|x86)
+ cpu="x86"
+ ;;
+ x86_64)
+ cpu="amd64"
+ ;;
+esac
+if [ "$cpu" != "$ARCH" ]; then
+ info "Detected unsupported $cpu environment."
+ log "Detected unsupported $cpu environment."
+ exit 1
+fi
+
+# Sensible default actions
+ACTION="install"
+BUILD_MODULE="true"
+unset FORCE_UPGRADE
+while true
+do
+ if [ "$2" = "" ]; then
+ break
+ fi
+ shift
+ case "$1" in
+ install|--install)
+ ACTION="install"
+ ;;
+
+ uninstall|--uninstall)
+ ACTION="uninstall"
+ ;;
+
+ force|--force)
+ FORCE_UPGRADE=1
+ ;;
+ license_accepted_unconditionally|--license_accepted_unconditionally)
+ # Legacy option
+ ;;
+ no_module|--no_module)
+ BUILD_MODULE=""
+ ;;
+ *)
+ if [ "$ACTION" = "" ]; then
+ info "Unknown command '$1'."
+ usage
+ fi
+ info "Specifying an installation path is not allowed -- using _INSTALLATION_DIR_!"
+ ;;
+ esac
+done
+
+if [ "$ACTION" = "install" ]; then
+ # Choose a proper umask
+ umask 022
+
+ # Find previous installation
+ if test -r "$CONFIG_DIR/$CONFIG"; then
+ . $CONFIG_DIR/$CONFIG
+ PREV_INSTALLATION=$INSTALL_DIR
+ fi
+ if ! check_previous $INSTALL_DIR && test -z "$FORCE_UPGRADE"
+ then
+ info
+ info "You appear to have a version of VirtualBox on your system which was installed"
+ info "from a different source or using a different type of installer (or a damaged"
+ info "installation of VirtualBox). We strongly recommend that you remove it before"
+ info "installing this version of VirtualBox."
+ info
+ info "Do you wish to continue anyway? [yes or no]"
+ read reply dummy
+ if ! expr "$reply" : [yY] && ! expr "$reply" : [yY][eE][sS]
+ then
+ info
+ info "Cancelling installation."
+ log "User requested cancellation of the installation"
+ exit 1
+ fi
+ fi
+
+ # Do additional clean-up in case some-one is running from a build folder.
+ ./prerm-common.sh || exit 1
+
+ # Remove previous installation
+ test "${BUILD_MODULE}" = true || VBOX_DONT_REMOVE_OLD_MODULES=1
+
+ if [ -n "$PREV_INSTALLATION" ]; then
+ [ -n "$INSTALL_REV" ] && INSTALL_REV=" r$INSTALL_REV"
+ info "Removing previous installation of VirtualBox $INSTALL_VER$INSTALL_REV from $PREV_INSTALLATION"
+ log "Removing previous installation of VirtualBox $INSTALL_VER$INSTALL_REV from $PREV_INSTALLATION"
+ log ""
+
+ VBOX_NO_UNINSTALL_MESSAGE=1
+ # This also checks $BUILD_MODULE and $VBOX_DONT_REMOVE_OLD_MODULES
+ . ./uninstall.sh
+ fi
+
+ mkdir -p -m 755 $CONFIG_DIR
+ touch $CONFIG_DIR/$CONFIG
+
+ info "Installing VirtualBox to $INSTALLATION_DIR"
+ log "Installing VirtualBox to $INSTALLATION_DIR"
+ log ""
+
+ # Verify the archive
+ mkdir -p -m 755 $INSTALLATION_DIR
+ bzip2 -d -c VirtualBox.tar.bz2 > VirtualBox.tar
+ if ! tar -tf VirtualBox.tar > $CONFIG_DIR/$CONFIG_FILES; then
+ rmdir $INSTALLATION_DIR 2> /dev/null
+ rm -f $CONFIG_DIR/$CONFIG 2> /dev/null
+ rm -f $CONFIG_DIR/$CONFIG_FILES 2> /dev/null
+ log 'Error running "bzip2 -d -c VirtualBox.tar.bz2" or "tar -tf VirtualBox.tar".'
+ abort "Error installing VirtualBox. Installation aborted"
+ fi
+
+ # Create installation directory and install
+ if ! tar -xf VirtualBox.tar -C $INSTALLATION_DIR; then
+ cwd=`pwd`
+ cd $INSTALLATION_DIR
+ rm -f `cat $CONFIG_DIR/$CONFIG_FILES` 2> /dev/null
+ cd $pwd
+ rmdir $INSTALLATION_DIR 2> /dev/null
+ rm -f $CONFIG_DIR/$CONFIG 2> /dev/null
+ log 'Error running "tar -xf VirtualBox.tar -C '"$INSTALLATION_DIR"'".'
+ abort "Error installing VirtualBox. Installation aborted"
+ fi
+
+ cp uninstall.sh $INSTALLATION_DIR
+ echo "uninstall.sh" >> $CONFIG_DIR/$CONFIG_FILES
+
+ # Hardened build: Mark selected binaries set-user-ID-on-execution,
+ # create symlinks for working around unsupported $ORIGIN/.. in VBoxC.so (setuid),
+ # and finally make sure the directory is only writable by the user (paranoid).
+ if [ -n "$HARDENED" ]; then
+ if [ -f $INSTALLATION_DIR/VirtualBoxVM ]; then
+ test -e $INSTALLATION_DIR/VirtualBoxVM && chmod 4511 $INSTALLATION_DIR/VirtualBoxVM
+ else
+ test -e $INSTALLATION_DIR/VirtualBox && chmod 4511 $INSTALLATION_DIR/VirtualBox
+ fi
+ test -e $INSTALLATION_DIR/VBoxSDL && chmod 4511 $INSTALLATION_DIR/VBoxSDL
+ test -e $INSTALLATION_DIR/VBoxHeadless && chmod 4511 $INSTALLATION_DIR/VBoxHeadless
+ test -e $INSTALLATION_DIR/VBoxNetDHCP && chmod 4511 $INSTALLATION_DIR/VBoxNetDHCP
+ test -e $INSTALLATION_DIR/VBoxNetNAT && chmod 4511 $INSTALLATION_DIR/VBoxNetNAT
+
+ ln -sf $INSTALLATION_DIR/VBoxVMM.so $INSTALLATION_DIR/components/VBoxVMM.so
+ ln -sf $INSTALLATION_DIR/VBoxRT.so $INSTALLATION_DIR/components/VBoxRT.so
+
+ chmod go-w $INSTALLATION_DIR
+ fi
+
+ # This binaries need to be suid root in any case, even if not hardened
+ test -e $INSTALLATION_DIR/VBoxNetAdpCtl && chmod 4511 $INSTALLATION_DIR/VBoxNetAdpCtl
+ test -e $INSTALLATION_DIR/VBoxVolInfo && chmod 4511 $INSTALLATION_DIR/VBoxVolInfo
+
+ # Write the configuration. Needs to be done before the vboxdrv service is
+ # started.
+ echo "# VirtualBox installation directory" > $CONFIG_DIR/$CONFIG
+ echo "INSTALL_DIR='$INSTALLATION_DIR'" >> $CONFIG_DIR/$CONFIG
+ echo "# VirtualBox version" >> $CONFIG_DIR/$CONFIG
+ echo "INSTALL_VER='$VERSION'" >> $CONFIG_DIR/$CONFIG
+ echo "INSTALL_REV='$SVNREV'" >> $CONFIG_DIR/$CONFIG
+ echo "# Build type and user name for logging purposes" >> $CONFIG_DIR/$CONFIG
+ echo "VBOX_KBUILD_TYPE='$BUILD_VBOX_KBUILD_TYPE'" >> $CONFIG_DIR/$CONFIG
+ echo "USERNAME='$BUILD_USERNAME'" >> $CONFIG_DIR/$CONFIG
+
+ # Create users group
+ groupadd -r -f $GROUPNAME 2> /dev/null
+
+ # Create symlinks to start binaries
+ ln -sf $INSTALLATION_DIR/VBox.sh /usr/bin/VirtualBox
+ if [ -f $INSTALLATION_DIR/VirtualBoxVM ]; then
+ ln -sf $INSTALLATION_DIR/VBox.sh /usr/bin/VirtualBoxVM
+ fi
+ ln -sf $INSTALLATION_DIR/VBox.sh /usr/bin/VBoxManage
+ ln -sf $INSTALLATION_DIR/VBox.sh /usr/bin/VBoxSDL
+ ln -sf $INSTALLATION_DIR/VBox.sh /usr/bin/VBoxVRDP
+ ln -sf $INSTALLATION_DIR/VBox.sh /usr/bin/VBoxHeadless
+ ln -sf $INSTALLATION_DIR/VBox.sh /usr/bin/VBoxBalloonCtrl
+ ln -sf $INSTALLATION_DIR/VBox.sh /usr/bin/VBoxBugReport
+ ln -sf $INSTALLATION_DIR/VBox.sh /usr/bin/VBoxAutostart
+ ln -sf $INSTALLATION_DIR/VBox.sh /usr/bin/vboxwebsrv
+ ln -sf $INSTALLATION_DIR/vbox-img /usr/bin/vbox-img
+ ln -sf $INSTALLATION_DIR/vboximg-mount /usr/bin/vboximg-mount
+ if [ -d /usr/share/pixmaps/ ]; then
+ ln -sf $INSTALLATION_DIR/VBox.png /usr/share/pixmaps/VBox.png
+ fi
+ if [ -f $INSTALLATION_DIR/VBoxDTrace ]; then
+ ln -sf $INSTALLATION_DIR/VBox.sh /usr/bin/VBoxDTrace
+ fi
+ if [ -f $INSTALLATION_DIR/VBoxAudioTest ]; then
+ ln -sf $INSTALLATION_DIR/VBox.sh /usr/bin/VBoxAudioTest
+ fi
+ # Unity and Nautilus seem to look here for their icons
+ if [ -d /usr/share/pixmaps/ ]; then
+ ln -sf $INSTALLATION_DIR/icons/128x128/virtualbox.png /usr/share/pixmaps/virtualbox.png
+ fi
+ if [ -d /usr/share/applications/ ]; then
+ ln -sf $INSTALLATION_DIR/virtualbox.desktop /usr/share/applications/virtualbox.desktop
+ ln -sf $INSTALLATION_DIR/virtualboxvm.desktop /usr/share/applications/virtualboxvm.desktop
+ fi
+ if [ -d /usr/share/mime/packages/ ]; then
+ ln -sf $INSTALLATION_DIR/virtualbox.xml /usr/share/mime/packages/virtualbox.xml
+ fi
+ ln -sf $INSTALLATION_DIR/src/vboxhost /usr/src/vboxhost-_VERSION_
+
+ # Convenience symlinks. The creation fails if the FS is not case sensitive
+ ln -sf VirtualBox /usr/bin/virtualbox > /dev/null 2>&1
+ if [ -f $INSTALLATION_DIR/VirtualBoxVM ]; then
+ ln -sf VirtualBoxVM /usr/bin/virtualboxvm > /dev/null 2>&1
+ fi
+ ln -sf VBoxManage /usr/bin/vboxmanage > /dev/null 2>&1
+ ln -sf VBoxSDL /usr/bin/vboxsdl > /dev/null 2>&1
+ ln -sf VBoxHeadless /usr/bin/vboxheadless > /dev/null 2>&1
+ ln -sf VBoxBugReport /usr/bin/vboxbugreport > /dev/null 2>&1
+ if [ -f $INSTALLATION_DIR/VBoxDTrace ]; then
+ ln -sf VBoxDTrace /usr/bin/vboxdtrace > /dev/null 2>&1
+ fi
+ if [ -f $INSTALLATION_DIR/VBoxAudioTest ]; then
+ ln -sf VBoxAudioTest /usr/bin/vboxaudiotest > /dev/null 2>&1
+ fi
+
+ # Icons
+ cur=`pwd`
+ cd $INSTALLATION_DIR/icons
+ for i in *; do
+ cd $i
+ if [ -d /usr/share/icons/hicolor/$i ]; then
+ for j in *; do
+ if expr "$j" : "virtualbox\..*" > /dev/null; then
+ dst=apps
+ else
+ dst=mimetypes
+ fi
+ if [ -d /usr/share/icons/hicolor/$i/$dst ]; then
+ ln -s $INSTALLATION_DIR/icons/$i/$j /usr/share/icons/hicolor/$i/$dst/$j
+ echo /usr/share/icons/hicolor/$i/$dst/$j >> $CONFIG_DIR/$CONFIG_FILES
+ fi
+ done
+ fi
+ cd -
+ done
+ cd $cur
+
+ # Update the MIME database
+ update-mime-database /usr/share/mime 2>/dev/null
+
+ # Update the desktop database
+ update-desktop-database -q 2>/dev/null
+
+ # If Python is available, install Python bindings
+ if [ -n "$PYTHON" ]; then
+ maybe_run_python_bindings_installer $INSTALLATION_DIR $CONFIG_DIR $CONFIG_FILES
+ fi
+
+ # Do post-installation common to all installer types, currently service
+ # script set-up.
+ if test "${BUILD_MODULE}" = "true"; then
+ START_SERVICES=
+ else
+ START_SERVICES="--nostart"
+ fi
+ "${INSTALLATION_DIR}/prerm-common.sh" >> "${LOG}"
+
+ # Now check whether the kernel modules were stopped.
+ lsmod | grep -q vboxdrv && MODULES_STOPPED=
+
+ "${INSTALLATION_DIR}/postinst-common.sh" ${START_SERVICES} >> "${LOG}"
+
+ info ""
+ info "VirtualBox has been installed successfully."
+ info ""
+ info "You will find useful information about using VirtualBox in the user manual"
+ info " $INSTALLATION_DIR/UserManual.pdf"
+ info "and in the user FAQ"
+ info " http://www.virtualbox.org/wiki/User_FAQ"
+ info ""
+ info "We hope that you enjoy using VirtualBox."
+ info ""
+
+ # And do a final test as to whether the kernel modules were properly created
+ # and loaded. Return 0 if both are true, 1 if not.
+ test -n "${MODULES_STOPPED}" &&
+ modinfo vboxdrv >/dev/null 2>&1 &&
+ lsmod | grep -q vboxdrv ||
+ abort "The installation log file is at ${LOG}."
+
+ log "Installation successful"
+elif [ "$ACTION" = "uninstall" ]; then
+ . ./uninstall.sh
+fi
+exit $RC_SCRIPT
diff --git a/src/VBox/Installer/linux/postinst-common.sh b/src/VBox/Installer/linux/postinst-common.sh
new file mode 100755
index 00000000..37e1a710
--- /dev/null
+++ b/src/VBox/Installer/linux/postinst-common.sh
@@ -0,0 +1,125 @@
+#!/bin/sh
+# $Id: postinst-common.sh $
+## @file
+# Oracle VM VirtualBox
+# VirtualBox Linux post-installer common portions
+#
+
+#
+# Copyright (C) 2015-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+# Put bits of the post-installation here which should work the same for all of
+# the Linux installers. We do not use special helpers (e.g. dh_* on Debian),
+# but that should not matter, as we know what those helpers actually do, and we
+# have to work on those systems anyway when installed using the all
+# distributions installer.
+#
+# We assume that all required files are in the same folder as this script
+# (e.g. /opt/VirtualBox, /usr/lib/VirtualBox, the build output directory).
+
+# The below is GNU-specific. See VBox.sh for the longer Solaris/OS X version.
+TARGET=`readlink -e -- "${0}"` || exit 1
+MY_PATH="${TARGET%/[!/]*}"
+cd "${MY_PATH}"
+. "./routines.sh"
+
+START=true
+while test -n "${1}"; do
+ case "${1}" in
+ --nostart)
+ START=
+ ;;
+ *)
+ echo "Bad argument ${1}" >&2
+ exit 1
+ ;;
+ esac
+ shift
+done
+
+# Remove any traces of DKMS from previous installations.
+for i in vboxhost vboxdrv vboxnetflt vboxnetadp; do
+ rm -rf "/var/lib/dkms/${i}"*
+done
+
+# Install runlevel scripts and systemd unit files
+install_init_script "${MY_PATH}/vboxdrv.sh" vboxdrv
+install_init_script "${MY_PATH}/vboxballoonctrl-service.sh" vboxballoonctrl-service
+install_init_script "${MY_PATH}/vboxautostart-service.sh" vboxautostart-service
+install_init_script "${MY_PATH}/vboxweb-service.sh" vboxweb-service
+finish_init_script_install
+
+delrunlevel vboxdrv
+addrunlevel vboxdrv
+delrunlevel vboxballoonctrl-service
+addrunlevel vboxballoonctrl-service
+delrunlevel vboxautostart-service
+addrunlevel vboxautostart-service
+delrunlevel vboxweb-service
+addrunlevel vboxweb-service
+
+ln -sf "${MY_PATH}/postinst-common.sh" /sbin/vboxconfig
+
+# Set SELinux permissions
+# XXX SELinux: allow text relocation entries
+if [ -x /usr/bin/chcon ]; then
+ chcon -t texrel_shlib_t "${MY_PATH}"/*VBox* > /dev/null 2>&1
+ chcon -t texrel_shlib_t "${MY_PATH}"/VBoxAuth.so \
+ > /dev/null 2>&1
+ chcon -t texrel_shlib_t "${MY_PATH}"/VirtualBox.so \
+ > /dev/null 2>&1
+ chcon -t texrel_shlib_t "${MY_PATH}"/components/VBox*.so \
+ > /dev/null 2>&1
+ chcon -t java_exec_t "${MY_PATH}"/VirtualBox > /dev/null 2>&1
+ chcon -t java_exec_t "${MY_PATH}"/VBoxSDL > /dev/null 2>&1
+ chcon -t java_exec_t "${MY_PATH}"/VBoxHeadless \
+ > /dev/null 2>&1
+ chcon -t java_exec_t "${MY_PATH}"/VBoxNetDHCP \
+ > /dev/null 2>&1
+ chcon -t java_exec_t "${MY_PATH}"/VBoxNetNAT \
+ > /dev/null 2>&1
+ chcon -t java_exec_t "${MY_PATH}"/VBoxExtPackHelperApp \
+ > /dev/null 2>&1
+ chcon -t java_exec_t "${MY_PATH}"/vboxwebsrv > /dev/null 2>&1
+ chcon -t bin_t "${MY_PATH}"/src/vboxhost/build_in_tmp \
+ > /dev/null 2>&1
+ chcon -t bin_t /usr/share/virtualbox/src/vboxhost/build_in_tmp \
+ > /dev/null 2>&1
+fi
+
+test -n "${START}" &&
+{
+ if ! "${MY_PATH}/vboxdrv.sh" setup; then
+ "${MY_PATH}/check_module_dependencies.sh" >&2
+ echo >&2
+ echo "There were problems setting up VirtualBox. To re-start the set-up process, run" >&2
+ echo " /sbin/vboxconfig" >&2
+ echo "as root. If your system is using EFI Secure Boot you may need to sign the" >&2
+ echo "kernel modules (vboxdrv, vboxnetflt, vboxnetadp, vboxpci) before you can load" >&2
+ echo "them. Please see your Linux system's documentation for more information." >&2
+ else
+ start_init_script vboxdrv
+ start_init_script vboxballoonctrl-service
+ start_init_script vboxautostart-service
+ start_init_script vboxweb-service
+ fi
+}
diff --git a/src/VBox/Installer/linux/prerm-common.sh b/src/VBox/Installer/linux/prerm-common.sh
new file mode 100755
index 00000000..b326c262
--- /dev/null
+++ b/src/VBox/Installer/linux/prerm-common.sh
@@ -0,0 +1,81 @@
+#!/bin/sh
+# $Id: prerm-common.sh $
+## @file
+# Oracle VM VirtualBox
+# VirtualBox Linux pre-uninstaller common portions
+#
+
+#
+# Copyright (C) 2015-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+# Put bits of the pre-uninstallation here which should work the same for all of
+# the Linux installers. We do not use special helpers (e.g. dh_* on Debian),
+# but that should not matter, as we know what those helpers actually do, and we
+# have to work on those systems anyway when installed using the all
+# distributions installer.
+#
+# We assume that all required files are in the same folder as this script
+# (e.g. /opt/VirtualBox, /usr/lib/VirtualBox, the build output directory).
+#
+# Script exit status: 0 on success, 1 if VirtualBox is running and can not be
+# stopped (installers may show an error themselves or just pass on standard
+# error).
+
+
+# The below is GNU-specific. See VBox.sh for the longer Solaris/OS X version.
+TARGET=`readlink -e -- "${0}"` || exit 1
+MY_PATH="${TARGET%/[!/]*}"
+cd "${MY_PATH}"
+. "./routines.sh"
+
+# Stop the ballon control service
+stop_init_script vboxballoonctrl-service >/dev/null 2>&1
+# Stop the autostart service
+stop_init_script vboxautostart-service >/dev/null 2>&1
+# Stop the web service
+stop_init_script vboxweb-service >/dev/null 2>&1
+# Do this check here after we terminated the web service: check whether VBoxSVC
+# is running and exit if it can't be stopped.
+check_running
+# Terminate VBoxNetDHCP if running
+terminate_proc VBoxNetDHCP
+# Terminate VBoxNetNAT if running
+terminate_proc VBoxNetNAT
+delrunlevel vboxballoonctrl-service
+remove_init_script vboxballoonctrl-service
+delrunlevel vboxautostart-service
+remove_init_script vboxautostart-service
+delrunlevel vboxweb-service
+remove_init_script vboxweb-service
+# Stop kernel module and uninstall runlevel script
+stop_init_script vboxdrv >/dev/null 2>&1
+delrunlevel vboxdrv
+remove_init_script vboxdrv
+# And do final clean-up
+"${MY_PATH}/vboxdrv.sh" cleanup >/dev/null # Do not silence errors for now
+# Stop host networking and uninstall runlevel script (obsolete)
+stop_init_script vboxnet >/dev/null 2>&1
+delrunlevel vboxnet >/dev/null 2>&1
+remove_init_script vboxnet >/dev/null 2>&1
+finish_init_script_install
+rm -f /sbin/vboxconfig
+exit 0
diff --git a/src/VBox/Installer/linux/routines.sh b/src/VBox/Installer/linux/routines.sh
new file mode 100644
index 00000000..7638ee66
--- /dev/null
+++ b/src/VBox/Installer/linux/routines.sh
@@ -0,0 +1,471 @@
+# $Id: routines.sh $
+# Oracle VM VirtualBox
+# VirtualBox installer shell routines
+#
+
+#
+# Copyright (C) 2007-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+ro_LOG_FILE=""
+ro_X11_AUTOSTART="/etc/xdg/autostart"
+ro_KDE_AUTOSTART="/usr/share/autostart"
+
+## Aborts the script and prints an error message to stderr.
+#
+# syntax: abort message
+
+abort()
+{
+ echo 1>&2 "$1"
+ exit 1
+}
+
+## Creates an empty log file and remembers the name for future logging
+# operations
+create_log()
+{
+ ## The path of the file to create.
+ ro_LOG_FILE="$1"
+ if [ "$ro_LOG_FILE" = "" ]; then
+ abort "create_log called without an argument! Aborting..."
+ fi
+ # Create an empty file
+ echo > "$ro_LOG_FILE" 2> /dev/null
+ if [ ! -f "$ro_LOG_FILE" -o "`cat "$ro_LOG_FILE"`" != "" ]; then
+ abort "Error creating log file! Aborting..."
+ fi
+}
+
+## Writes text to standard error, as standard output is masked.
+#
+# Syntax: info text
+info()
+{
+ echo 1>&2 "$1"
+}
+
+## Copies standard input to standard error, as standard output is masked.
+#
+# Syntax: info text
+catinfo()
+{
+ cat 1>&2
+}
+
+## Writes text to the log file
+#
+# Syntax: log text
+log()
+{
+ if [ "$ro_LOG_FILE" = "" ]; then
+ abort "Error! Logging has not been set up yet! Aborting..."
+ fi
+ echo "$1" >> $ro_LOG_FILE
+ return 0
+}
+
+## Writes test to standard output and to the log file
+#
+# Syntax: infolog text
+infolog()
+{
+ info "$1"
+ log "$1"
+}
+
+## Checks whether a module is loaded with a given string in its name.
+#
+# syntax: module_loaded string
+module_loaded()
+{
+ if [ "$1" = "" ]; then
+ log "module_loaded called without an argument. Aborting..."
+ abort "Error in installer. Aborting..."
+ fi
+ lsmod | grep -q $1
+}
+
+## Abort if we are not running as root
+check_root()
+{
+ if [ `id -u` -ne 0 ]; then
+ abort "This program must be run with administrator privileges. Aborting"
+ fi
+}
+
+## Abort if dependencies are not found
+check_deps()
+{
+ for i in ${@}; do
+ type "${i}" >/dev/null 2>&1 ||
+ abort "${i} not found. Please install: ${*}; and try again."
+ done
+}
+
+## Abort if a copy of VirtualBox is already running
+check_running()
+{
+ VBOXSVC_PID=`pidof VBoxSVC 2> /dev/null`
+ if [ -n "$VBOXSVC_PID" ]; then
+ if [ -f /etc/init.d/vboxweb-service ]; then
+ kill -USR1 $VBOXSVC_PID
+ fi
+ sleep 1
+ if pidof VBoxSVC > /dev/null 2>&1; then
+ echo 1>&2 "A copy of VirtualBox is currently running. Please close it and try again."
+ abort "Please note that it can take up to ten seconds for VirtualBox to finish running."
+ fi
+ fi
+}
+
+## Creates a systemd wrapper in /lib for an LSB init script
+systemd_wrap_init_script()
+{
+ self="systemd_wrap_init_script"
+ ## The init script to be installed. The file may be copied or referenced.
+ script="$(readlink -f -- "${1}")"
+ ## Name for the service.
+ name="$2"
+ test -x "$script" && test ! "$name" = "" || \
+ { echo "$self: invalid arguments" >&2 && return 1; }
+ test -d /usr/lib/systemd/system && unit_path=/usr/lib/systemd/system
+ test -d /lib/systemd/system && unit_path=/lib/systemd/system
+ test -n "${unit_path}" || \
+ { echo "$self: systemd unit path not found" >&2 && return 1; }
+ conflicts=`sed -n 's/# *X-Conflicts-With: *\(.*\)/\1/p' "${script}" | sed 's/\$[a-z]*//'`
+ description=`sed -n 's/# *Short-Description: *\(.*\)/\1/p' "${script}"`
+ required=`sed -n 's/# *Required-Start: *\(.*\)/\1/p' "${script}" | sed 's/\$[a-z]*//'`
+ required_target=`sed -n 's/# *X-Required-Target-Start: *\(.*\)/\1/p' "${script}"`
+ startbefore=`sed -n 's/# *X-Start-Before: *\(.*\)/\1/p' "${script}" | sed 's/\$[a-z]*//'`
+ runlevels=`sed -n 's/# *Default-Start: *\(.*\)/\1/p' "${script}"`
+ servicetype=`sed -n 's/# *X-Service-Type: *\(.*\)/\1/p' "${script}"`
+ test -z "${servicetype}" && servicetype="forking"
+ targets=`for i in ${runlevels}; do printf "runlevel${i}.target "; done`
+ before=`for i in ${startbefore}; do printf "${i}.service "; done`
+ after=`for i in ${required_target}; do printf "${i}.target "; done; for i in ${required}; do printf "${i}.service "; done`
+ cat > "${unit_path}/${name}.service" << EOF
+[Unit]
+SourcePath=${script}
+Description=${description}
+Before=${targets}shutdown.target ${before}
+After=${after}
+Conflicts=shutdown.target ${conflicts}
+
+[Service]
+Type=${servicetype}
+Restart=no
+TimeoutSec=5min
+IgnoreSIGPIPE=no
+KillMode=process
+GuessMainPID=no
+RemainAfterExit=yes
+ExecStart=${script} start
+ExecStop=${script} stop
+
+[Install]
+WantedBy=multi-user.target
+EOF
+}
+
+# Checks if systemctl is present and functional (i.e., systemd is the init process).
+use_systemd()
+{
+ systemctl status >/dev/null 2>&1
+}
+
+## Installs a file containing a shell script as an init script. Call
+# finish_init_script_install when all scripts have been installed.
+install_init_script()
+{
+ self="install_init_script"
+ ## The init script to be installed. The file may be copied or referenced.
+ script="$1"
+ ## Name for the service.
+ name="$2"
+
+ test -x "${script}" && test ! "${name}" = "" ||
+ { echo "${self}: invalid arguments" >&2; return 1; }
+ # Do not unconditionally silence the following "ln".
+ test -L "/sbin/rc${name}" && rm "/sbin/rc${name}"
+ ln -s "${script}" "/sbin/rc${name}"
+ if test -x "`which systemctl 2>/dev/null`"; then
+ if use_systemd; then
+ { systemd_wrap_init_script "$script" "$name"; return; }
+ fi
+ fi
+ if test -d /etc/rc.d/init.d; then
+ cp "${script}" "/etc/rc.d/init.d/${name}" &&
+ chmod 755 "/etc/rc.d/init.d/${name}"
+ elif test -d /etc/init.d; then
+ cp "${script}" "/etc/init.d/${name}" &&
+ chmod 755 "/etc/init.d/${name}"
+ else
+ { echo "${self}: error: unknown init type" >&2; return 1; }
+ fi
+}
+
+## Remove the init script "name"
+remove_init_script()
+{
+ self="remove_init_script"
+ ## Name of the service to remove.
+ name="$1"
+
+ test -n "${name}" ||
+ { echo "$self: missing argument"; return 1; }
+ rm -f "/sbin/rc${name}"
+ rm -f /lib/systemd/system/"$name".service /usr/lib/systemd/system/"$name".service
+ rm -f "/etc/rc.d/init.d/$name"
+ rm -f "/etc/init.d/$name"
+}
+
+## Tell systemd services have been installed or removed. Should not be done
+# after each individual one, as systemd can crash if it is done too often
+# (reported by the OL team for OL 7.6, may not apply to other versions.)
+finish_init_script_install()
+{
+ if use_systemd; then
+ systemctl daemon-reload
+ fi
+}
+
+## Did we install a systemd service?
+systemd_service_installed()
+{
+ ## Name of service to test.
+ name="${1}"
+
+ test -f /lib/systemd/system/"${name}".service ||
+ test -f /usr/lib/systemd/system/"${name}".service
+}
+
+## Perform an action on a service
+do_sysvinit_action()
+{
+ self="do_sysvinit_action"
+ ## Name of service to start.
+ name="${1}"
+ ## The action to perform, normally "start", "stop" or "status".
+ action="${2}"
+
+ test ! -z "${name}" && test ! -z "${action}" ||
+ { echo "${self}: missing argument" >&2; return 1; }
+ if systemd_service_installed "${name}"; then
+ systemctl -q ${action} "${name}"
+ elif test -x "/etc/rc.d/init.d/${name}"; then
+ "/etc/rc.d/init.d/${name}" "${action}" quiet
+ elif test -x "/etc/init.d/${name}"; then
+ "/etc/init.d/${name}" "${action}" quiet
+ fi
+}
+
+## Start a service
+start_init_script()
+{
+ do_sysvinit_action "${1}" start
+}
+
+## Stop the init script "name"
+stop_init_script()
+{
+ do_sysvinit_action "${1}" stop
+}
+
+## Extract chkconfig information from a sysvinit script.
+get_chkconfig_info()
+{
+ ## The script to extract the information from.
+ script="${1}"
+
+ set `sed -n 's/# *chkconfig: *\([0-9]*\) *\(.*\)/\1 \2/p' "${script}"`
+ ## Which runlevels should we start in?
+ runlevels="${1}"
+ ## How soon in the boot process will we start, from 00 (first) to 99
+ start_order="${2}"
+ ## How soon in the shutdown process will we stop, from 99 (first) to 00
+ stop_order="${3}"
+ test ! -z "${name}" || \
+ { echo "${self}: missing name" >&2; return 1; }
+ expr "${start_order}" + 0 > /dev/null 2>&1 && \
+ expr 0 \<= "${start_order}" > /dev/null 2>&1 && \
+ test `expr length "${start_order}"` -eq 2 > /dev/null 2>&1 || \
+ { echo "${self}: start sequence number must be between 00 and 99" >&2;
+ return 1; }
+ expr "${stop_order}" + 0 > /dev/null 2>&1 && \
+ expr 0 \<= "${stop_order}" > /dev/null 2>&1 && \
+ test `expr length "${stop_order}"` -eq 2 > /dev/null 2>&1 || \
+ { echo "${self}: stop sequence number must be between 00 and 99" >&2;
+ return 1; }
+}
+
+## Add a service to its default runlevels (annotated inside the script, see get_chkconfig_info).
+addrunlevel()
+{
+ self="addrunlevel"
+ ## Service name.
+ name="${1}"
+
+ test -n "${name}" || \
+ { echo "${self}: missing argument" >&2; return 1; }
+ systemd_service_installed "${name}" && \
+ { systemctl -q enable "${name}"; return; }
+ if test -x "/etc/rc.d/init.d/${name}"; then
+ init_d_path=/etc/rc.d
+ elif test -x "/etc/init.d/${name}"; then
+ init_d_path=/etc
+ else
+ { echo "${self}: error: unknown init type" >&2; return 1; }
+ fi
+ get_chkconfig_info "${init_d_path}/init.d/${name}" || return 1
+ # Redhat based sysvinit systems
+ if test -x "`which chkconfig 2>/dev/null`"; then
+ chkconfig --add "${name}"
+ # SUSE-based sysvinit systems
+ elif test -x "`which insserv 2>/dev/null`"; then
+ insserv "${name}"
+ # Debian/Ubuntu-based systems
+ elif test -x "`which update-rc.d 2>/dev/null`"; then
+ # Old Debians did not support dependencies
+ update-rc.d "${name}" defaults "${start_order}" "${stop_order}"
+ # Gentoo Linux
+ elif test -x "`which rc-update 2>/dev/null`"; then
+ rc-update add "${name}" default
+ # Generic sysvinit
+ elif test -n "${init_d_path}/rc0.d"
+ then
+ for locali in 0 1 2 3 4 5 6
+ do
+ target="${init_d_path}/rc${locali}.d/K${stop_order}${name}"
+ expr "${runlevels}" : ".*${locali}" >/dev/null && \
+ target="${init_d_path}/rc${locali}.d/S${start_order}${name}"
+ test -e "${init_d_path}/rc${locali}.d/"[KS][0-9]*"${name}" || \
+ ln -fs "${init_d_path}/init.d/${name}" "${target}"
+ done
+ else
+ { echo "${self}: error: unknown init type" >&2; return 1; }
+ fi
+}
+
+
+## Delete a service from a runlevel
+delrunlevel()
+{
+ self="delrunlevel"
+ ## Service name.
+ name="${1}"
+
+ test -n "${name}" ||
+ { echo "${self}: missing argument" >&2; return 1; }
+ systemctl -q disable "${name}" >/dev/null 2>&1
+ # Redhat-based systems
+ chkconfig --del "${name}" >/dev/null 2>&1
+ # SUSE-based sysvinit systems
+ insserv -r "${name}" >/dev/null 2>&1
+ # Debian/Ubuntu-based systems
+ update-rc.d -f "${name}" remove >/dev/null 2>&1
+ # Gentoo Linux
+ rc-update del "${name}" >/dev/null 2>&1
+ # Generic sysvinit
+ rm -f /etc/rc.d/rc?.d/[SK]??"${name}"
+ rm -f /etc/rc?.d/[SK]??"${name}"
+}
+
+
+terminate_proc() {
+ PROC_NAME="${1}"
+ SERVER_PID=`pidof $PROC_NAME 2> /dev/null`
+ if [ "$SERVER_PID" != "" ]; then
+ killall -TERM $PROC_NAME > /dev/null 2>&1
+ sleep 2
+ fi
+}
+
+
+# install_python_bindings(pythonbin pythondesc)
+# failure: non fatal
+install_python_bindings()
+{
+ pythonbin="$1"
+ pythondesc="$2"
+
+ # The python binary might not be there, so just exit silently
+ if test -z "$pythonbin"; then
+ return 0
+ fi
+
+ if test -z "$pythondesc"; then
+ echo 1>&2 "missing argument to install_python_bindings"
+ return 1
+ fi
+
+ echo 1>&2 "Python found: $pythonbin, installing bindings..."
+
+ # check if python has working distutils
+ "$pythonbin" -c "from distutils.core import setup" > /dev/null 2>&1
+ if test "$?" -ne 0; then
+ echo 1>&2 "Skipped: $pythondesc install is unusable, missing package 'distutils'"
+ return 0
+ fi
+
+ # Pass install path via environment
+ export VBOX_INSTALL_PATH
+ $SHELL -c "cd $VBOX_INSTALL_PATH/sdk/installer && $pythonbin vboxapisetup.py install \
+ --record $CONFIG_DIR/python-$CONFIG_FILES"
+ cat $CONFIG_DIR/python-$CONFIG_FILES >> $CONFIG_DIR/$CONFIG_FILES
+ rm -f $CONFIG_DIR/python-$CONFIG_FILES
+
+ # Remove files created by Python API setup.
+ rm -rf $VBOX_INSTALL_PATH/sdk/installer/build
+}
+
+maybe_run_python_bindings_installer() {
+ VBOX_INSTALL_PATH="${1}"
+
+ # Loop over all usual suspect Python executable names and try installing
+ # the VirtualBox API bindings. Needs to prevent double installs which waste
+ # quite a bit of time.
+ PYTHONS=""
+ for p in python2.6 python2.7 python2 python3.3 python3.4 python3.5 python3.6 python3.7 python3.8 python3.9 python3.10 python3 python; do
+ if [ "`$p -c 'import sys
+if sys.version_info >= (2, 6) and (sys.version_info < (3, 0) or sys.version_info >= (3, 3)):
+ print(\"test\")' 2> /dev/null`" != "test" ]; then
+ continue
+ fi
+ # Get python major/minor version, and skip if it was already covered.
+ # Uses grep -F to avoid trouble with '.' matching any char.
+ pyvers="`$p -c 'import sys
+print("%s.%s" % (sys.version_info[0], sys.version_info[1]))' 2> /dev/null`"
+ if echo "$PYTHONS" | grep -Fq ":$pyvers:"; then
+ continue
+ fi
+ # Record which version will be installed. If it fails there is no point
+ # trying with different executable/symlink reporting the same version.
+ PYTHONS="$PYTHONS:$pyvers:"
+ install_python_bindings "$p" "Python $pyvers"
+ done
+ if [ -z "$PYTHONS" ]; then
+ echo 1>&2 "Python (2.6, 2.7 or 3.3 and later) unavailable, skipping bindings installation."
+ return 1
+ fi
+
+ return 0
+}
diff --git a/src/VBox/Installer/linux/rpm/LocalConfig.kmk b/src/VBox/Installer/linux/rpm/LocalConfig.kmk
new file mode 100644
index 00000000..161684f4
--- /dev/null
+++ b/src/VBox/Installer/linux/rpm/LocalConfig.kmk
@@ -0,0 +1,44 @@
+# -*- Makefile -*-
+#
+# Overwrite some default kBuild settings
+#
+
+#
+# Copyright (C) 2006-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+# don't build testcases to save time, they are not needed for the package
+VBOX_WITH_TESTCASES :=
+VBOX_WITH_VALIDATIONKIT :=
+
+# required for VBOX_WITH_RUNPATH
+VBOX_WITH_ORIGIN :=
+
+KBUILD_MSG_STYLE := brief
+VBOX_PATH_APP_PRIVATE_ARCH := /usr/lib/virtualbox
+VBOX_PATH_SHARED_LIBS := $(VBOX_PATH_APP_PRIVATE_ARCH)
+VBOX_WITH_RUNPATH := $(VBOX_PATH_APP_PRIVATE_ARCH)
+VBOX_PATH_APP_PRIVATE := /usr/share/virtualbox
+VBOX_PATH_APP_DOCS = $(VBOX_PATH_PACKAGE_DOCS)
+VBOX_WITH_VBOX_IMG := 1
+
+# gcc 4.5 produces some more false positives
+VBOX_WITH_WARNINGS_AS_ERRORS :=
diff --git a/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec b/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec
new file mode 100644
index 00000000..829322aa
--- /dev/null
+++ b/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec
@@ -0,0 +1,371 @@
+# $Id: VirtualBox.tmpl.spec $
+## @file
+# Spec file for creating VirtualBox rpm packages
+#
+
+#
+# Copyright (C) 2006-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+%define %SPEC% 1
+%define %OSE% 1
+%define %PYTHON% 1
+%define %QHELP% 1
+%define VBOXDOCDIR %{_defaultdocdir}/%NAME%
+%global __requires_exclude_from ^/usr/lib/virtualbox/VBoxPython.*$|^/usr/lib/python.*$|^.*\\.py$
+%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
+
+Summary: Oracle VM VirtualBox
+Name: %NAME%
+Version: %BUILDVER%_%BUILDREL%
+Release: 1
+URL: http://www.virtualbox.org/
+Source: VirtualBox.tar
+License: GPLv3
+Group: Applications/System
+Vendor: Oracle Corporation
+BuildRoot: %BUILDROOT%
+Requires: %INITSCRIPTS% %LIBASOUND% %NETTOOLS% %LIBVULKAN%
+
+%if %{?rpm_suse:1}%{!?rpm_suse:0}
+%debug_package
+%endif
+
+%MACROSPYTHON%
+%if %{?__python3:1}%{!?__python3:0}
+%define vbox_python %{__python3}
+%define vbox_python_sitelib %{python3_sitelib}
+%else
+%define vbox_python %{__python}
+%{?rpm_suse: %define vbox_python_sitelib %{py_sitedir}}
+%{!?rpm_suse: %define vbox_python_sitelib %{python_sitelib}}
+%endif
+
+# Remove source code from debuginfo package, needed for Fedora 27 and later
+# as we build the binaries before creating the RPMs.
+%if 0%{?fedora} >= 27
+%undefine _debugsource_packages
+%undefine _debuginfo_subpackages
+%endif
+%if 0%{?rhel} >= 8
+%undefine _debugsource_packages
+%undefine _debuginfo_subpackages
+%endif
+
+%description
+VirtualBox is a powerful PC virtualization solution allowing
+you to run a wide range of PC operating systems on your Linux
+system. This includes Windows, Linux, FreeBSD, DOS, OpenBSD
+and others. VirtualBox comes with a broad feature set and
+excellent performance, making it the premier virtualization
+software solution on the market.
+
+
+%prep
+%setup -q
+DESTDIR=""
+unset DESTDIR
+
+
+%build
+
+
+%install
+# Mandriva: prevent replacing 'echo' by 'gprintf'
+export DONT_GPRINTIFY=1
+rm -rf $RPM_BUILD_ROOT
+install -m 755 -d $RPM_BUILD_ROOT/sbin
+install -m 755 -d $RPM_BUILD_ROOT%{_initrddir}
+install -m 755 -d $RPM_BUILD_ROOT/lib/modules
+install -m 755 -d $RPM_BUILD_ROOT/etc/vbox
+install -m 755 -d $RPM_BUILD_ROOT/usr/bin
+install -m 755 -d $RPM_BUILD_ROOT/usr/src
+install -m 755 -d $RPM_BUILD_ROOT/usr/share/applications
+install -m 755 -d $RPM_BUILD_ROOT/usr/share/pixmaps
+install -m 755 -d $RPM_BUILD_ROOT/usr/share/icons/hicolor
+install -m 755 -d $RPM_BUILD_ROOT%{VBOXDOCDIR}
+install -m 755 -d $RPM_BUILD_ROOT/usr/lib/virtualbox
+install -m 755 -d $RPM_BUILD_ROOT/usr/share/virtualbox
+install -m 755 -d $RPM_BUILD_ROOT/usr/share/mime/packages
+%if %{?with_python:1}%{!?with_python:0}
+(export VBOX_INSTALL_PATH=/usr/lib/virtualbox && \
+ cd ./sdk/installer && \
+ %{vbox_python} ./vboxapisetup.py install --prefix %{_prefix} --root $RPM_BUILD_ROOT)
+%endif
+rm -rf sdk/installer
+mv UnattendedTemplates $RPM_BUILD_ROOT/usr/share/virtualbox
+mv nls $RPM_BUILD_ROOT/usr/share/virtualbox
+cp -a src $RPM_BUILD_ROOT/usr/share/virtualbox
+mv VBox.sh $RPM_BUILD_ROOT/usr/bin/VBox
+mv VBoxSysInfo.sh $RPM_BUILD_ROOT/usr/share/virtualbox
+cp icons/128x128/virtualbox.png $RPM_BUILD_ROOT/usr/share/pixmaps/virtualbox.png
+cd icons
+ for i in *; do
+ if [ -f $i/virtualbox.* ]; then
+ install -d $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/apps
+ mv $i/virtualbox.* $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/apps
+ fi
+ install -d $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/mimetypes
+ mv $i/* $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/mimetypes || true
+ rmdir $i
+ done
+cd -
+rmdir icons
+mv virtualbox.xml $RPM_BUILD_ROOT/usr/share/mime/packages
+%if %{?is_ose:0}%{!?is_ose:1}
+%if "%BUILDREL%" == "el7"
+# For el7 we use gcc from devtoolset-4, which is not suitable for kernel work.
+# See the PATH trickery in src/VBox/Installer/linux/rpm/rules.
+old_path="$PATH"
+PATH=${PATH#/opt/rh/devtoolset-4/root/usr/bin:}
+%endif
+for d in /lib/modules/*; do
+ if [ -L $d/build ]; then
+ rm -f /tmp/vboxdrv-Module.symvers
+ ./src/vboxhost/build_in_tmp \
+ --save-module-symvers /tmp/vboxdrv-Module.symvers \
+ --module-source `pwd`/src/vboxhost/vboxdrv \
+ KBUILD_VERBOSE= KERN_VER=$(basename $d) INSTALL_MODULE_PATH=$RPM_BUILD_ROOT -j4 \
+ %INSTMOD%
+ ./src/vboxhost/build_in_tmp \
+ --use-module-symvers /tmp/vboxdrv-Module.symvers \
+ --module-source `pwd`/src/vboxhost/vboxnetflt \
+ KBUILD_VERBOSE= KERN_VER=$(basename $d) INSTALL_MODULE_PATH=$RPM_BUILD_ROOT -j4 \
+ %INSTMOD%
+ ./src/vboxhost/build_in_tmp \
+ --use-module-symvers /tmp/vboxdrv-Module.symvers \
+ --module-source `pwd`/src/vboxhost/vboxnetadp \
+ KBUILD_VERBOSE= KERN_VER=$(basename $d) INSTALL_MODULE_PATH=$RPM_BUILD_ROOT -j4 \
+ %INSTMOD%
+ if [ -e `pwd`/src/vboxhost/vboxpci ]; then
+ ./src/vboxhost/build_in_tmp \
+ --use-module-symvers /tmp/vboxdrv-Module.symvers \
+ --module-source `pwd`/src/vboxhost/vboxpci \
+ KBUILD_VERBOSE= KERN_VER=$(basename $d) INSTALL_MODULE_PATH=$RPM_BUILD_ROOT -j4 \
+ %INSTMOD%
+ fi
+ fi
+done
+%if "%BUILDREL%" == "el7"
+# For el7 restore PATH, see above.
+PATH="$old_path"
+unset old_path
+%endif
+rm -r src
+%endif
+for i in additions/VBoxGuestAdditions.iso; do
+ mv $i $RPM_BUILD_ROOT/usr/share/virtualbox; done
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/VirtualBox
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/virtualbox
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/VirtualBoxVM
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/virtualboxvm
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxManage
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxmanage
+test -f VBoxSDL && ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxSDL
+test -f VBoxSDL && ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxsdl
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxVRDP
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxHeadless
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxheadless
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxDTrace
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxAudioTest
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxdtrace
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxaudiotest
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxBugReport
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxbugreport
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxBalloonCtrl
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxballoonctrl
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/VBoxAutostart
+ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxautostart
+test -f vboxwebsrv && ln -s VBox $RPM_BUILD_ROOT/usr/bin/vboxwebsrv
+ln -s /usr/lib/virtualbox/vbox-img $RPM_BUILD_ROOT/usr/bin/vbox-img
+ln -s /usr/lib/virtualbox/vboximg-mount $RPM_BUILD_ROOT/usr/bin/vboximg-mount
+ln -s /usr/share/virtualbox/src/vboxhost $RPM_BUILD_ROOT/usr/src/vboxhost-%VER%
+mv virtualbox.desktop $RPM_BUILD_ROOT/usr/share/applications/virtualbox.desktop
+mv VBox.png $RPM_BUILD_ROOT/usr/share/pixmaps/VBox.png
+%{!?is_ose: mv LICENSE $RPM_BUILD_ROOT%{VBOXDOCDIR}}
+mv UserManual*.pdf $RPM_BUILD_ROOT%{VBOXDOCDIR}
+%{?with_qhelp: mv UserManual*.qch UserManual*.qhc $RPM_BUILD_ROOT%{VBOXDOCDIR}}
+install -m 755 -d $RPM_BUILD_ROOT/usr/lib/debug/usr/lib/virtualbox
+%if %{?rpm_suse:1}%{!?rpm_suse:0}
+rm *.debug
+%else
+mv *.debug $RPM_BUILD_ROOT/usr/lib/debug/usr/lib/virtualbox
+%endif
+mv * $RPM_BUILD_ROOT/usr/lib/virtualbox
+if [ -f $RPM_BUILD_ROOT/usr/lib/virtualbox/libQt5CoreVBox.so.5 ]; then
+ $RPM_BUILD_ROOT/usr/lib/virtualbox/chrpath --keepgoing --replace /usr/lib/virtualbox \
+ $RPM_BUILD_ROOT/usr/lib/virtualbox/*.so.5 \
+ $RPM_BUILD_ROOT/usr/lib/virtualbox/plugins/platforms/*.so \
+ $RPM_BUILD_ROOT/usr/lib/virtualbox/plugins/platformthemes/*.so \
+ $RPM_BUILD_ROOT/usr/lib/virtualbox/plugins/sqldrivers/*.so \
+ $RPM_BUILD_ROOT/usr/lib/virtualbox/plugins/styles/*.so \
+ $RPM_BUILD_ROOT/usr/lib/virtualbox/plugins/xcbglintegrations/*.so || true
+ echo "[Paths]" > $RPM_BUILD_ROOT/usr/lib/virtualbox/qt.conf
+ echo "Plugins = /usr/lib/virtualbox/plugins" >> $RPM_BUILD_ROOT/usr/lib/virtualbox/qt.conf
+fi
+rm -f $RPM_BUILD_ROOT/usr/lib/virtualbox/chrpath
+ln -s ../VBoxVMM.so $RPM_BUILD_ROOT/usr/lib/virtualbox/components/VBoxVMM.so
+for i in VBoxHeadless VBoxNetDHCP VBoxNetNAT VBoxNetAdpCtl; do
+ chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/$i; done
+if test -e $RPM_BUILD_ROOT/usr/lib/virtualbox/VirtualBoxVM; then
+ chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/VirtualBoxVM
+else
+ chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/VirtualBox
+fi
+if [ -f $RPM_BUILD_ROOT/usr/lib/virtualbox/VBoxVolInfo ]; then
+ chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/VBoxVolInfo
+fi
+test -f $RPM_BUILD_ROOT/usr/lib/virtualbox/VBoxSDL && \
+ chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/VBoxSDL
+%if %{?with_python:1}%{!?with_python:0}
+if [ -x /usr/bin/pathfix.py ]; then
+ /usr/bin/pathfix.py -pni "%{__python3} %{py3_shbang_opts}" $RPM_BUILD_ROOT/usr/lib/virtualbox/vboxshell.py
+fi
+%endif
+
+
+%pre
+# defaults
+[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
+
+# check for old installation
+if [ -r /etc/vbox/vbox.cfg ]; then
+ . /etc/vbox/vbox.cfg
+ if [ "x$INSTALL_DIR" != "x" -a -d "$INSTALL_DIR" ]; then
+ echo "An old installation of VirtualBox was found. To install this package the"
+ echo "old package has to be removed first. Have a look at /etc/vbox/vbox.cfg to"
+ echo "determine the installation directory of the previous installation. After"
+ echo "uninstalling the old package remove the file /etc/vbox/vbox.cfg."
+ exit 1
+ fi
+fi
+
+# check for active VMs of the installed (old) package
+# Execute the installed packages pre-uninstaller if present.
+/usr/lib/virtualbox/prerm-common.sh 2>/dev/null
+# Stop services from older versions without pre-uninstaller.
+/etc/init.d/vboxballoonctrl-service stop 2>/dev/null
+/etc/init.d/vboxautostart-service stop 2>/dev/null
+/etc/init.d/vboxweb-service stop 2>/dev/null
+VBOXSVC_PID=`pidof VBoxSVC 2>/dev/null || true`
+if [ -n "$VBOXSVC_PID" ]; then
+ # ask the daemon to terminate immediately
+ kill -USR1 $VBOXSVC_PID
+ sleep 1
+ if pidof VBoxSVC > /dev/null 2>&1; then
+ echo "A copy of VirtualBox is currently running. Please close it and try again."
+ echo "Please note that it can take up to ten seconds for VirtualBox (in particular"
+ echo "the VBoxSVC daemon) to finish running."
+ exit 1
+ fi
+fi
+
+
+%post
+LOG="/var/log/vbox-install.log"
+
+# defaults
+[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
+
+# remove old cruft
+if [ -f /etc/init.d/vboxdrv.sh ]; then
+ echo "Found old version of /etc/init.d/vboxdrv.sh, removing."
+ rm /etc/init.d/vboxdrv.sh
+fi
+if [ -f /etc/vbox/vbox.cfg ]; then
+ echo "Found old version of /etc/vbox/vbox.cfg, removing."
+ rm /etc/vbox/vbox.cfg
+fi
+rm -f /etc/vbox/module_not_compiled
+
+# create users groups (disable with INSTALL_NO_GROUP=1 in /etc/default/virtualbox)
+if [ "$INSTALL_NO_GROUP" != "1" ]; then
+ echo
+ echo "Creating group 'vboxusers'. VM users must be member of that group!"
+ echo
+ groupadd -r -f vboxusers 2> /dev/null
+fi
+
+%if %{?rpm_mdv:1}%{!?rpm_mdv:0}
+/sbin/ldconfig
+%update_menus
+%endif
+update-mime-database /usr/share/mime &> /dev/null || :
+update-desktop-database -q > /dev/null 2>&1 || :
+touch --no-create /usr/share/icons/hicolor
+gtk-update-icon-cache -q /usr/share/icons/hicolor 2> /dev/null || :
+
+# Disable module compilation with INSTALL_NO_VBOXDRV=1 in /etc/default/virtualbox
+if test "${INSTALL_NO_VBOXDRV}" = 1; then
+ POSTINST_START=--nostart
+else
+ POSTINST_START=
+fi
+# Install and start the new service scripts.
+/usr/lib/virtualbox/prerm-common.sh || true
+/usr/lib/virtualbox/postinst-common.sh ${POSTINST_START} > /dev/null || true
+
+
+%preun
+# Called before the package is removed, or during upgrade after (not before)
+# the new version's "post" scriptlet.
+# $1==0: remove the last version of the package
+# $1>=1: upgrade
+if [ "$1" = 0 ]; then
+ /usr/lib/virtualbox/prerm-common.sh || exit 1
+ rm -f /etc/udev/rules.d/60-vboxdrv.rules
+ rm -f /etc/vbox/license_agreed
+ rm -f /etc/vbox/module_not_compiled
+fi
+
+%postun
+%if %{?rpm_mdv:1}%{!?rpm_mdv:0}
+/sbin/ldconfig
+%{clean_desktop_database}
+%clean_menus
+%endif
+update-mime-database /usr/share/mime &> /dev/null || :
+update-desktop-database -q > /dev/null 2>&1 || :
+touch --no-create /usr/share/icons/hicolor
+gtk-update-icon-cache -q /usr/share/icons/hicolor 2> /dev/null || :
+rm -rf /usr/lib/virtualbox/ExtensionPacks
+
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+
+%files
+%defattr(-,root,root)
+%doc %{VBOXDOCDIR}/*
+%if %{?with_python:1}%{!?with_python:0}
+%{vbox_python_sitelib}/*
+%endif
+/etc/vbox
+/usr/bin/*
+/usr/src/vbox*
+/usr/lib/virtualbox
+/usr/share/applications/*
+/usr/share/icons/hicolor/*/apps/*
+/usr/share/icons/hicolor/*/mimetypes/*
+/usr/share/mime/packages/*
+/usr/share/pixmaps/*
+/usr/share/virtualbox
diff --git a/src/VBox/Installer/linux/rpm/rules b/src/VBox/Installer/linux/rpm/rules
new file mode 100755
index 00000000..21cf35ea
--- /dev/null
+++ b/src/VBox/Installer/linux/rpm/rules
@@ -0,0 +1,282 @@
+#!/usr/bin/make -f
+# $Id: rules $
+## @file
+# VirtualBox rules.
+#
+
+#
+# Copyright (C) 2006-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+# possible overrides:
+# OSE=1 force VBOX_OSE
+# NOPARALLEL=1 compile with -j1
+# LINUX=<dir> compile vboxdrv against Linux found in <dir>
+# VERBOSE=1 verbose build
+# DEBUG=1 debug build
+# 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 UserManual*.qch and UserManual*.qhc 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)
+# HEADLESS=1 build the headless version
+# VNC=1 build VNC code
+# NOWEBSVC=1 don't build the webservice API
+# STAGEDISO=<path> don't build the VBoxAdditions, use the precompiled .iso
+# PKGDIR=<path> where to store the final package(s)
+# 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.
+#
+# Wine will not be required if STAGEDISO is set.
+
+verpkg := VirtualBox-7.0
+vboxroot := $(shell while ! test -r configure && ! test "$$PWD" = "/"; do cd ..; done; pwd)
+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)/rpm
+builddir := $(bldbase)/builddir
+stagedir := $(bldbase)/rpmbuild
+rpmlib := $(shell if [ `uname -m` = "x86_64" ]; then echo "lib64"; else echo "lib"; fi)
+verfile := $(builddir)/version-generated.mk
+ose := $(if $(OSE),1,$(if $(wildcard $(vboxroot)/src/VBox/RDP/server),,1))
+chrarch := $(shell if [ `uname -m` = "x86_64" ]; then echo "amd64"; else echo "x86"; fi)
+-include $(vboxroot)/SVN_REVISION
+
+NOMODS ?= $(ose)
+NOQT ?= $(HEADLESS)
+NOSDL ?= $(HEADLESS)
+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,)
+NOWINE := $(if $(STAGEDISO),1,$(ose))
+
+ifneq ($(STAGEDISO),)
+ ifeq ($(wildcard $(STAGEDISO)/VBoxGuestAdditions.iso),)
+ $(error STAGEDISO='$(STAGEDISO)/VBoxGuestAdditions.iso' not found)
+ endif
+endif
+
+ifeq ($(wildcard rpm/rules),)
+$(error call rpm/rules from src/VBox/Installer/linux)
+endif
+
+ifneq ($(MAKECMDGOALS),clean)
+ # look for fedora
+ rpmrel := $(shell cat /etc/fedora-release 2> /dev/null | sed -e 's/^Fedora *release *\([1-9][0-9]*\) .*/fedora\1/')
+ ifeq ($(rpmrel),)
+ # look for OEL
+ rpmrel := $(shell cat /etc/enterprise-release 2> /dev/null | sed -ne 's/^Enterprise Linux[a-zA-Z ]*\([1-9][0-9]*\).*/el\1/p')
+ endif
+ ifeq ($(rpmrel),)
+ # look for OL
+ rpmrel := $(shell cat /etc/oracle-release 2> /dev/null | sed -ne 's/^Oracle Linux[a-zA-Z ]*\([1-9][0-9]*\).*/el\1/p')
+ endif
+ ifeq ($(rpmrel),)
+ # look for CentOS
+ rpmrel := $(shell cat /etc/redhat-release 2> /dev/null | sed -ne 's/^CentOS[a-zA-Z ]*\([1-9][0-9]*\).*/el\1/p')
+ endif
+ ifeq ($(rpmrel),)
+ # look for Red Hat
+ rpmrel := $(shell cat /etc/redhat-release 2> /dev/null | sed -ne 's/^Red Hat[a-zA-Z ]*\([1-9][0-9]*\).*/el\1/p')
+ endif
+ ifeq ($(rpmrel),)
+ # look for openSUSE
+ rpmrel := $(shell cat /etc/SUSE-brand 2> /dev/null | sed -ne 's/^VERSION *= *\([0-9]*\)\.\([0-9]*\)/openSUSE\1\2/p')
+ endif
+ # look for openSUSE Tumbleweed
+ ifeq ($(rpmrel),)
+ rpmrel := $(shell cat /etc/SUSE-brand 2> /dev/null | sed -ne 's/^VERSION *= *tumbleweed/openSUSETW/p')
+ endif
+ ifeq ($(rpmrel),)
+ $(error failed to detect the release type. Hack the detection.)
+ endif
+
+ rpmdist := $(strip $(shell grep $(rpmrel) $(instlin)/distributions_rpm | cut -d'=' -f2))
+ ifeq ($(rpmdist),)
+ $(error Cannot detect package distribution (rpmrel=$(rpmrel)))
+ endif
+
+ ifeq ($(filter-out el5 el6 el7 el8 el9 fedora18 fedora19 fedora20 fedora21 fedora22 fedora24 fedora25 fedora26 fedora29 fedora31 fedora32 fedora33 fedora35 fedora36,$(rpmrel)),)
+ rpmspec := rpm_redhat
+ endif
+ ifeq ($(filter-out openSUSE110 openSUSE111 openSUSE112 openSUSE113 openSUSE114 openSUSE123 openSUSE131 openSUSE132 openSUSE150 openSUSE153 openSUSETW,$(rpmrel)),)
+ rpmspec := rpm_suse
+ endif
+ ifeq ($(rpmspec),)
+ $(error failed to detect the .spec file (rpmrel=$(rpmrel)))
+ endif
+endif
+
+ifneq ($(wildcard $(verfile)),)
+include $(verfile)
+ver := $(VBOX_VERSION_STRING)
+svnver := $(if $(NOSUBVER),,$(if $(svn_revision),-$(svn_revision),$(shell if \
+ svn info $(vboxroot) > /dev/null 2>&1; then \
+ svn info $(vboxroot)|sed -e "s/^Revision: \(.*\)/-\1/;t;d"; else \
+ date +"-%Y%m%d"; fi)))
+rpmver := $(ver)$(subst -,_,$(svnver))$(VERSUFFIX)$(if $(HEADLESS),_headless,)$(if $(DEBUG),_dbg,)
+archdir := $(bldbase)/VirtualBox-$(ver)
+rpmname := $(verpkg)-$(rpmver)_$(rpmrel)
+endif
+
+# never ship any modules
+instmod :=
+
+ifeq ($(wildcard /usr/share/doc/packages/bash),)
+ doc_dir := VBOX_PATH_PACKAGE_DOCS="/usr/share/doc/$(verpkg)"
+else
+ # Novell (OpenSUSE, SLES)
+ doc_dir := VBOX_PATH_PACKAGE_DOCS="/usr/share/doc/packages/$(verpkg)"
+endif
+
+ifeq ($(NOQT),)
+ ifeq ($(rpmrel),el7)
+ # Protect against the fact that this Makefile is run several times, updating
+ # PATH every time. Still assumes that nothing else is added as a prefix.
+ PATH := $(PATH:/opt/rh/devtoolset-9/root/usr/bin:%=%)
+ export PATH := /opt/rh/devtoolset-9/root/usr/bin:$(PATH)
+ endif
+endif
+
+# EL5 ships Python 2.4 while our Python support requires Python 2.6 or later
+cfg_flags := $(if $(NOQT),--disable-qt,) \
+ $(if $(NOSDL),--disable-vboxsdl,) \
+ $(if $(filter el5 el6,$(rpmrel)),--build-libvpx,) \
+ $(if $(filter el5 el6,$(rpmrel)),--build-libopus,) \
+ $(if $(filter el5 el6,$(rpmrel)),--build-libssl,) \
+ $(if $(filter el5,$(rpmrel)),--build-libcurl,) \
+ $(if $(filter el5,$(rpmrel)),--disable-sdl-ttf,) \
+ $(if $(filter el5,$(rpmrel)),--disable-pulse,) \
+ $(if $(filter el5,$(rpmrel)),--disable-python,) \
+ $(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 := LOCALCFG=$(instlin)/rpm/LocalConfig.kmk \
+ PATH_OUT=$(builddir) \
+ VBOX_WITHOUT_EXTPACK_PUEL_PACKING=1 \
+ VBOX_WITHOUT_EXTPACK_VNC_PACKING=1 \
+ $(if $(filter el5 el6,$(rpmrel)),,VBOX_WITH_VMSVGA3D=1) \
+ VBOX_DO_STRIP= \
+ $(if $(filter el5,$(rpmrel)),VBOX_BLD_PYTHON=$(firstword $(wildcard \
+ /usr/local/bin/python2.7 /usr/bin/python2.7 /usr/bin/python2.6 /usr/bin/python2 /usr/bin/python)),) \
+ $(if $(filter el5,$(rpmrel)),,VBOX_WITH_SYSFS_BY_DEFAULT=1) \
+ $(doc_dir) \
+ VBOX_PACKAGE_DIST=$(rpmdist) \
+ $(if $(svn_revision),VBOX_SVN_REV=$(svn_revision),) \
+ $(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:
+ mkdir -p $(bldbase)
+ cd $(vboxroot) && ./configure --odir=$(bldbase) $(cfg_flags)
+ touch $@
+
+build: $(bldbase)/configure-stamp $(bldbase)/build-stamp
+$(bldbase)/build-stamp $(verfile): $(bldbase)/configure-stamp
+ . $(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,)
+ . $(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 \
+ VBOX_LNX_ADD_ARCHIVE.amd64=$(builddir)/bin/additions/VBoxGuestAdditions-amd64.tar.bz2 \
+ VBOX_PATH_ADDITIONS.linux.x86=$(builddir)/bin/additions \
+ VBOX_PATH_ADDITIONS.linux.amd64=$(builddir)/bin/additions \
+ packing
+ touch $(bldbase)/build-stamp
+
+clean:
+ rm -rf $(archdir)
+ rm -rf $(stagedir)
+ rm -rf $(builddir)
+ rm -rf $(bldbase)/wine.*
+ rm -rf $(bldbase)/VirtualBox-*
+ rm -f $(bldbase)/VirtualBox.tar $(bldbase)/VirtualBox.tar.bz2
+ rm -f $(bldbase)/build-stamp $(bldbase)/configure-stamp
+ rm -f $(bldbase)/AutoConfig.kmk $(bldbase)/configure.log $(bldbase)/env.sh
+ rm -f $(bldbase)/VirtualBox.spec
+ if [ -d $(bldbase) ]; then rmdir $(bldbase); fi
+
+ifeq ($(VBOX_VERSION_MAJOR),)
+binary: build $(verfile)
+ +$(MAKE) -f rpm/rules binary
+
+else
+binary: build
+ rm -rf $(bldbase)/VirtualBox-*
+ tar -xf $(builddir)/bin/VirtualBox.tar -C $(bldbase)
+ sed \
+ -e 's|%VER%|$(ver)|g' \
+ -e 's|%NAME%|$(verpkg)|g' \
+ -e 's|%BUILDVER%|$(rpmver)|g' \
+ -e 's|%BUILDREL%|$(rpmrel)|g' \
+ -e 's|%BUILDROOT%|$(bldbase)/buildroot|g' \
+ -e 's|%OSE%|$(if $(ose),is_ose,not_ose)|g' \
+ -e 's|%SPEC%|$(rpmspec)|g' \
+ -e 's|%QHELP%|$(if $(STAGEDQHELP),with_qhelp,without_qhelp)|g' \
+ -e 's|%PYTHON%|$(if $(filter el5,$(rpmrel)),without_python,with_python)|g' \
+ -e 's|%MACROSPYTHON%|$(if $(wildcard /usr/lib/rpm/macros.d/macros.python3),,$(if $(wildcard /usr/lib/rpm/macros.python),%include /usr/lib/rpm/macros.python,))|g' \
+ -e 's|%INSTMOD%|$(instmod)|g' \
+ -e 's|%LIBASOUND%|$(if $(filter lib64,$(rpmlib)),libasound.so.2()(64bit),libasound.so.2)|g' \
+ -e 's|%INITSCRIPTS%|$(if $(filter fedora,$(rpmspec)),initscripts,)|g' \
+ -e 's|%NETTOOLS%|$(if $(filter fedora18 fedora19 fedora20 fedora21 el5 openSUSE110 openSUSE111 openSUSE112 openSUSE113 openSUSE114,$(rpmrel)),net-tools,iproute)|g' \
+ -e 's|%LIBVULKAN%|$(if $(filter el7,$(rpmrel)),vulkan,%LIBVULKAN%)|g' \
+ -e 's|%LIBVULKAN%|$(if $(findstring el,$(rpmrel)),vulkan-loader,%LIBVULKAN%)|g' \
+ -e 's|%LIBVULKAN%|$(if $(findstring fedora,$(rpmrel)),vulkan-loader,%LIBVULKAN%)|g' \
+ -e 's|%LIBVULKAN%|$(if $(filter openSUSE153,$(rpmrel)),libvulkan1,)|g' \
+ $(instlin)/rpm/VirtualBox.tmpl.spec > $(archdir)/VirtualBox.spec
+ mv $(bldbase)/VirtualBox-$(ver) $(bldbase)/$(rpmname)
+ cp $(vboxroot)/tools/linux.$(chrarch)/bin/chrpath $(bldbase)/$(rpmname) || true
+ tar -cf $(bldbase)/VirtualBox.tar -C $(bldbase) $(rpmname)
+ rm -f $(stagedir)/RPMS/*/VirtualBox*rpm
+ rm -f $(stagedir)/SPECS/*
+ mkdir -p $(stagedir)/BUILD $(stagedir)/RPMS/i386 $(stagedir)/RPMS/x86_64 $(stagedir)/SOURCES $(stagedir)/SPECS $(stagedir)/SRPMS
+ (cd $(bldbase); rpmbuild --define '_topdir $(stagedir)' -tb --clean VirtualBox.tar)
+ mv $(stagedir)/RPMS/*/$(verpkg)-debug* $(pkgdir) || true
+ file=`find $(stagedir)/RPMS -name $(verpkg)*rpm -print`; \
+ mv $$file $(pkgdir)
+# Note! if rpmbuild fails: sudo chmod a+rw /usr/src/redhat/* /usr/src/redhat/RPMS/*
+# Note! if find/mv fails: sudo ln -s redhat/ /usr/src/packages
+endif
+
+.PHONY: binary configure build clean
diff --git a/src/VBox/Installer/linux/runasroot.sh b/src/VBox/Installer/linux/runasroot.sh
new file mode 100755
index 00000000..5af497d5
--- /dev/null
+++ b/src/VBox/Installer/linux/runasroot.sh
@@ -0,0 +1,188 @@
+#!/bin/sh
+# $Id: runasroot.sh $
+## @file
+# VirtualBox privileged execution helper script for Linux and Solaris
+#
+
+#
+# Copyright (C) 2009-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+# Deal with differing "which" semantics
+mywhich() {
+ which "$1" 2>/dev/null | grep -v "no $1"
+}
+
+# Get the name and execute switch for a useful terminal emulator
+#
+# Sets $gxtpath to the emulator path or empty
+# Sets $gxttitle to the "title" switch for that emulator
+# Sets $gxtexec to the "execute" switch for that emulator
+# May clobber $gtx*
+# Calls mywhich
+getxterm() {
+ # gnome-terminal uses -e differently to other emulators
+ for gxti in "konsole --title -e" "gnome-terminal --title -x" "xterm -T -e"; do
+ set $gxti
+ gxtpath="`mywhich $1`"
+ case "$gxtpath" in ?*)
+ gxttitle=$2
+ gxtexec=$3
+ return
+ ;;
+ esac
+ done
+}
+
+# Quotes its argument by inserting '\' in front of every character save
+# for 'A-Za-z0-9/'. Prints the result to stdout.
+quotify() {
+ echo "$1" | sed -e 's/\([^a-zA-Z0-9/]\)/\\\1/g'
+}
+
+ostype=`uname -s`
+if test "$ostype" != "Linux" && test "$ostype" != "SunOS" ; then
+ echo "Linux/Solaris not detected."
+ exit 1
+fi
+
+HAS_TERMINAL=""
+case "$1" in "--has-terminal")
+ shift
+ HAS_TERMINAL="yes"
+ ;;
+esac
+
+case "$#" in "2"|"3")
+ ;;
+ *)
+ echo "Usage: `basename $0` DESCRIPTION COMMAND [ADVICE]" >&2
+ echo >&2
+ echo "Attempt to execute COMMAND with root privileges, displaying DESCRIPTION if" >&2
+ echo "possible and displaying ADVICE if possible if no su(1)-like tool is available." >&2
+ exit 1
+ ;;
+esac
+
+DESCRIPTION=$1
+COMMAND=$2
+ADVICE=$3
+PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/X11/bin
+
+case "$ostype" in SunOS)
+ PATH=$PATH:/usr/sfw/bin:/usr/gnu/bin:/usr/xpg4/bin:/usr/xpg6/bin:/usr/openwin/bin:/usr/ucb
+ GKSU_SWITCHES="-au root"
+ ;;
+ *)
+ GKSU_SWITCHES=""
+ ;;
+esac
+
+case "$HAS_TERMINAL" in "")
+ case "$DISPLAY" in ?*)
+ KDESUDO="`mywhich kdesudo`"
+ case "$KDESUDO" in ?*)
+ eval "`quotify "$KDESUDO"` --comment `quotify "$DESCRIPTION"` -- $COMMAND"
+ exit
+ ;;
+ esac
+
+ KDESU="`mywhich kdesu`"
+ case "$KDESU" in ?*)
+ "$KDESU" -c "$COMMAND"
+ exit
+ ;;
+ esac
+
+ GKSU="`mywhich gksu`"
+ case "$GKSU" in ?*)
+ # Older gksu does not grok --description nor '--' and multiple args.
+ # @todo which versions do?
+ # "$GKSU" --description "$DESCRIPTION" -- "$@"
+ # Note that $GKSU_SWITCHES is NOT quoted in the following
+ "$GKSU" $GKSU_SWITCHES "$COMMAND"
+ exit
+ ;;
+ esac
+ ;;
+ esac # $DISPLAY
+ ;;
+esac # ! $HAS_TERMINAL
+
+# pkexec may work for ssh console sessions as well if the right agents
+# are installed. However it is very generic and does not allow for any
+# custom messages. Thus it comes after gksu.
+## @todo should we insist on either a display or a terminal?
+# case "$DISPLAY$HAS_TERMINAL" in ?*)
+PKEXEC="`mywhich pkexec`"
+case "$PKEXEC" in ?*)
+ eval "\"$PKEXEC\" $COMMAND"
+ exit
+ ;;
+esac
+# ;;S
+#esac
+
+case "$HAS_TERMINAL" in ?*)
+ USE_SUDO=
+ grep -q Ubuntu /etc/lsb-release 2>/dev/null && USE_SUDO=true
+ # On Ubuntu we need sudo instead of su. Assume this works, and is only
+ # needed for Ubuntu until proven wrong.
+ case $USE_SUDO in true)
+ SUDO_COMMAND="`quotify "$SUDO"` -- $COMMAND"
+ eval "$SUDO_COMMAND"
+ exit
+ ;;
+ esac
+
+ SU="`mywhich su`"
+ case "$SU" in ?*)
+ "$SU" - root -c "$COMMAND"
+ exit
+ ;;
+ esac
+ ;;
+esac
+
+# The ultimate fallback is running 'su -' within an xterm. We use the
+# title of the xterm to tell what is going on.
+case "$DISPLAY" in ?*)
+ SU="`mywhich su`"
+ case "$SU" in ?*)
+ getxterm
+ case "$gxtpath" in ?*)
+ "$gxtpath" "$gxttitle" "$DESCRIPTION - su" "$gxtexec" su - root -c "$COMMAND"
+ exit
+ ;;
+ esac
+ esac
+esac # $DISPLAY
+
+# Failure...
+case "$DISPLAY" in ?*)
+ echo "Unable to locate 'pkexec', 'gksu' or 'su+xterm'. $ADVICE" >&2
+ ;;
+ *)
+ echo "Unable to locate 'pkexec'. $ADVICE" >&2
+ ;;
+esac
+
+exit 1
diff --git a/src/VBox/Installer/linux/scripts/VBoxHeadlessXOrg.sh b/src/VBox/Installer/linux/scripts/VBoxHeadlessXOrg.sh
new file mode 100755
index 00000000..2cfa849f
--- /dev/null
+++ b/src/VBox/Installer/linux/scripts/VBoxHeadlessXOrg.sh
@@ -0,0 +1,369 @@
+#!/bin/sh
+# $Id: VBoxHeadlessXOrg.sh $
+## @file
+# VirtualBox X Server auto-start service.
+#
+
+#
+# Copyright (C) 2012-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+PATH=$PATH:/bin:/sbin:/usr/sbin
+
+## Start one or several X servers in the background for use with headless
+# rendering. For details, options and configuration see the usage() function
+# further down.
+#
+# I have tried to follow the best practices I could find for writing a Linux
+# service (and doing it in shell script) which should work well with
+# traditional and modern service systems using minimal init or service files.
+# In our case this boils down to:
+# * Start with a single command line, stop using one of ${EXIT_SIGNALS} below.
+# * Stopping with a signal can be done safely using the pid stored in the
+# pid-file and our (presumably unique) command name. For this reason we
+# only support running one instance of the service though.
+# * Start in the foreground. Systems without proper service control can take
+# care of the backgrounding in the init script.
+# * Clean up all sub-processes (X servers) ourselves when we are stopped
+# cleanly and don't provide any other way to clean them up automatically (in
+# case we are stopped uncleanly) as we don't know of a generic safe way to
+# do so, though some service management systems (i.e. systemd) can do so.
+# (A more thorough automatic clean-up would be possible if Xorg didn't
+# potentially have to be run as root, so that we could run all processes
+# using a service-specific user account and just terminate all processes
+# run by that user to clean up.)
+
+## Default configuration file name.
+# @note This is not very nice - /etc/default is actually Debian-specific.
+CONFIGURATION_FILE=/etc/default/virtualbox
+## The name of this script.
+SCRIPT_NAME="$0"
+## The service name.
+SERVICE_NAME="vboxheadlessxorg"
+## The service description.
+SERVICE_DESCRIPTION="Headless rendering service"
+## Signals and conditions which may be used to terminate the service.
+EXIT_SIGNALS="EXIT HUP INT QUIT ABRT TERM"
+## The default run-time data folder.
+DEFAULT_RUN_FOLDER="/var/run/${SERVICE_NAME}/"
+## The default X server configuration directory.
+DEFAULT_CONFIGURATION_FOLDER="${DEFAULT_RUN_FOLDER}/xorg.conf.d/"
+## The extra data key used to provide the list of available X server displays.
+EXTRA_DATA_KEY_DISPLAYS="HeadlessXServer/Displays"
+## The extra data key used to specify the X server authority file.
+EXTRA_DATA_KEY_AUTH="HeadlessXServer/AuthFile"
+
+## Print usage information for the service script.
+## @todo Perhaps we should support some of the configuration file options from
+# the command line. Opinions welcome.
+## @todo Possibly extract this information for the user manual.
+usage() {
+ cat << EOF
+Usage:
+
+ $(basename "${SCRIPT_NAME}") [<options>]
+
+Start one or several X servers in the background for use with headless
+rendering. We only support X.Org Server at the moment. On service start-up available graphics devices are detected and an X server configuration file is
+generated for each. We attempt to start an X server process for each
+configuration file. The process is configurable by setting values in a file as
+described below.
+
+Options:
+
+ -c|--conf-file Specify an alternative locations for the configuration
+ file. The default location is:
+ "${CONFIGURATION_FILE}"
+
+ --help|--usage Print this text.
+
+The optional configuration file should contain a series of lines of the form
+"KEY=value". It will be read in as a command shell sub-script. Here is the
+current list of possible key settings with a short explanation. Usually it
+should be sufficient to change the value of \${HEADLESS_X_ORG_USERS} and to
+leave all other settings unchanged.
+
+ HEADLESS_X_ORG_CONFIGURATION_FOLDER
+ The folder where the X server configuration files are to be created.
+
+ HEADLESS_X_ORG_LOG_FOLDER
+ The folder where log files will be saved.
+
+ HEADLESS_X_ORG_LOG_FILE
+ The main log file name.
+
+ HEADLESS_X_ORG_RUN_FOLDER
+ The folder to store run-time data in.
+
+ HEADLESS_X_ORG_WAIT_FOR_PREREQUISITES
+ Command to execute to wait until all dependencies for the X servers are
+ available. The default command waits until the udev event queue has
+ settled. The command may return failure to signal that it has given up.
+ No arguments may be passsed.
+
+ HEADLESS_X_ORG_USERS
+ List of users who will have access to the X servers started and for whom we
+ will provide the configuration details via VirtualBox extra data. This
+ variable is only used by the commands in the default configuration
+ (\${HEADLESS_X_ORG_SERVER_PRE_COMMAND} and
+ \${HEADLESS_X_ORG_SERVER_POST_COMMAND}), and not by the service itself.
+
+ HEADLESS_X_ORG_FIRST_DISPLAY
+ The first display number which will be used for a started X server. The
+ others will use the following numbers.
+
+ HEADLESS_X_ORG_SERVER_PRE_COMMAND
+ Command to execute once to perform any set-up needed before starting the
+ X servers, such as setting up the X server authentication. The default
+ command creates an authority file for each of the users in the list
+ \${HEADLESS_X_ORG_USERS} and generates server configuration files for all
+ detected graphics cards. No arguments may be passed.
+
+ HEADLESS_X_ORG_SERVER_COMMAND
+ The default X server start-up command. It will be passed three parameters
+ - in order, the screen number to use, the path of the X.Org configuration
+ file to use and the path of the X server log file to create.
+
+ HEADLESS_X_ORG_SERVER_POST_COMMAND
+ Command to execute once the X servers have been successfully started. It
+ will be passed a single parameter which is a space-separated list of the
+ X server screen numbers. By default this stores the service configuration
+ information to VirtualBox extra data for each of the users in the list
+ from the variable HEADLESS_X_ORG_USERS: the list of displays is set to the
+ key "${EXTRA_DATA_KEY_DISPLAYS}" and the path of the authority file to
+ "${EXTRA_DATA_KEY_AUTH}".
+EOF
+}
+
+# Default configuration.
+HEADLESS_X_ORG_CONFIGURATION_FOLDER="${DEFAULT_CONFIGURATION_FOLDER}"
+HEADLESS_X_ORG_LOG_FOLDER="/var/log/${SERVICE_NAME}"
+HEADLESS_X_ORG_LOG_FILE="${SERVICE_NAME}.log"
+HEADLESS_X_ORG_RUN_FOLDER="/var/run/${SERVICE_NAME}"
+HEADLESS_X_ORG_USERS=""
+HEADLESS_X_ORG_FIRST_DISPLAY=40
+X_AUTH_FILE="${HEADLESS_X_ORG_RUN_FOLDER}/xauth"
+
+default_wait_for_prerequisites()
+{
+ udevadm settle || udevsettle # Fails if no udevadm.
+}
+HEADLESS_X_ORG_WAIT_FOR_PREREQUISITES="default_wait_for_prerequisites"
+
+default_pre_command()
+{
+ # Create new authority file.
+ echo > "${X_AUTH_FILE}"
+ # Create the xorg.conf files.
+ mkdir -p "${HEADLESS_X_ORG_CONFIGURATION_FOLDER}" || return 1
+ display="${HEADLESS_X_ORG_FIRST_DISPLAY}"
+ for i in /sys/bus/pci/devices/*; do
+ read class < "${i}/class"
+ case "${class}" in *03????)
+ address="${i##*/}"
+ address="${address%%:*}${address#*:}"
+ address="PCI:${address%%.*}:${address#*.}"
+ read vendor < "${i}/vendor"
+ case "${vendor}" in *10de|*10DE) # NVIDIA
+ cat > "${HEADLESS_X_ORG_CONFIGURATION_FOLDER}/xorg.conf.${display}" << EOF
+Section "Module"
+ Load "glx"
+EndSection
+Section "Device"
+ Identifier "Device${display}"
+ Driver "nvidia"
+ Option "UseDisplayDevice" "none"
+EndSection
+Section "Screen"
+ Identifier "Screen${display}"
+ Device "Device${display}"
+EndSection
+Section "ServerLayout"
+ Identifier "Layout${display}"
+ Screen "Screen${display}"
+ Option "AllowMouseOpenFail" "true"
+ Option "AutoAddDevices" "false"
+ Option "AutoAddGPU" "false"
+ Option "AutoEnableDevices" "false"
+ Option "IsolateDevice" "${address}"
+EndSection
+EOF
+ esac
+ # Add key to the authority file.
+ key="$(dd if=/dev/urandom count=1 bs=16 2>/dev/null | od -An -x)"
+ xauth -f "${X_AUTH_FILE}" add :${display} . "${key}"
+ display=`expr ${display} + 1`
+ esac
+ done
+ # Duplicate the authority file.
+ for i in ${HEADLESS_X_ORG_USERS}; do
+ cp "${X_AUTH_FILE}" "${X_AUTH_FILE}.${i}"
+ chown "${i}" "${X_AUTH_FILE}.${i}"
+ done
+}
+HEADLESS_X_ORG_SERVER_PRE_COMMAND="default_pre_command"
+
+default_command()
+{
+ auth="${HEADLESS_X_ORG_RUN_FOLDER}/xauth"
+ # screen=$1
+ # conf_file=$2
+ # log_file=$3
+ trap "kill \${PID}; sleep 5; kill -KILL \${PID} 2>/dev/null" ${EXIT_SIGNALS}
+ Xorg :"${1}" -auth "${auth}" -config "${2}" -logverbose 0 -logfile /dev/null -verbose 7 > "${3}" 2>&1 &
+ PID="$!"
+ wait
+ exit
+}
+HEADLESS_X_ORG_SERVER_COMMAND="default_command"
+
+default_post_command()
+{
+ # screens=$1
+ for i in ${HEADLESS_X_ORG_USERS}; do
+ su ${i} -c "VBoxManage setextradata global ${EXTRA_DATA_KEY_DISPLAYS} \"${1}\""
+ su ${i} -c "VBoxManage setextradata global ${EXTRA_DATA_KEY_AUTH} \"${HEADLESS_X_ORG_RUN_FOLDER}/xauth\""
+ done
+}
+HEADLESS_X_ORG_SERVER_POST_COMMAND="default_post_command"
+
+## The function definition at the start of every non-trivial shell script!
+abort() {
+ ## $@, ... Error text to output to standard error in printf format.
+ printf "$@" >&2
+ exit 1
+}
+
+## Milder version of abort, when we can't continue because of a valid condition.
+abandon() {
+ ## $@, ... Text to output to standard error in printf format.
+ printf "$@" >&2
+ exit 0
+}
+
+abort_usage() {
+ usage >&2
+ abort "$@"
+}
+
+# Print a banner message
+banner() {
+ cat << EOF
+${VBOX_PRODUCT} VBoxHeadless X Server start-up service Version ${VBOX_VERSION_STRING}
+(C) 2005-${VBOX_C_YEAR} ${VBOX_VENDOR}
+All rights reserved.
+
+EOF
+}
+
+# Get the directory where the script is located.
+SCRIPT_FOLDER=$(dirname "${SCRIPT_NAME}")"/"
+[ -r "${SCRIPT_FOLDER}generated.sh" ] ||
+ abort "${LOG_FILE}" "Failed to find installation information.\n"
+. "${SCRIPT_FOLDER}generated.sh"
+
+# Parse our arguments.
+while [ "$#" -gt 0 ]; do
+ case $1 in
+ -c|--conf-file)
+ [ "$#" -gt 1 ] ||
+ {
+ banner
+ abort "%s requires at least one argument.\n" "$1"
+ }
+ CONFIGURATION_FILE="$2"
+ shift
+ ;;
+ --help|--usage)
+ banner
+ usage
+ exit 0
+ ;;
+ *)
+ banner
+ abort_usage "Unknown argument $1.\n"
+ ;;
+ esac
+ shift
+done
+
+[ -r "${CONFIGURATION_FILE}" ] && . "${CONFIGURATION_FILE}"
+
+# Change to the root directory so we don't hold any other open.
+cd /
+
+# If something fails here we will catch it when we create the directory.
+[ -e "${HEADLESS_X_ORG_LOG_FOLDER}" ] &&
+ [ -d "${HEADLESS_X_ORG_LOG_FOLDER}" ] &&
+ rm -rf "${HEADLESS_X_ORG_LOG_FOLDER}.old" 2> /dev/null &&
+mv "${HEADLESS_X_ORG_LOG_FOLDER}" "${HEADLESS_X_ORG_LOG_FOLDER}.old" 2> /dev/null
+mkdir -p "${HEADLESS_X_ORG_LOG_FOLDER}" 2>/dev/null ||
+{
+ banner
+ abort "Failed to create log folder \"${HEADLESS_X_ORG_LOG_FOLDER}\".\n"
+}
+mkdir -p "${HEADLESS_X_ORG_RUN_FOLDER}" 2>/dev/null ||
+{
+ banner
+ abort "Failed to create run folder \"${HEADLESS_X_ORG_RUN_FOLDER}\".\n"
+}
+exec > "${HEADLESS_X_ORG_LOG_FOLDER}/${HEADLESS_X_ORG_LOG_FILE}" 2>&1
+
+banner
+
+# Wait for our dependencies to become available.
+if [ -n "${HEADLESS_X_ORG_WAIT_FOR_PREREQUISITES}" ]; then
+ "${HEADLESS_X_ORG_WAIT_FOR_PREREQUISITES}" ||
+ abort "Service prerequisites not available.\n"
+fi
+
+# Do any pre-start setup.
+if [ -n "${HEADLESS_X_ORG_SERVER_PRE_COMMAND}" ]; then
+ "${HEADLESS_X_ORG_SERVER_PRE_COMMAND}" ||
+ abort "Pre-requisite failed.\n"
+fi
+
+X_SERVER_PIDS=""
+X_SERVER_SCREENS=""
+trap "kill \${X_SERVER_PIDS} 2>/dev/null" ${EXIT_SIGNALS}
+space="" # Hack to put spaces between the pids but not before or after.
+for conf_file in "${HEADLESS_X_ORG_CONFIGURATION_FOLDER}"/*; do
+ [ x"${conf_file}" = x"${HEADLESS_X_ORG_CONFIGURATION_FOLDER}/*" ] &&
+ ! [ -e "${conf_file}" ] &&
+ abort "No configuration files found.\n"
+ filename="$(basename "${conf_file}")"
+ screen="$(expr "${filename}" : "xorg\.conf\.\(.*\)")"
+ [ 0 -le "${screen}" ] 2>/dev/null ||
+ abort "Badly formed file name \"${conf_file}\".\n"
+ log_file="${HEADLESS_X_ORG_LOG_FOLDER}/Xorg.${screen}.log"
+ "${HEADLESS_X_ORG_SERVER_COMMAND}" "${screen}" "${conf_file}" "${log_file}" &
+ X_SERVER_PIDS="${X_SERVER_PIDS}${space}$!"
+ X_SERVER_SCREENS="${X_SERVER_SCREENS}${space}${screen}"
+ space=" "
+done
+
+# Do any post-start work.
+if [ -n "${HEADLESS_X_ORG_SERVER_POST_COMMAND}" ]; then
+ "${HEADLESS_X_ORG_SERVER_POST_COMMAND}" "${X_SERVER_SCREENS}" ||
+ abort "Post-command failed.\n"
+fi
+
+wait
diff --git a/src/VBox/Installer/linux/testcase/Makefile.kmk b/src/VBox/Installer/linux/testcase/Makefile.kmk
new file mode 100644
index 00000000..1e1ac7ea
--- /dev/null
+++ b/src/VBox/Installer/linux/testcase/Makefile.kmk
@@ -0,0 +1,37 @@
+# $Id: Makefile.kmk $
+## @file
+# Sub-Makefile for the VBox Linux installer testcase.
+#
+
+#
+# Copyright (C) 2006-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+SUB_DEPTH = ../../../../..
+include $(KBUILD_PATH)/subheader.kmk
+
+INSTALLS += tstHeadlessXOrg
+TESTING += tstHeadlessXOrg
+tstHeadlessXOrg_INST = $(INST_TESTCASE)
+tstHeadlessXOrg_MODE = a+rx,u+w
+tstHeadlessXOrg_SOURCES = tstHeadlessXOrg.sh
+
+include $(FILE_KBUILD_SUB_FOOTER)
diff --git a/src/VBox/Installer/linux/testcase/tstHeadlessXOrg.sh b/src/VBox/Installer/linux/testcase/tstHeadlessXOrg.sh
new file mode 100755
index 00000000..51c6ddf7
--- /dev/null
+++ b/src/VBox/Installer/linux/testcase/tstHeadlessXOrg.sh
@@ -0,0 +1,315 @@
+#!/bin/sh
+# $Id: tstHeadlessXOrg.sh $
+## @file
+# VirtualBox X Server auto-start service unit test.
+#
+
+#
+# Copyright (C) 2012-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+## The function definition at the start of every non-trivial shell script!
+abort()
+{
+ ## $@, ... Error text to output to standard error in printf format.
+ format="$1"
+ shift
+ printf "${TEST_NAME}: ${format}" "$@" >&2
+ exit 1
+}
+
+## Print a TESTING line. Takes printf arguments but without a '\n'.
+print_line()
+{
+ format="$1"
+ shift
+ printf "${TEST_NAME}: TESTING ${format}... " "$@"
+}
+
+## Expected a process to complete within a certain time and call a function if
+# it does which should check whether the test was successful and print status
+# information. The function takes the exit status as its single parameter.
+expect_exit()
+{
+ PID="$1" ## The PID we are waiting for.
+ TIME_OUT="$2" ## The time-out before we terminate the process.
+ TEST_FUNCTION="$3" ## The function to call on exit to check the test result.
+
+ # Give it time to complete.
+ { sleep "${TIME_OUT}"; kill "${PID}" 2>/dev/null; } &
+
+ wait "${PID}"
+ STATUS="$?"
+ case "${STATUS}" in
+ 143) # SIGTERM
+ printf "\nFAILED: time-out.\n"
+ ;;
+ *)
+ ${TEST_FUNCTION} "${STATUS}"
+esac
+}
+
+## Create a simple configuration file. Add items onto the end to override them
+# on an item-by-item basis.
+create_basic_configuration()
+{
+ TEST_FOLDER="${1}"
+ FILE_NAME="${TEST_FOLDER}conf" ## The name of the configuration file to create.
+ BASE_FOLDER="${TEST_FOLDER}"
+ XORG_FOLDER="${TEST_FOLDER}/xorg"
+ mkdir -p "${XORG_FOLDER}"
+ cat > "${FILE_NAME}" << EOF
+HEADLESS_X_ORG_CONFIGURATION_FOLDER="${BASE_FOLDER}/xorg"
+HEADLESS_X_ORG_LOG_FOLDER="${BASE_FOLDER}/log"
+HEADLESS_X_ORG_LOG_FILE="log"
+HEADLESS_X_ORG_RUN_FOLDER="${BASE_FOLDER}/run"
+HEADLESS_X_ORG_WAIT_FOR_PREREQUISITES="true"
+HEADLESS_X_ORG_SERVER_PRE_COMMAND=
+HEADLESS_X_ORG_SERVER_COMMAND="echo"
+EOF
+
+}
+
+# Get the directory where the script is located and the parent.
+OUR_FOLDER="$(dirname "$0")"
+OUR_FOLDER=$(cd "${OUR_FOLDER}" && pwd)
+VBOX_FOLDER=$(cd "${OUR_FOLDER}/.." && pwd)
+[ -d "${VBOX_FOLDER}" ] ||
+ abort "Failed to change to directory ${VBOX_FOLDER}.\n"
+cd "${VBOX_FOLDER}"
+
+# Get our name for output.
+TEST_NAME="$(basename "$0" .sh)"
+
+# And remember the full path.
+TEST_NAME_FULL="${OUR_FOLDER}/$(basename "$0")"
+
+# Create a temporary directory for configuration and logging.
+TEST_FOLDER_BASE="/tmp/${TEST_NAME} 99/" # Space in the name to test quoting.
+if [ -n "${TESTBOX_PATH_SCRATCH}" ]; then
+ TEST_FOLDER_BASE="${TESTBOX_PATH_SCRATCH}/${TEST_NAME} 99/"
+fi
+{
+ rm -rf "${TEST_FOLDER_BASE}" 2>/dev/null &&
+ mkdir -m 0700 "${TEST_FOLDER_BASE}" 2>/dev/null
+} || abort "Could not create test folder (${TEST_FOLDER_BASE}).\n"
+
+###############################################################################
+# Simple start-up test. #
+###############################################################################
+print_line "simple start-up test"
+create_basic_configuration "${TEST_FOLDER_BASE}simple_start-up_test/"
+touch "${XORG_FOLDER}/xorg.conf.2"
+touch "${XORG_FOLDER}/xorg.conf.4"
+
+test_simple_start_up()
+{
+ STATUS="$1"
+ case "${STATUS}" in
+ 0)
+ LOG_FOLDER="${TEST_FOLDER}/log"
+ LOG="${LOG_FOLDER}/log"
+ if grep -q "2 ${XORG_FOLDER}/xorg.conf.2 ${LOG_FOLDER}/Xorg.2.log" "${LOG}" &&
+ grep -q "4 ${XORG_FOLDER}/xorg.conf.4 ${LOG_FOLDER}/Xorg.4.log" "${LOG}"; then
+ printf "SUCCESS.\n"
+ else
+ printf "\nFAILED: incorrect log output.\n"
+ fi
+ ;;
+ *)
+ printf "\nFAILED: exit status ${STATUS}.\n"
+ esac
+}
+
+scripts/VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}conf" &
+PID=$!
+expect_exit "${PID}" 5 test_simple_start_up
+
+###############################################################################
+# No configuration files. #
+###############################################################################
+create_basic_configuration "${TEST_FOLDER_BASE}no_configuration_files/"
+print_line "no configuration files"
+
+test_should_fail()
+{
+ STATUS="$1"
+ case "${STATUS}" in
+ 0)
+ printf "\nFAILED: successful exit when an error was expected.\n"
+ ;;
+ *)
+ printf "SUCCESS.\n" # At least it behaved the way we wanted.
+ esac
+}
+
+scripts/VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}conf" &
+PID=$!
+expect_exit "${PID}" 5 test_should_fail
+
+###############################################################################
+# Bad configuration files. #
+###############################################################################
+print_line "bad configuration files"
+create_basic_configuration "${TEST_FOLDER_BASE}bad_configuration_files/"
+touch "${XORG_FOLDER}/xorg.conf.2"
+touch "${XORG_FOLDER}/xorg.conf.4"
+touch "${XORG_FOLDER}/xorg.conf.other"
+scripts/VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}conf" &
+PID=$!
+expect_exit "${PID}" 5 test_should_fail
+
+###############################################################################
+# Long running server command. #
+###############################################################################
+
+# Set up a configuration file for a long-running command.
+create_basic_configuration "${TEST_FOLDER_BASE}long-running_command/"
+cat >> "${TEST_FOLDER}conf" << EOF
+HEADLESS_X_ORG_SERVER_COMMAND="${TEST_FOLDER}command.sh"
+EOF
+
+cat > "${TEST_FOLDER}command.sh" << EOF
+#!/bin/sh
+touch "${TEST_FOLDER}stopped"
+touch "${TEST_FOLDER}started"
+trap "touch \\"${TEST_FOLDER}stopped\\"; exit" TERM
+rm "${TEST_FOLDER}stopped"
+while true; do :; done
+EOF
+chmod a+x "${TEST_FOLDER}command.sh"
+
+print_line "long running server command"
+touch "${XORG_FOLDER}/xorg.conf.5"
+FAILURE=""
+scripts/VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}conf" &
+PID="$!"
+while [ ! -f "${TEST_FOLDER}started" ]; do :; done
+while [ -f "${TEST_FOLDER}stopped" ]; do :; done
+[ -n "${PID}" ] && kill "${PID}" 2>/dev/null
+while [ ! -f "${TEST_FOLDER}stopped" ]; do :; done
+printf "SUCCESS.\n"
+
+###############################################################################
+# Pre-requisite test. #
+###############################################################################
+
+# Set up a configuration file with a pre-requisite.
+create_basic_configuration "${TEST_FOLDER_BASE}pre-requisite/"
+cat >> "${TEST_FOLDER}conf" << EOF
+HEADLESS_X_ORG_WAIT_FOR_PREREQUISITES="false"
+EOF
+
+print_line "configuration file with failed pre-requisite"
+touch "${XORG_FOLDER}/xorg.conf.2"
+touch "${XORG_FOLDER}/xorg.conf.4"
+if scripts/VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}conf"; then
+ echo "\nFAILED to stop for failed pre-requisite.\n"
+else
+ echo "SUCCESS"
+fi
+
+###############################################################################
+# Pre-command test. #
+###############################################################################
+
+# Set up our pre-command test configuration file.
+create_basic_configuration "${TEST_FOLDER_BASE}pre-command/"
+
+cat >> "${TEST_FOLDER}conf" << EOF
+test_pre_command_server_pre_command()
+{
+ touch "${TEST_FOLDER}/run/pre"
+}
+test_pre_command_server_command()
+{
+ cp "${TEST_FOLDER}/run/pre" "${TEST_FOLDER}/run/pre2"
+}
+HEADLESS_X_ORG_SERVER_PRE_COMMAND="test_pre_command_server_pre_command"
+HEADLESS_X_ORG_SERVER_COMMAND="test_pre_command_server_command"
+EOF
+
+print_line "pre-command test"
+touch "${XORG_FOLDER}/xorg.conf.2"
+
+test_pre_command()
+{
+ STATUS="$1"
+ case "${STATUS}" in
+ 0)
+ LOG_FOLDER="${TEST_FOLDER}/log"
+ LOG="${LOG_FOLDER}/log"
+ if [ -e "${TEST_FOLDER}/run/pre" ] && [ -e "${TEST_FOLDER}/run/pre2" ]; then
+ printf "SUCCESS.\n"
+ else
+ printf "\nFAILED: pre-command not executed.\n"
+ fi
+ ;;
+ *)
+ printf "\nFAILED: exit status ${STATUS}.\n"
+ esac
+}
+
+rm -f "${TEST_FOLDER}/run/pre"
+scripts/VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}conf" &
+PID=$!
+expect_exit "${PID}" 5 test_pre_command
+
+###############################################################################
+# Post-command test. #
+###############################################################################
+
+# Set up our post-command test configuration file.
+create_basic_configuration "${TEST_FOLDER_BASE}post-command/"
+cat >> "${TEST_FOLDER}conf" << EOF
+test_post_command_post_command()
+{
+ echo "\${1}" > "${TEST_FOLDER}/run/post"
+}
+HEADLESS_X_ORG_SERVER_POST_COMMAND="test_post_command_post_command"
+EOF
+
+print_line "post-command test"
+touch "${XORG_FOLDER}/xorg.conf.2"
+touch "${XORG_FOLDER}/xorg.conf.4"
+
+test_post_command()
+{
+ STATUS="$1"
+ case "${STATUS}" in
+ 0)
+ LOG_FOLDER="${TEST_FOLDER}/log"
+ LOG="${LOG_FOLDER}/log"
+ if grep -q "2 4" "${TEST_FOLDER}/run/post"; then
+ printf "SUCCESS.\n"
+ else
+ printf "\nFAILED: post-command not executed.\n"
+ fi
+ ;;
+ *)
+ printf "\nFAILED: exit status ${STATUS}.\n"
+ esac
+}
+
+rm -f "${TEST_FOLDER}/run/post"
+scripts/VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}conf" &
+PID=$!
+expect_exit "${PID}" 5 test_post_command
diff --git a/src/VBox/Installer/linux/uninstall.sh b/src/VBox/Installer/linux/uninstall.sh
new file mode 100755
index 00000000..b182058b
--- /dev/null
+++ b/src/VBox/Installer/linux/uninstall.sh
@@ -0,0 +1,166 @@
+#!/bin/sh
+#
+# Oracle VM VirtualBox
+# VirtualBox linux uninstallation script
+
+#
+# Copyright (C) 2009-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+# The below is GNU-specific. See VBox.sh for the longer Solaris/OS X version.
+TARGET=`readlink -e -- "${0}"` || exit 1
+MY_PATH="${TARGET%/[!/]*}"
+. "${MY_PATH}/routines.sh"
+
+if [ -z "$ro_LOG_FILE" ]; then
+ create_log "/var/log/vbox-uninstall.log"
+fi
+
+if [ -z "VBOX_NO_UNINSTALL_MESSAGE" ]; then
+ info "Uninstalling VirtualBox"
+ log "Uninstalling VirtualBox"
+ log ""
+fi
+
+check_root
+
+[ -z "$CONFIG_DIR" ] && CONFIG_DIR="/etc/vbox"
+[ -z "$CONFIG" ] && CONFIG="vbox.cfg"
+[ -z "$CONFIG_FILES" ] && CONFIG_FILES="filelist"
+[ -z "$DEFAULT_FILES" ] && DEFAULT_FILES=`pwd`/deffiles
+
+# Find previous installation
+if [ -r "$CONFIG_DIR/$CONFIG" ]; then
+ . "$CONFIG_DIR/$CONFIG"
+ PREV_INSTALLATION="$INSTALL_DIR"
+fi
+
+# Remove previous installation
+if [ "$PREV_INSTALLATION" = "" ]; then
+ log "Unable to find a VirtualBox installation, giving up."
+ abort "Couldn't find a VirtualBox installation to uninstall."
+fi
+
+# Do pre-removal common to all installer types, currently service script
+# clean-up.
+"${MY_PATH}/prerm-common.sh" || exit 1
+
+# Remove kernel module installed
+if [ -z "$VBOX_DONT_REMOVE_OLD_MODULES" ]; then
+ rm -f "/usr/src/vboxhost-$INSTALL_VER" 2> /dev/null
+ rm -f "/usr/src/vboxdrv-$INSTALL_VER" 2> /dev/null
+ rm -f "/usr/src/vboxnetflt-$INSTALL_VER" 2> /dev/null
+ rm -f "/usr/src/vboxnetadp-$INSTALL_VER" 2> /dev/null
+ rm -f "/usr/src/vboxpci-$INSTALL_VER" 2> /dev/null
+fi
+
+# Remove symlinks
+rm -f \
+ /usr/bin/VirtualBox \
+ /usr/bin/VirtualBoxVM \
+ /usr/bin/VBoxManage \
+ /usr/bin/VBoxSDL \
+ /usr/bin/VBoxVRDP \
+ /usr/bin/VBoxHeadless \
+ /usr/bin/VBoxDTrace \
+ /usr/bin/VBoxAudioTest \
+ /usr/bin/VBoxBugReport \
+ /usr/bin/VBoxBalloonCtrl \
+ /usr/bin/VBoxAutostart \
+ /usr/bin/VBoxNetDHCP \
+ /usr/bin/VBoxNetNAT \
+ /usr/bin/vboxwebsrv \
+ /usr/bin/vbox-img \
+ /usr/bin/vboximg-mount \
+ /usr/bin/VBoxAddIF \
+ /usr/bin/VBoxDeleteIf \
+ /usr/bin/VBoxTunctl \
+ /usr/bin/virtualbox \
+ /usr/bin/virtualboxvm \
+ /usr/share/pixmaps/VBox.png \
+ /usr/share/pixmaps/virtualbox.png \
+ /usr/share/applications/virtualbox.desktop \
+ /usr/share/applications/virtualboxvm.desktop \
+ /usr/share/mime/packages/virtualbox.xml \
+ /usr/bin/rdesktop-vrdp \
+ /usr/bin/virtualbox \
+ /usr/bin/vboxmanage \
+ /usr/bin/vboxsdl \
+ /usr/bin/vboxheadless \
+ /usr/bin/vboxdtrace \
+ /usr/bin/vboxaudiotest \
+ /usr/bin/vboxbugreport \
+ "$PREV_INSTALLATION/components/VBoxVMM.so" \
+ "$PREV_INSTALLATION/components/VBoxREM.so" \
+ "$PREV_INSTALLATION/components/VBoxRT.so" \
+ "$PREV_INSTALLATION/components/VBoxDDU.so" \
+ "$PREV_INSTALLATION/components/VBoxXPCOM.so" \
+ "$PREV_INSTALLATION/VBoxREM.so" \
+ "$PREV_INSTALLATION/VBoxVRDP" \
+ "$PREV_INSTALLATION/VBoxVRDP.so" \
+ 2> /dev/null
+
+cwd=`pwd`
+if [ -f "$PREV_INSTALLATION/src/Makefile" ]; then
+ cd "$PREV_INSTALLATION/src"
+ make clean > /dev/null 2>&1
+fi
+if [ -f "$PREV_INSTALLATION/src/vboxdrv/Makefile" ]; then
+ cd "$PREV_INSTALLATION/src/vboxdrv"
+ make clean > /dev/null 2>&1
+fi
+if [ -f "$PREV_INSTALLATION/src/vboxnetflt/Makefile" ]; then
+ cd "$PREV_INSTALLATION/src/vboxnetflt"
+ make clean > /dev/null 2>&1
+fi
+if [ -f "$PREV_INSTALLATION/src/vboxnetadp/Makefile" ]; then
+ cd "$PREV_INSTALLATION/src/vboxnetadp"
+ make clean > /dev/null 2>&1
+fi
+if [ -f "$PREV_INSTALLATION/src/vboxpci/Makefile" ]; then
+ cd "$PREV_INSTALLATION/src/vboxpci"
+ make clean > /dev/null 2>&1
+fi
+cd "$PREV_INSTALLATION"
+if [ -r "$CONFIG_DIR/$CONFIG_FILES" ]; then
+ rm -f `cat "$CONFIG_DIR/$CONFIG_FILES"` 2> /dev/null
+elif [ -n "$DEFAULT_FILES" -a -r "$DEFAULT_FILES" ]; then
+ DEFAULT_FILE_NAMES=""
+ . "$DEFAULT_FILES"
+ rm -f $DEFAULT_FILE_NAMES 2> /dev/null
+fi
+for file in `find "$PREV_INSTALLATION" 2> /dev/null`; do
+ rmdir -p "$file" 2> /dev/null
+done
+cd "$cwd" 2> /dev/null
+mkdir -p "$PREV_INSTALLATION" 2> /dev/null # The above actually removes the current directory and parents!
+rmdir "$PREV_INSTALLATION" 2> /dev/null
+rm -f "$CONFIG_DIR/$CONFIG" 2> /dev/null
+rm -f "$CONFIG_DIR/$CONFIG_FILES" 2> /dev/null
+rmdir "$CONFIG_DIR" 2> /dev/null
+
+update-mime-database /usr/share/mime >/dev/null 2>&1
+
+if [ -z "$VBOX_NO_UNINSTALL_MESSAGE" ]; then
+ [ -n "$INSTALL_REV" ] && INSTALL_REV=" r$INSTALL_REV"
+ info "VirtualBox $INSTALL_VER$INSTALL_REV has been removed successfully."
+ log "Successfully $INSTALL_VER$INSTALL_REV removed VirtualBox."
+fi
diff --git a/src/VBox/Installer/linux/vboxautostart-service.sh b/src/VBox/Installer/linux/vboxautostart-service.sh
new file mode 100755
index 00000000..d41cfaf6
--- /dev/null
+++ b/src/VBox/Installer/linux/vboxautostart-service.sh
@@ -0,0 +1,184 @@
+#!/bin/sh
+# $Id: vboxautostart-service.sh $
+## @file
+# VirtualBox autostart service init script.
+#
+
+#
+# Copyright (C) 2012-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+# chkconfig: 345 35 65
+# description: VirtualBox autostart service
+#
+### BEGIN INIT INFO
+# Provides: vboxautostart-service
+# Required-Start: vboxdrv
+# Required-Stop: vboxdrv
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Description: VirtualBox autostart service
+### END INIT INFO
+
+PATH=$PATH:/bin:/sbin:/usr/sbin
+SCRIPTNAME=vboxautostart-service.sh
+
+[ -f /etc/debian_release -a -f /lib/lsb/init-functions ] || NOLSB=yes
+[ -f /etc/vbox/vbox.cfg ] && . /etc/vbox/vbox.cfg
+
+if [ -n "$INSTALL_DIR" ]; then
+ binary="$INSTALL_DIR/VBoxAutostart"
+else
+ binary="/usr/lib/virtualbox/VBoxAutostart"
+fi
+
+# silently exit if the package was uninstalled but not purged,
+# applies to Debian packages only (but shouldn't hurt elsewhere)
+[ ! -f /etc/debian_release -o -x $binary ] || exit 0
+
+[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
+
+# Preamble for Gentoo
+if [ "`which $0`" = "/sbin/rc" ]; then
+ shift
+fi
+
+begin_msg()
+{
+ test -n "${2}" && echo "${SCRIPTNAME}: ${1}."
+ logger -t "${SCRIPTNAME}" "${1}."
+}
+
+succ_msg()
+{
+ logger -t "${SCRIPTNAME}" "${1}."
+}
+
+fail_msg()
+{
+ echo "${SCRIPTNAME}: failed: ${1}." >&2
+ logger -t "${SCRIPTNAME}" "failed: ${1}."
+}
+
+start_daemon() {
+ usr="$1"
+ shift
+ su - $usr -c "$*"
+}
+
+if which start-stop-daemon >/dev/null 2>&1; then
+ start_daemon() {
+ usr="$1"
+ shift
+ bin="$1"
+ shift
+ start-stop-daemon --chuid $usr --start --exec $bin -- $@
+ }
+fi
+
+vboxdrvrunning() {
+ lsmod | grep -q "vboxdrv[^_-]"
+}
+
+valid_db_entry() {
+
+ entry="$1"
+ [ -z "$entry" ] && return 1
+
+ user="$2"
+ [ -z "$user" ] && return 1
+
+ user_name=$(id -n -u "$user" 2>/dev/null)
+ [ -z "$user_name" ] && return 1
+
+ user_id=$(id -u "$user" 2>/dev/null)
+
+ # Verify that @user identifies a user *by name* (i.e. not a numeric id).
+ # Careful, all numeric user names are legal.
+ if [ "$user_id" = "$user" ] && [ "$user_name" != "$user" ]; then
+ return 1
+ fi
+
+ # Verify whether file name is the same as file owner name.
+ [ -z "$(find "$entry" -user "$user" -type f 2>/dev/null)" ] && return 1
+
+ return 0
+}
+
+start() {
+ [ -z "$VBOXAUTOSTART_DB" ] && exit 0
+ [ -z "$VBOXAUTOSTART_CONFIG" ] && exit 0
+ begin_msg "Starting VirtualBox VMs configured for autostart" console;
+ vboxdrvrunning || {
+ fail_msg "VirtualBox kernel module not loaded!"
+ exit 0
+ }
+ PARAMS="--background --start --config $VBOXAUTOSTART_CONFIG"
+
+ # prevent inheriting this setting to VBoxSVC
+ unset VBOX_RELEASE_LOG_DEST
+
+ for entry in "$VBOXAUTOSTART_DB"/*.start
+ do
+ user=$(basename "$entry" .start)
+ [ "$user" = "*" ] && break
+ valid_db_entry "$entry" "$user" || continue
+
+ start_daemon "$user" "$binary" $PARAMS > /dev/null 2>&1
+ done
+
+ return $RETVAL
+}
+
+stop() {
+ [ -z "$VBOXAUTOSTART_DB" ] && exit 0
+ [ -z "$VBOXAUTOSTART_CONFIG" ] && exit 0
+
+ PARAMS="--stop --config $VBOXAUTOSTART_CONFIG"
+
+ # prevent inheriting this setting to VBoxSVC
+ unset VBOX_RELEASE_LOG_DEST
+
+ for entry in "$VBOXAUTOSTART_DB"/*.stop
+ do
+ user=$(basename "$entry" .stop)
+ [ "$user" = "*" ] && break
+ valid_db_entry "$entry" "$user" || continue
+
+ start_daemon "$user" "$binary" $PARAMS > /dev/null 2>&1
+ done
+
+ return $RETVAL
+}
+
+case "$1" in
+start)
+ start
+ ;;
+stop)
+ stop
+ ;;
+*)
+ echo "Usage: $0 {start|stop}"
+ exit 1
+esac
+
+exit $RETVAL
diff --git a/src/VBox/Installer/linux/vboxballoonctrl-service.sh b/src/VBox/Installer/linux/vboxballoonctrl-service.sh
new file mode 100755
index 00000000..832af64c
--- /dev/null
+++ b/src/VBox/Installer/linux/vboxballoonctrl-service.sh
@@ -0,0 +1,218 @@
+#!/bin/sh
+# $Id: vboxballoonctrl-service.sh $
+## @file
+# VirtualBox watchdog daemon init script.
+#
+
+#
+# Copyright (C) 2006-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+# chkconfig: 345 35 65
+# description: VirtualBox watchdog daemon
+#
+### BEGIN INIT INFO
+# Provides: vboxballoonctrl-service
+# Required-Start: vboxdrv
+# Required-Stop: vboxdrv
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Description: VirtualBox watchdog daemon
+### END INIT INFO
+
+PATH=$PATH:/bin:/sbin:/usr/sbin
+SCRIPTNAME=vboxballoonctrl-service.sh
+
+[ -f /etc/vbox/vbox.cfg ] && . /etc/vbox/vbox.cfg
+
+if [ -n "$INSTALL_DIR" ]; then
+ binary="$INSTALL_DIR/VBoxBalloonCtrl"
+else
+ binary="/usr/lib/virtualbox/VBoxBalloonCtrl"
+fi
+
+# silently exit if the package was uninstalled but not purged,
+# applies to Debian packages only (but shouldn't hurt elsewhere)
+[ ! -f /etc/debian_release -o -x $binary ] || exit 0
+
+[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
+
+PIDFILE="/var/run/${SCRIPTNAME}"
+
+# Preamble for Gentoo
+if [ "`which $0`" = "/sbin/rc" ]; then
+ shift
+fi
+
+begin_msg()
+{
+ test -n "${2}" && echo "${SCRIPTNAME}: ${1}."
+ logger -t "${SCRIPTNAME}" "${1}."
+}
+
+succ_msg()
+{
+ logger -t "${SCRIPTNAME}" "${1}."
+}
+
+fail_msg()
+{
+ echo "${SCRIPTNAME}: failed: ${1}." >&2
+ logger -t "${SCRIPTNAME}" "failed: ${1}."
+}
+
+start_daemon() {
+ usr="$1"
+ shift
+ su - $usr -c "$*"
+}
+
+killproc() {
+ killall $1
+ rm -f $PIDFILE
+}
+
+if which start-stop-daemon >/dev/null 2>&1; then
+ start_daemon() {
+ usr="$1"
+ shift
+ bin="$1"
+ shift
+ start-stop-daemon --background --chuid $usr --start --exec $bin -- $@
+ }
+
+ killproc() {
+ start-stop-daemon --stop --exec $@
+ }
+fi
+
+vboxdrvrunning() {
+ lsmod | grep -q "vboxdrv[^_-]"
+}
+
+check_single_user() {
+ if [ -n "$2" ]; then
+ fail_msg "VBOXWATCHDOG_USER must not contain multiple users!"
+ exit 1
+ fi
+}
+
+start() {
+ if ! test -f $PIDFILE; then
+ [ -z "$VBOXWATCHDOG_USER" -a -z "$VBOXBALLOONCTRL_USER" ] && exit 0
+ [ -z "$VBOXWATCHDOG_USER" ] && VBOXWATCHDOG_USER="$VBOXBALLOONCTRL_USER"
+ begin_msg "Starting VirtualBox watchdog service" console;
+ check_single_user $VBOXWATCHDOG_USER
+ vboxdrvrunning || {
+ fail_msg "VirtualBox kernel module not loaded!"
+ exit 0
+ }
+ # Handle legacy parameters, do not add any further ones unless absolutely necessary.
+ [ -z "$VBOXWATCHDOG_BALLOON_INTERVAL" -a -n "$VBOXBALLOONCTRL_INTERVAL" ] && VBOXWATCHDOG_BALLOON_INTERVAL="$VBOXBALLOONCTRL_INTERVAL"
+ [ -z "$VBOXWATCHDOG_BALLOON_INCREMENT" -a -n "$VBOXBALLOONCTRL_INCREMENT" ] && VBOXWATCHDOG_BALLOON_INCREMENT="$VBOXBALLOONCTRL_INCREMENT"
+ [ -z "$VBOXWATCHDOG_BALLOON_DECREMENT" -a -n "$VBOXBALLOONCTRL_DECREMENT" ] && VBOXWATCHDOG_BALLOON_DECREMENT="$VBOXBALLOONCTRL_DECREMENT"
+ [ -z "$VBOXWATCHDOG_BALLOON_LOWERLIMIT" -a -n "$VBOXBALLOONCTRL_LOWERLIMIT" ] && VBOXWATCHDOG_BALLOON_LOWERLIMIT="$VBOXBALLOONCTRL_LOWERLIMIT"
+ [ -z "$VBOXWATCHDOG_BALLOON_SAFETYMARGIN" -a -n "$VBOXBALLOONCTRL_SAFETYMARGIN" ] && VBOXWATCHDOG_BALLOON_SAFETYMARGIN="$VBOXBALLOONCTRL_SAFETYMARGIN"
+ [ -z "$VBOXWATCHDOG_ROTATE" -a -n "$VBOXBALLOONCTRL_ROTATE" ] && VBOXWATCHDOG_ROTATE="$VBOXBALLOONCTRL_ROTATE"
+ [ -z "$VBOXWATCHDOG_LOGSIZE" -a -n "$VBOXBALLOONCTRL_LOGSIZE" ] && VBOXWATCHDOG_LOGSIZE="$VBOXBALLOONCTRL_LOGSIZE"
+ [ -z "$VBOXWATCHDOG_LOGINTERVAL" -a -n "$VBOXBALLOONCTRL_LOGINTERVAL" ] && VBOXWATCHDOG_LOGINTERVAL="$VBOXBALLOONCTRL_LOGINTERVAL"
+
+ PARAMS="--background"
+ [ -n "$VBOXWATCHDOG_BALLOON_INTERVAL" ] && PARAMS="$PARAMS --balloon-interval \"$VBOXWATCHDOG_BALLOON_INTERVAL\""
+ [ -n "$VBOXWATCHDOG_BALLOON_INCREMENT" ] && PARAMS="$PARAMS --balloon-inc \"$VBOXWATCHDOG_BALLOON_INCREMENT\""
+ [ -n "$VBOXWATCHDOG_BALLOON_DECREMENT" ] && PARAMS="$PARAMS --balloon-dec \"$VBOXWATCHDOG_BALLOON_DECREMENT\""
+ [ -n "$VBOXWATCHDOG_BALLOON_LOWERLIMIT" ] && PARAMS="$PARAMS --balloon-lower-limit \"$VBOXWATCHDOG_BALLOON_LOWERLIMIT\""
+ [ -n "$VBOXWATCHDOG_BALLOON_SAFETYMARGIN" ] && PARAMS="$PARAMS --balloon-safety-margin \"$VBOXWATCHDOG_BALLOON_SAFETYMARGIN\""
+ [ -n "$VBOXWATCHDOG_ROTATE" ] && PARAMS="$PARAMS -R \"$VBOXWATCHDOG_ROTATE\""
+ [ -n "$VBOXWATCHDOG_LOGSIZE" ] && PARAMS="$PARAMS -S \"$VBOXWATCHDOG_LOGSIZE\""
+ [ -n "$VBOXWATCHDOG_LOGINTERVAL" ] && PARAMS="$PARAMS -I \"$VBOXWATCHDOG_LOGINTERVAL\""
+ # prevent inheriting this setting to VBoxSVC
+ unset VBOX_RELEASE_LOG_DEST
+ start_daemon $VBOXWATCHDOG_USER $binary $PARAMS > /dev/null 2>&1
+ # ugly: wait until the final process has forked
+ sleep .1
+ PID=`pidof $binary 2>/dev/null`
+ if [ -n "$PID" ]; then
+ echo "$PID" > $PIDFILE
+ RETVAL=0
+ succ_msg "VirtualBox watchdog service started"
+ else
+ RETVAL=1
+ fail_msg "VirtualBox watchdog service failed to start"
+ fi
+ fi
+ return $RETVAL
+}
+
+stop() {
+ if test -f $PIDFILE; then
+ begin_msg "Stopping VirtualBox watchdog service" console;
+ killproc $binary
+ RETVAL=$?
+ if ! pidof $binary > /dev/null 2>&1; then
+ rm -f $PIDFILE
+ succ_msg "VirtualBox watchdog service stopped"
+ else
+ fail_msg "VirtualBox watchdog service failed to stop"
+ fi
+ fi
+ return $RETVAL
+}
+
+restart() {
+ stop && start
+}
+
+status() {
+ echo -n "Checking for VBox watchdog service"
+ if [ -f $PIDFILE ]; then
+ echo " ...running"
+ else
+ echo " ...not running"
+ fi
+}
+
+case "$1" in
+start)
+ start
+ ;;
+stop)
+ stop
+ ;;
+restart)
+ restart
+ ;;
+force-reload)
+ restart
+ ;;
+status)
+ status
+ ;;
+setup)
+ ;;
+cleanup)
+ ;;
+*)
+ echo "Usage: $0 {start|stop|restart|status}"
+ exit 1
+esac
+
+exit $RETVAL
diff --git a/src/VBox/Installer/linux/vboxdrv.sh b/src/VBox/Installer/linux/vboxdrv.sh
new file mode 100755
index 00000000..4077c169
--- /dev/null
+++ b/src/VBox/Installer/linux/vboxdrv.sh
@@ -0,0 +1,899 @@
+#! /bin/sh
+# Oracle VM VirtualBox
+# Linux kernel module init script
+
+#
+# Copyright (C) 2006-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+# chkconfig: 345 20 80
+# description: VirtualBox Linux kernel module
+#
+### BEGIN INIT INFO
+# Provides: vboxdrv
+# Required-Start: $syslog
+# Required-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: VirtualBox Linux kernel module
+### END INIT INFO
+
+## @todo This file duplicates a lot of script with vboxadd.sh. When making
+# changes please try to reduce differences between the two wherever possible.
+
+## @todo Remove the stop_vms target so that this script is only relevant to
+# kernel modules. Nice but not urgent.
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin:$PATH
+DEVICE=/dev/vboxdrv
+MODPROBE=/sbin/modprobe
+SCRIPTNAME=vboxdrv.sh
+
+# The below is GNU-specific. See VBox.sh for the longer Solaris/OS X version.
+TARGET=`readlink -e -- "${0}"` || exit 1
+SCRIPT_DIR="${TARGET%/[!/]*}"
+
+if $MODPROBE -c | grep -q '^allow_unsupported_modules *0'; then
+ MODPROBE="$MODPROBE --allow-unsupported-modules"
+fi
+
+setup_log()
+{
+ test -n "${LOG}" && return 0
+ # Rotate log files
+ LOG="/var/log/vbox-setup.log"
+ mv "${LOG}.3" "${LOG}.4" 2>/dev/null
+ mv "${LOG}.2" "${LOG}.3" 2>/dev/null
+ mv "${LOG}.1" "${LOG}.2" 2>/dev/null
+ mv "${LOG}" "${LOG}.1" 2>/dev/null
+}
+
+[ -f /etc/vbox/vbox.cfg ] && . /etc/vbox/vbox.cfg
+export VBOX_KBUILD_TYPE
+export USERNAME
+export USER=$USERNAME
+
+if test -n "${INSTALL_DIR}" && test -x "${INSTALL_DIR}/VirtualBox"; then
+ MODULE_SRC="${INSTALL_DIR}/src/vboxhost"
+elif test -x /usr/lib/virtualbox/VirtualBox; then
+ INSTALL_DIR=/usr/lib/virtualbox
+ MODULE_SRC="/usr/share/virtualbox/src/vboxhost"
+elif test -x "${SCRIPT_DIR}/VirtualBox"; then
+ # Executing from the build directory
+ INSTALL_DIR="${SCRIPT_DIR}"
+ MODULE_SRC="${INSTALL_DIR}/src"
+else
+ # Silently exit if the package was uninstalled but not purged.
+ # Applies to Debian packages only (but shouldn't hurt elsewhere)
+ exit 0
+fi
+VIRTUALBOX="${INSTALL_DIR}/VirtualBox"
+VBOXMANAGE="${INSTALL_DIR}/VBoxManage"
+BUILDINTMP="${MODULE_SRC}/build_in_tmp"
+if test -u "${VIRTUALBOX}"; then
+ GROUP=root
+ DEVICE_MODE=0600
+else
+ GROUP=vboxusers
+ DEVICE_MODE=0660
+fi
+
+KERN_VER=`uname -r`
+
+# Prepend PATH for building UEK7 on OL8 distribution.
+case "$KERN_VER" in
+ 5.15.0-*.el8uek*) PATH="/opt/rh/gcc-toolset-11/root/usr/bin:$PATH";;
+esac
+
+if test -e "${MODULE_SRC}/vboxpci"; then
+ MODULE_LIST="vboxdrv vboxnetflt vboxnetadp vboxpci"
+else
+ MODULE_LIST="vboxdrv vboxnetflt vboxnetadp"
+fi
+# Secure boot state.
+case "`mokutil --sb-state 2>/dev/null`" in
+ *"disabled in shim"*) unset HAVE_SEC_BOOT;;
+ *"SecureBoot enabled"*) HAVE_SEC_BOOT=true;;
+ *) unset HAVE_SEC_BOOT;;
+esac
+# So far we can only sign modules on Ubuntu and on Debian 10 and later.
+DEB_PUB_KEY=/var/lib/shim-signed/mok/MOK.der
+DEB_PRIV_KEY=/var/lib/shim-signed/mok/MOK.priv
+unset HAVE_DEB_KEY
+case "`mokutil --test-key "$DEB_PUB_KEY" 2>/dev/null`" in
+ *"is already"*) DEB_KEY_ENROLLED=true;;
+ *) unset DEB_KEY_ENROLLED;;
+esac
+
+# Try to find a tool for modules signing.
+SIGN_TOOL=$(which kmodsign 2>/dev/null)
+# Attempt to use in-kernel signing tool if kmodsign not found.
+if test -z "$SIGN_TOOL"; then
+ if test -x "/lib/modules/$KERN_VER/build/scripts/sign-file"; then
+ SIGN_TOOL="/lib/modules/$KERN_VER/build/scripts/sign-file"
+ fi
+fi
+
+# Check if update-secureboot-policy tool supports required commandline options.
+update_secureboot_policy_supports()
+{
+ opt_name="$1"
+ [ -n "$opt_name" ] || return
+
+ [ -z "$(update-secureboot-policy --help 2>&1 | grep "$opt_name")" ] && return
+ echo "1"
+}
+
+HAVE_UPDATE_SECUREBOOT_POLICY_TOOL=
+if type update-secureboot-policy >/dev/null 2>&1; then
+ [ "$(update_secureboot_policy_supports new-key)" = "1" -a "$(update_secureboot_policy_supports enroll-key)" = "1" ] && \
+ HAVE_UPDATE_SECUREBOOT_POLICY_TOOL=true
+fi
+
+[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
+
+# Preamble for Gentoo
+if [ "`which $0`" = "/sbin/rc" ]; then
+ shift
+fi
+
+begin_msg()
+{
+ test -n "${2}" && echo "${SCRIPTNAME}: ${1}."
+ logger -t "${SCRIPTNAME}" "${1}."
+}
+
+succ_msg()
+{
+ logger -t "${SCRIPTNAME}" "${1}."
+}
+
+fail_msg()
+{
+ echo "${SCRIPTNAME}: failed: ${1}." >&2
+ logger -t "${SCRIPTNAME}" "failed: ${1}."
+}
+
+failure()
+{
+ fail_msg "$1"
+ exit 1
+}
+
+running()
+{
+ lsmod | grep -q "$1[^_-]"
+}
+
+log()
+{
+ setup_log
+ echo "${1}" >> "${LOG}"
+}
+
+module_build_log()
+{
+ setup_log
+ echo "${1}" | egrep -v \
+ "^test -e include/generated/autoconf.h|^echo >&2|^/bin/false\)$" \
+ >> "${LOG}"
+}
+
+# Detect VirtualBox version info or report error.
+VBOX_VERSION="`"$VBOXMANAGE" -v | cut -d r -f1`"
+[ -n "$VBOX_VERSION" ] || failure 'Cannot detect VirtualBox version number'
+VBOX_REVISION="r`"$VBOXMANAGE" -v | cut -d r -f2`"
+[ "$VBOX_REVISION" != "r" ] || failure 'Cannot detect VirtualBox revision number'
+
+## Output the vboxdrv part of our udev rule. This is redirected to the right file.
+udev_write_vboxdrv() {
+ VBOXDRV_GRP="$1"
+ VBOXDRV_MODE="$2"
+
+ echo "KERNEL==\"vboxdrv\", OWNER=\"root\", GROUP=\"$VBOXDRV_GRP\", MODE=\"$VBOXDRV_MODE\""
+ echo "KERNEL==\"vboxdrvu\", OWNER=\"root\", GROUP=\"root\", MODE=\"0666\""
+ echo "KERNEL==\"vboxnetctl\", OWNER=\"root\", GROUP=\"$VBOXDRV_GRP\", MODE=\"$VBOXDRV_MODE\""
+}
+
+## Output the USB part of our udev rule. This is redirected to the right file.
+udev_write_usb() {
+ INSTALLATION_DIR="$1"
+ USB_GROUP="$2"
+
+ echo "SUBSYSTEM==\"usb_device\", ACTION==\"add\", RUN+=\"$INSTALLATION_DIR/VBoxCreateUSBNode.sh \$major \$minor \$attr{bDeviceClass}${USB_GROUP}\""
+ echo "SUBSYSTEM==\"usb\", ACTION==\"add\", ENV{DEVTYPE}==\"usb_device\", RUN+=\"$INSTALLATION_DIR/VBoxCreateUSBNode.sh \$major \$minor \$attr{bDeviceClass}${USB_GROUP}\""
+ echo "SUBSYSTEM==\"usb_device\", ACTION==\"remove\", RUN+=\"$INSTALLATION_DIR/VBoxCreateUSBNode.sh --remove \$major \$minor\""
+ echo "SUBSYSTEM==\"usb\", ACTION==\"remove\", ENV{DEVTYPE}==\"usb_device\", RUN+=\"$INSTALLATION_DIR/VBoxCreateUSBNode.sh --remove \$major \$minor\""
+}
+
+## Generate our udev rule file. This takes a change in udev rule syntax in
+## version 55 into account. It only creates rules for USB for udev versions
+## recent enough to support USB device nodes.
+generate_udev_rule() {
+ VBOXDRV_GRP="$1" # The group owning the vboxdrv device
+ VBOXDRV_MODE="$2" # The access mode for the vboxdrv device
+ INSTALLATION_DIR="$3" # The directory VirtualBox is installed in
+ USB_GROUP="$4" # The group that has permission to access USB devices
+ NO_INSTALL="$5" # Set this to "1" to remove but not re-install rules
+
+ # Extra space!
+ case "$USB_GROUP" in ?*) USB_GROUP=" $USB_GROUP" ;; esac
+ case "$NO_INSTALL" in "1") return ;; esac
+ udev_write_vboxdrv "$VBOXDRV_GRP" "$VBOXDRV_MODE"
+ udev_write_usb "$INSTALLATION_DIR" "$USB_GROUP"
+}
+
+## Install udev rule (disable with INSTALL_NO_UDEV=1 in
+## /etc/default/virtualbox).
+install_udev() {
+ VBOXDRV_GRP="$1" # The group owning the vboxdrv device
+ VBOXDRV_MODE="$2" # The access mode for the vboxdrv device
+ INSTALLATION_DIR="$3" # The directory VirtualBox is installed in
+ USB_GROUP="$4" # The group that has permission to access USB devices
+ NO_INSTALL="$5" # Set this to "1" to remove but not re-install rules
+
+ if test -d /etc/udev/rules.d; then
+ generate_udev_rule "$VBOXDRV_GRP" "$VBOXDRV_MODE" "$INSTALLATION_DIR" \
+ "$USB_GROUP" "$NO_INSTALL"
+ fi
+ # Remove old udev description file
+ rm -f /etc/udev/rules.d/10-vboxdrv.rules 2> /dev/null
+}
+
+## Create a usb device node for a given sysfs path to a USB device.
+install_create_usb_node_for_sysfs() {
+ path="$1" # sysfs path for the device
+ usb_createnode="$2" # Path to the USB device node creation script
+ usb_group="$3" # The group to give ownership of the node to
+ if test -r "${path}/dev"; then
+ dev="`cat "${path}/dev" 2> /dev/null`"
+ major="`expr "$dev" : '\(.*\):' 2> /dev/null`"
+ minor="`expr "$dev" : '.*:\(.*\)' 2> /dev/null`"
+ class="`cat ${path}/bDeviceClass 2> /dev/null`"
+ sh "${usb_createnode}" "$major" "$minor" "$class" \
+ "${usb_group}" 2>/dev/null
+ fi
+}
+
+udev_rule_file=/etc/udev/rules.d/60-vboxdrv.rules
+sysfs_usb_devices="/sys/bus/usb/devices/*"
+
+## Install udev rules and create device nodes for usb access
+setup_usb() {
+ VBOXDRV_GRP="$1" # The group that should own /dev/vboxdrv
+ VBOXDRV_MODE="$2" # The mode to be used for /dev/vboxdrv
+ INSTALLATION_DIR="$3" # The directory VirtualBox is installed in
+ USB_GROUP="$4" # The group that should own the /dev/vboxusb device
+ # nodes unless INSTALL_NO_GROUP=1 in
+ # /etc/default/virtualbox. Optional.
+ usb_createnode="$INSTALLATION_DIR/VBoxCreateUSBNode.sh"
+ # install udev rule (disable with INSTALL_NO_UDEV=1 in
+ # /etc/default/virtualbox)
+ if [ "$INSTALL_NO_GROUP" != "1" ]; then
+ usb_group=$USB_GROUP
+ vboxdrv_group=$VBOXDRV_GRP
+ else
+ usb_group=root
+ vboxdrv_group=root
+ fi
+ install_udev "${vboxdrv_group}" "$VBOXDRV_MODE" \
+ "$INSTALLATION_DIR" "${usb_group}" \
+ "$INSTALL_NO_UDEV" > ${udev_rule_file}
+ # Build our device tree
+ for i in ${sysfs_usb_devices}; do # This line intentionally without quotes.
+ install_create_usb_node_for_sysfs "$i" "${usb_createnode}" \
+ "${usb_group}"
+ done
+}
+
+cleanup_usb()
+{
+ # Remove udev description file
+ rm -f /etc/udev/rules.d/60-vboxdrv.rules
+ rm -f /etc/udev/rules.d/10-vboxdrv.rules
+
+ # Remove our USB device tree
+ rm -rf /dev/vboxusb
+}
+
+# Returns path to module file as seen by modinfo(8) or empty string.
+module_path()
+{
+ mod="$1"
+ [ -n "$mod" ] || return
+
+ modinfo "$mod" 2>/dev/null | grep -e "^filename:" | tr -s ' ' | cut -d " " -f2
+}
+
+# Returns module version if module is available or empty string.
+module_version()
+{
+ mod="$1"
+ [ -n "$mod" ] || return
+
+ modinfo "$mod" 2>/dev/null | grep -e "^version:" | tr -s ' ' | cut -d " " -f2
+}
+
+# Returns module revision if module is available in the system or empty string.
+module_revision()
+{
+ mod="$1"
+ [ -n "$mod" ] || return
+
+ modinfo "$mod" 2>/dev/null | grep -e "^version:" | tr -s ' ' | cut -d " " -f3
+}
+
+# Reads kernel configuration option.
+kernel_get_config_opt()
+{
+ opt_name="$1"
+ [ -n "$opt_name" ] || return
+
+ # Check if there is a kernel tool which can extract config option.
+ if test -x /lib/modules/"$KERN_VER"/build/scripts/config; then
+ /lib/modules/"$KERN_VER"/build/scripts/config \
+ --file /lib/modules/"$KERN_VER"/build/.config \
+ --state "$opt_name" 2>/dev/null
+ elif test -f /lib/modules/"$KERN_VER"/build/.config; then
+ # Extract config option manually.
+ grep "$opt_name=" /lib/modules/"$KERN_VER"/build/.config | sed -e "s/^$opt_name=//" -e "s/\"//g"
+ fi
+}
+
+# Reads CONFIG_MODULE_SIG_HASH from kernel config.
+kernel_module_sig_hash()
+{
+ kernel_get_config_opt "CONFIG_MODULE_SIG_HASH"
+}
+
+# Returns "1" if kernel module signature hash algorithm
+# is supported by us. Or empty string otherwise.
+module_sig_hash_supported()
+{
+ sig_hashalgo="$1"
+ [ -n "$sig_hashalgo" ] || return
+
+ # Go through supported list.
+ [ "$sig_hashalgo" = "sha1" \
+ -o "$sig_hashalgo" = "sha224" \
+ -o "$sig_hashalgo" = "sha256" \
+ -o "$sig_hashalgo" = "sha384" \
+ -o "$sig_hashalgo" = "sha512" ] || return
+
+ echo "1"
+}
+
+# Check if kernel configuration requires modules signature.
+kernel_requires_module_signature()
+{
+ vbox_sys_lockdown_path="/sys/kernel/security/lockdown"
+
+ requires=""
+ # We consider that if kernel is running in the following configurations,
+ # it will require modules to be signed.
+ if [ "$(kernel_get_config_opt "CONFIG_MODULE_SIG")" = "y" ]; then
+
+ # Modules signature verification is hardcoded in kernel config.
+ [ "$(kernel_get_config_opt "CONFIG_MODULE_SIG_FORCE")" = "y" ] && requires="1"
+
+ # Unsigned modules loading is restricted by "lockdown" feature in runtime.
+ if [ "$(kernel_get_config_opt "CONFIG_LOCK_DOWN_KERNEL")" = "y" \
+ -o "$(kernel_get_config_opt "CONFIG_SECURITY_LOCKDOWN_LSM")" = "y" \
+ -o "$(kernel_get_config_opt "CONFIG_SECURITY_LOCKDOWN_LSM_EARLY")" = "y" ]; then
+
+ # Once lockdown level is set to something different than "none" (e.g., "integrity"
+ # or "confidentiality"), kernel will reject unsigned modules loading.
+ if [ -r "$vbox_sys_lockdown_path" ]; then
+ [ -n "$(cat "$vbox_sys_lockdown_path" | grep "\[integrity\]")" ] && requires="1"
+ [ -n "$(cat "$vbox_sys_lockdown_path" | grep "\[confidentiality\]")" ] && requires="1"
+ fi
+
+ # This configuration is used by a number of modern Linux distributions and restricts
+ # unsigned modules loading when Secure Boot mode is enabled.
+ [ "$(kernel_get_config_opt "CONFIG_LOCK_DOWN_IN_EFI_SECURE_BOOT")" = "y" -a -n "$HAVE_SEC_BOOT" ] && requires="1"
+ fi
+ fi
+
+ [ -n "$requires" ] && echo "1"
+}
+
+# Returns "1" if module is signed and signature can be verified
+# with public key provided in DEB_PUB_KEY. Or empty string otherwise.
+module_signed()
+{
+ mod="$1"
+ [ -n "$mod" ] || return
+
+ # Be nice with distributions which do not provide tools which we
+ # use in order to verify module signature. This variable needs to
+ # be explicitly set by administrator. This script will look for it
+ # in /etc/vbox/vbox.cfg. Make sure that you know what you do!
+ if [ "$VBOX_BYPASS_MODULES_SIGNATURE_CHECK" = "1" ]; then
+ echo "1"
+ return
+ fi
+
+ extraction_tool=/lib/modules/"$(uname -r)"/build/scripts/extract-module-sig.pl
+ mod_path=$(module_path "$mod" 2>/dev/null)
+ openssl_tool=$(which openssl 2>/dev/null)
+ # Do not use built-in printf!
+ printf_tool=$(which printf 2>/dev/null)
+
+ # Make sure all the tools required for signature validation are available.
+ [ -x "$extraction_tool" ] || return
+ [ -n "$mod_path" ] || return
+ [ -n "$openssl_tool" ] || return
+ [ -n "$printf_tool" ] || return
+
+ # Make sure openssl can handle hash algorithm.
+ sig_hashalgo=$(modinfo -F sig_hashalgo "$mod" 2>/dev/null)
+ [ "$(module_sig_hash_supported $sig_hashalgo)" = "1" ] || return
+
+ # Generate file names for temporary stuff.
+ mod_pub_key=$(mktemp -u)
+ mod_signature=$(mktemp -u)
+ mod_unsigned=$(mktemp -u)
+
+ # Convert public key in DER format into X509 certificate form.
+ "$openssl_tool" x509 -pubkey -inform DER -in "$DEB_PUB_KEY" -out "$mod_pub_key" 2>/dev/null
+ # Extract raw module signature and convert it into binary format.
+ "$printf_tool" \\x$(modinfo -F signature "$mod" | sed -z 's/[ \t\n]//g' | sed -e "s/:/\\\x/g") 2>/dev/null > "$mod_signature"
+ # Extract unsigned module for further digest calculation.
+ "$extraction_tool" -0 "$mod_path" 2>/dev/null > "$mod_unsigned"
+
+ # Verify signature.
+ rc=""
+ "$openssl_tool" dgst "-$sig_hashalgo" -binary -verify "$mod_pub_key" -signature "$mod_signature" "$mod_unsigned" 2>&1 >/dev/null && rc="1"
+ # Clean up.
+ rm -f $mod_pub_key $mod_signature $mod_unsigned
+
+ # Check result.
+ [ "$rc" = "1" ] || return
+
+ echo "1"
+}
+
+# Returns "1" if externally built module is available in the system and its
+# version and revision number do match to current VirtualBox installation.
+# Or empty string otherwise.
+module_available()
+{
+ mod="$1"
+ [ -n "$mod" ] || return
+
+ [ "$VBOX_VERSION" = "$(module_version "$mod")" ] || return
+ [ "$VBOX_REVISION" = "$(module_revision "$mod")" ] || return
+
+ # Check if module belongs to VirtualBox installation.
+ #
+ # We have a convention that only modules from /lib/modules/*/misc
+ # belong to us. Modules from other locations are treated as
+ # externally built.
+ mod_path="$(module_path "$mod")"
+
+ # If module path points to a symbolic link, resolve actual file location.
+ [ -L "$mod_path" ] && mod_path="$(readlink -e -- "$mod_path")"
+
+ # File exists?
+ [ -f "$mod_path" ] || return
+
+ # Extract last component of module path and check whether it is located
+ # outside of /lib/modules/*/misc.
+ mod_dir="$(dirname "$mod_path" | sed 's;^.*/;;')"
+ [ "$mod_dir" = "misc" ] || return
+
+ # In case if kernel configuration requires module signature, check if module is signed.
+ if test "$(kernel_requires_module_signature)" = "1"; then
+ [ "$(module_signed "$mod")" = "1" ] || return
+ fi
+
+ echo "1"
+}
+
+# Check if required modules are installed in the system and versions match.
+setup_complete()
+{
+ [ "$(module_available vboxdrv)" = "1" ] || return
+ [ "$(module_available vboxnetflt)" = "1" ] || return
+ [ "$(module_available vboxnetadp)" = "1" ] || return
+
+ # All modules are in place.
+ echo "1"
+}
+
+start()
+{
+ begin_msg "Starting VirtualBox services" console
+ if [ -d /proc/xen ]; then
+ failure "Running VirtualBox in a Xen environment is not supported"
+ fi
+ if test "$(kernel_requires_module_signature)" = "1" && test -z "$DEB_KEY_ENROLLED"; then
+ if test -n "$HAVE_DEB_KEY"; then
+ begin_msg "You must re-start your system to finish Debian secure boot set-up." console
+ else
+ begin_msg "You must sign these kernel modules before using VirtualBox:
+ $MODULE_LIST
+See the documentation for your Linux distribution." console
+ fi
+ fi
+
+ if ! running vboxdrv; then
+
+ # Check if system already has matching modules installed.
+ [ "$(setup_complete)" = "1" ] || setup
+
+ if ! rm -f $DEVICE; then
+ failure "Cannot remove $DEVICE"
+ fi
+ if ! $MODPROBE vboxdrv > /dev/null 2>&1; then
+ failure "modprobe vboxdrv failed. Please use 'dmesg' to find out why"
+ fi
+ sleep .2
+ fi
+ # ensure the character special exists
+ if [ ! -c $DEVICE ]; then
+ MAJOR=`sed -n 's;\([0-9]\+\) vboxdrv$;\1;p' /proc/devices`
+ if [ ! -z "$MAJOR" ]; then
+ MINOR=0
+ else
+ MINOR=`sed -n 's;\([0-9]\+\) vboxdrv$;\1;p' /proc/misc`
+ if [ ! -z "$MINOR" ]; then
+ MAJOR=10
+ fi
+ fi
+ if [ -z "$MAJOR" ]; then
+ rmmod vboxdrv 2>/dev/null
+ failure "Cannot locate the VirtualBox device"
+ fi
+ if ! mknod -m 0660 $DEVICE c $MAJOR $MINOR 2>/dev/null; then
+ rmmod vboxdrv 2>/dev/null
+ failure "Cannot create device $DEVICE with major $MAJOR and minor $MINOR"
+ fi
+ fi
+ # ensure permissions
+ if ! chown :"${GROUP}" $DEVICE 2>/dev/null; then
+ rmmod vboxpci 2>/dev/null
+ rmmod vboxnetadp 2>/dev/null
+ rmmod vboxnetflt 2>/dev/null
+ rmmod vboxdrv 2>/dev/null
+ failure "Cannot change group ${GROUP} for device $DEVICE"
+ fi
+ if ! $MODPROBE vboxnetflt > /dev/null 2>&1; then
+ failure "modprobe vboxnetflt failed. Please use 'dmesg' to find out why"
+ fi
+ if ! $MODPROBE vboxnetadp > /dev/null 2>&1; then
+ failure "modprobe vboxnetadp failed. Please use 'dmesg' to find out why"
+ fi
+ if test -e "${MODULE_SRC}/vboxpci" && ! $MODPROBE vboxpci > /dev/null 2>&1; then
+ failure "modprobe vboxpci failed. Please use 'dmesg' to find out why"
+ fi
+ # Create the /dev/vboxusb directory if the host supports that method
+ # of USB access. The USB code checks for the existence of that path.
+ if grep -q usb_device /proc/devices; then
+ mkdir -p -m 0750 /dev/vboxusb 2>/dev/null
+ chown root:vboxusers /dev/vboxusb 2>/dev/null
+ fi
+ # Remove any kernel modules left over from previously installed kernels.
+ cleanup only_old
+ succ_msg "VirtualBox services started"
+}
+
+stop()
+{
+ begin_msg "Stopping VirtualBox services" console
+
+ if running vboxpci; then
+ if ! rmmod vboxpci 2>/dev/null; then
+ failure "Cannot unload module vboxpci"
+ fi
+ fi
+ if running vboxnetadp; then
+ if ! rmmod vboxnetadp 2>/dev/null; then
+ failure "Cannot unload module vboxnetadp"
+ fi
+ fi
+ if running vboxdrv; then
+ if running vboxnetflt; then
+ if ! rmmod vboxnetflt 2>/dev/null; then
+ failure "Cannot unload module vboxnetflt"
+ fi
+ fi
+ if ! rmmod vboxdrv 2>/dev/null; then
+ failure "Cannot unload module vboxdrv"
+ fi
+ if ! rm -f $DEVICE; then
+ failure "Cannot unlink $DEVICE"
+ fi
+ fi
+ succ_msg "VirtualBox services stopped"
+}
+
+# enter the following variables in /etc/default/virtualbox:
+# SHUTDOWN_USERS="foo bar"
+# check for running VMs of user foo and user bar
+# SHUTDOWN=poweroff
+# SHUTDOWN=acpibutton
+# SHUTDOWN=savestate
+# select one of these shutdown methods for running VMs
+stop_vms()
+{
+ wait=0
+ for i in $SHUTDOWN_USERS; do
+ # don't create the ipcd directory with wrong permissions!
+ if [ -d /tmp/.vbox-$i-ipc ]; then
+ export VBOX_IPC_SOCKETID="$i"
+ VMS=`$VBOXMANAGE --nologo list runningvms | sed -e 's/^".*".*{\(.*\)}/\1/' 2>/dev/null`
+ if [ -n "$VMS" ]; then
+ if [ "$SHUTDOWN" = "poweroff" ]; then
+ begin_msg "Powering off remaining VMs"
+ for v in $VMS; do
+ $VBOXMANAGE --nologo controlvm $v poweroff
+ done
+ succ_msg "Remaining VMs powered off"
+ elif [ "$SHUTDOWN" = "acpibutton" ]; then
+ begin_msg "Sending ACPI power button event to remaining VMs"
+ for v in $VMS; do
+ $VBOXMANAGE --nologo controlvm $v acpipowerbutton
+ wait=30
+ done
+ succ_msg "ACPI power button event sent to remaining VMs"
+ elif [ "$SHUTDOWN" = "savestate" ]; then
+ begin_msg "Saving state of remaining VMs"
+ for v in $VMS; do
+ $VBOXMANAGE --nologo controlvm $v savestate
+ done
+ succ_msg "State of remaining VMs saved"
+ fi
+ fi
+ fi
+ done
+ # wait for some seconds when doing ACPI shutdown
+ if [ "$wait" -ne 0 ]; then
+ begin_msg "Waiting for $wait seconds for VM shutdown"
+ sleep $wait
+ succ_msg "Waited for $wait seconds for VM shutdown"
+ fi
+}
+
+cleanup()
+{
+ # If this is set, only remove kernel modules for no longer installed
+ # kernels. Note that only generated kernel modules should be placed
+ # in /lib/modules/*/misc. Anything that we should not remove automatically
+ # should go elsewhere.
+ only_old="${1}"
+ for i in /lib/modules/*; do
+ # Check whether we are only cleaning up for uninstalled kernels.
+ test -n "${only_old}" && test -e "${i}/kernel/drivers" && continue
+
+ unset do_update
+ for j in $MODULE_LIST; do
+ for mod_ext in ko ko.gz ko.xz ko.zst; do
+ test -f "${i}/misc/${j}.${mod_ext}" && do_update=1 && rm -f "${i}/misc/${j}.${mod_ext}"
+ done
+ done
+
+ # Trigger depmod(8) only in case if directory content was modified
+ # and save a bit of run time.
+ test -n "$do_update" && depmod -a "$(basename "$i")" && sync
+
+ # 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.
+ done
+}
+
+# setup_script
+setup()
+{
+ begin_msg "Building VirtualBox kernel modules" console
+ log "Building the main VirtualBox module."
+
+ # Detect if kernel was built with clang.
+ unset LLVM
+ vbox_cc_is_clang=$(kernel_get_config_opt "CONFIG_CC_IS_CLANG")
+ if test "${vbox_cc_is_clang}" = "y"; then
+ log "Using clang compiler."
+ export LLVM=1
+ fi
+
+ if ! myerr=`$BUILDINTMP \
+ --save-module-symvers /tmp/vboxdrv-Module.symvers \
+ --module-source "$MODULE_SRC/vboxdrv" \
+ --no-print-directory install 2>&1`; then
+ "${INSTALL_DIR}/check_module_dependencies.sh" || exit 1
+ log "Error building the module:"
+ module_build_log "$myerr"
+ failure "Look at $LOG to find out what went wrong"
+ fi
+ log "Building the net filter module."
+ if ! myerr=`$BUILDINTMP \
+ --use-module-symvers /tmp/vboxdrv-Module.symvers \
+ --module-source "$MODULE_SRC/vboxnetflt" \
+ --no-print-directory install 2>&1`; then
+ log "Error building the module:"
+ module_build_log "$myerr"
+ failure "Look at $LOG to find out what went wrong"
+ fi
+ log "Building the net adapter module."
+ if ! myerr=`$BUILDINTMP \
+ --use-module-symvers /tmp/vboxdrv-Module.symvers \
+ --module-source "$MODULE_SRC/vboxnetadp" \
+ --no-print-directory install 2>&1`; then
+ log "Error building the module:"
+ module_build_log "$myerr"
+ failure "Look at $LOG to find out what went wrong"
+ fi
+ if test -e "$MODULE_SRC/vboxpci"; then
+ log "Building the PCI pass-through module."
+ if ! myerr=`$BUILDINTMP \
+ --use-module-symvers /tmp/vboxdrv-Module.symvers \
+ --module-source "$MODULE_SRC/vboxpci" \
+ --no-print-directory install 2>&1`; then
+ log "Error building the module:"
+ module_build_log "$myerr"
+ failure "Look at $LOG to find out what went wrong"
+ fi
+ fi
+ rm -f /etc/vbox/module_not_compiled
+ depmod -a
+ sync
+ succ_msg "VirtualBox kernel modules built"
+
+ # Sign kernel modules if kernel configuration requires it.
+ if test "$(kernel_requires_module_signature)" = "1"; then
+ begin_msg "Signing VirtualBox kernel modules" console
+
+ # Generate new signing key if needed.
+ [ -n "$HAVE_UPDATE_SECUREBOOT_POLICY_TOOL" ] && SHIM_NOTRIGGER=y update-secureboot-policy --new-key
+
+ # Check if signing keys are in place.
+ if test ! -f "$DEB_PUB_KEY" || ! test -f "$DEB_PRIV_KEY"; then
+ # update-secureboot-policy tool present in the system, but keys were not generated.
+ [ -n "$HAVE_UPDATE_SECUREBOOT_POLICY_TOOL" ] && fail_msg "
+
+update-secureboot-policy tool does not generate signing keys
+in your distribution, see below on how to generate them manually
+"
+
+ # update-secureboot-policy not present in the system, recommend generate keys manually.
+ failure "
+
+System is running in Secure Boot mode, however your distribution
+does not provide tools for automatic generation of keys needed for
+modules signing. Please consider to generate and enroll them manually:
+
+ sudo mkdir -p /var/lib/shim-signed/mok
+ sudo openssl req -nodes -new -x509 -newkey rsa:2048 -outform DER -addext \"extendedKeyUsage=codeSigning\" -keyout $DEB_PRIV_KEY -out $DEB_PUB_KEY
+ sudo mokutil --import $DEB_PUB_KEY
+ sudo reboot
+
+Restart \"rcvboxdrv setup\" after system is rebooted
+"
+ fi
+
+ # Check if signing tool is available.
+ [ -n "$SIGN_TOOL" ] || failure "Unable to find signing tool"
+
+ # Get kernel signature hash algorithm from kernel config and validate it.
+ sig_hashalgo=$(kernel_module_sig_hash)
+ [ "$(module_sig_hash_supported $sig_hashalgo)" = "1" ] \
+ || failure "Unsupported kernel signature hash algorithm $sig_hashalgo"
+
+ # Sign modules.
+ for i in $MODULE_LIST; do
+ "$SIGN_TOOL" "$sig_hashalgo" "$DEB_PRIV_KEY" "$DEB_PUB_KEY" \
+ /lib/modules/"$KERN_VER"/misc/"$i".ko 2>/dev/null || failure "Unable to sign $i.ko"
+ done
+
+ # Enroll signing key if needed.
+ if test -n "$HAVE_UPDATE_SECUREBOOT_POLICY_TOOL"; then
+ # update-secureboot-policy "expects" DKMS modules.
+ # Work around this and talk to the authors as soon
+ # as possible to fix it.
+ mkdir -p /var/lib/dkms/vbox-temp
+ update-secureboot-policy --enroll-key 2>/dev/null ||
+ begin_msg "Failed to enroll secure boot key." console
+ rmdir -p /var/lib/dkms/vbox-temp 2>/dev/null
+
+ # Indicate that key has been enrolled and reboot is needed.
+ HAVE_DEB_KEY=true
+ fi
+ succ_msg "Signing completed"
+ fi
+}
+
+dmnstatus()
+{
+ if running vboxdrv; then
+ str="vboxdrv"
+ if running vboxnetflt; then
+ str="$str, vboxnetflt"
+ if running vboxnetadp; then
+ str="$str, vboxnetadp"
+ fi
+ fi
+ if running vboxpci; then
+ str="$str, vboxpci"
+ fi
+ echo "VirtualBox kernel modules ($str) are loaded."
+ for i in $SHUTDOWN_USERS; do
+ # don't create the ipcd directory with wrong permissions!
+ if [ -d /tmp/.vbox-$i-ipc ]; then
+ export VBOX_IPC_SOCKETID="$i"
+ VMS=`$VBOXMANAGE --nologo list runningvms | sed -e 's/^".*".*{\(.*\)}/\1/' 2>/dev/null`
+ if [ -n "$VMS" ]; then
+ echo "The following VMs are currently running:"
+ for v in $VMS; do
+ echo " $v"
+ done
+ fi
+ fi
+ done
+ else
+ echo "VirtualBox kernel module is not loaded."
+ fi
+}
+
+case "$1" in
+start)
+ start
+ ;;
+stop)
+ stop_vms
+ stop
+ ;;
+stop_vms)
+ stop_vms
+ ;;
+restart)
+ stop && start
+ ;;
+setup)
+ test -n "${2}" && export KERN_VER="${2}"
+ # Create udev rule and USB device nodes.
+ ## todo Wouldn't it make more sense to install the rule to /lib/udev? This
+ ## is not a user-created configuration file after all.
+ ## todo Do we need a udev rule to create /dev/vboxdrv[u] at all? We have
+ ## working fall-back code here anyway, and the "right" code is more complex
+ ## than the fall-back. Unnecessary duplication?
+ stop && cleanup
+ setup_usb "$GROUP" "$DEVICE_MODE" "$INSTALL_DIR"
+ start
+ ;;
+cleanup)
+ stop && cleanup
+ cleanup_usb
+ ;;
+force-reload)
+ stop
+ start
+ ;;
+status)
+ dmnstatus
+ ;;
+*)
+ echo "Usage: $0 {start|stop|stop_vms|restart|setup|cleanup|force-reload|status}"
+ exit 1
+esac
+
+exit 0
diff --git a/src/VBox/Installer/linux/vboxweb-service.sh b/src/VBox/Installer/linux/vboxweb-service.sh
new file mode 100755
index 00000000..3e259170
--- /dev/null
+++ b/src/VBox/Installer/linux/vboxweb-service.sh
@@ -0,0 +1,234 @@
+#!/bin/sh
+# $Id: vboxweb-service.sh $
+## @file
+# VirtualBox web service API daemon init script.
+#
+
+#
+# Copyright (C) 2006-2023 Oracle and/or its affiliates.
+#
+# This file is part of VirtualBox base platform packages, as
+# available from https://www.virtualbox.org.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, in version 3 of the
+# License.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <https://www.gnu.org/licenses>.
+#
+# SPDX-License-Identifier: GPL-3.0-only
+#
+
+# chkconfig: 345 35 65
+# description: VirtualBox web service API
+#
+### BEGIN INIT INFO
+# Provides: vboxweb-service
+# Required-Start: vboxdrv
+# Required-Stop: vboxdrv
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Description: VirtualBox web service API
+# X-Required-Target-Start: network-online
+### END INIT INFO
+
+PATH=$PATH:/bin:/sbin:/usr/sbin
+SCRIPTNAME=vboxweb-service.sh
+
+[ -f /etc/vbox/vbox.cfg ] && . /etc/vbox/vbox.cfg
+
+if [ -n "$INSTALL_DIR" ]; then
+ binary="$INSTALL_DIR/vboxwebsrv"
+ vboxmanage="$INSTALL_DIR/VBoxManage"
+else
+ binary="/usr/lib/virtualbox/vboxwebsrv"
+ vboxmanage="/usr/lib/virtualbox/VBoxManage"
+fi
+
+# silently exit if the package was uninstalled but not purged,
+# applies to Debian packages only (but shouldn't hurt elsewhere)
+[ ! -f /etc/debian_release -o -x $binary ] || exit 0
+
+[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
+
+PIDFILE="/var/run/${SCRIPTNAME}"
+
+# Preamble for Gentoo
+if [ "`which $0`" = "/sbin/rc" ]; then
+ shift
+fi
+
+begin_msg()
+{
+ test -n "${2}" && echo "${SCRIPTNAME}: ${1}."
+ logger -t "${SCRIPTNAME}" "${1}."
+}
+
+succ_msg()
+{
+ logger -t "${SCRIPTNAME}" "${1}."
+}
+
+fail_msg()
+{
+ echo "${SCRIPTNAME}: failed: ${1}." >&2
+ logger -t "${SCRIPTNAME}" "failed: ${1}."
+}
+
+start_daemon() {
+ usr="$1"
+ shift
+ su - $usr -c "$*"
+}
+
+killproc() {
+ killall $1
+ rm -f $PIDFILE
+}
+
+if which start-stop-daemon >/dev/null 2>&1; then
+ start_daemon() {
+ usr="$1"
+ shift
+ bin="$1"
+ shift
+ start-stop-daemon --background --chuid $usr --start --exec $bin -- $@
+ }
+
+ killproc() {
+ start-stop-daemon --stop --exec $@
+ }
+fi
+
+vboxdrvrunning() {
+ lsmod | grep -q "vboxdrv[^_-]"
+}
+
+check_single_user() {
+ if [ -n "$2" ]; then
+ fail_msg "VBOXWEB_USER must not contain multiple users!"
+ exit 1
+ fi
+}
+
+start() {
+ if ! test -f $PIDFILE; then
+ [ -z "$VBOXWEB_USER" ] && exit 0
+ begin_msg "Starting VirtualBox web service" console;
+ check_single_user $VBOXWEB_USER
+ vboxdrvrunning || {
+ fail_msg "VirtualBox kernel module not loaded!"
+ exit 0
+ }
+ PARAMS="--background"
+ [ -n "$VBOXWEB_HOST" ] && PARAMS="$PARAMS -H $VBOXWEB_HOST"
+ [ -n "$VBOXWEB_PORT" ] && PARAMS="$PARAMS -p $VBOXWEB_PORT"
+ [ -n "$VBOXWEB_SSL_KEYFILE" ] && PARAMS="$PARAMS -s -K $VBOXWEB_SSL_KEYFILE"
+ [ -n "$VBOXWEB_SSL_PASSWORDFILE" ] && PARAMS="$PARAMS -a $VBOXWEB_SSL_PASSWORDFILE"
+ [ -n "$VBOXWEB_SSL_CACERT" ] && PARAMS="$PARAMS -c $VBOXWEB_SSL_CACERT"
+ [ -n "$VBOXWEB_SSL_CAPATH" ] && PARAMS="$PARAMS -C $VBOXWEB_SSL_CAPATH"
+ [ -n "$VBOXWEB_SSL_DHFILE" ] && PARAMS="$PARAMS -D $VBOXWEB_SSL_DHFILE"
+ [ -n "$VBOXWEB_SSL_RANDFILE" ] && PARAMS="$PARAMS -r $VBOXWEB_SSL_RANDFILE"
+ [ -n "$VBOXWEB_TIMEOUT" ] && PARAMS="$PARAMS -t $VBOXWEB_TIMEOUT"
+ [ -n "$VBOXWEB_CHECK_INTERVAL" ] && PARAMS="$PARAMS -i $VBOXWEB_CHECK_INTERVAL"
+ [ -n "$VBOXWEB_THREADS" ] && PARAMS="$PARAMS -T $VBOXWEB_THREADS"
+ [ -n "$VBOXWEB_KEEPALIVE" ] && PARAMS="$PARAMS -k $VBOXWEB_KEEPALIVE"
+ [ -n "$VBOXWEB_AUTHENTICATION" ] && PARAMS="$PARAMS -A $VBOXWEB_AUTHENTICATION"
+ [ -n "$VBOXWEB_LOGFILE" ] && PARAMS="$PARAMS -F $VBOXWEB_LOGFILE"
+ [ -n "$VBOXWEB_ROTATE" ] && PARAMS="$PARAMS -R $VBOXWEB_ROTATE"
+ [ -n "$VBOXWEB_LOGSIZE" ] && PARAMS="$PARAMS -S $VBOXWEB_LOGSIZE"
+ [ -n "$VBOXWEB_LOGINTERVAL" ] && PARAMS="$PARAMS -I $VBOXWEB_LOGINTERVAL"
+ # set authentication method + password hash
+ if [ -n "$VBOXWEB_AUTH_LIBRARY" ]; then
+ su - "$VBOXWEB_USER" -c "$vboxmanage setproperty websrvauthlibrary \"$VBOXWEB_AUTH_LIBRARY\""
+ if [ $? -ne 0 ]; then
+ fail_msg "Error $? setting webservice authentication library to $VBOXWEB_AUTH_LIBRARY"
+ fi
+ fi
+ if [ -n "$VBOXWEB_AUTH_PWHASH" ]; then
+ su - "$VBOXWEB_USER" -c "$vboxmanage setextradata global \"VBoxAuthSimple/users/$VBOXWEB_USER\" \"$VBOXWEB_AUTH_PWHASH\""
+ if [ $? -ne 0 ]; then
+ fail_msg "Error $? setting webservice password hash"
+ fi
+ fi
+ # prevent inheriting this setting to VBoxSVC
+ unset VBOX_RELEASE_LOG_DEST
+ start_daemon $VBOXWEB_USER $binary $PARAMS > /dev/null 2>&1
+ # ugly: wait until the final process has forked
+ sleep .1
+ PID=`pidof $binary 2>/dev/null`
+ if [ -n "$PID" ]; then
+ echo "$PID" > $PIDFILE
+ RETVAL=0
+ succ_msg "VirtualBox web service started"
+ else
+ RETVAL=1
+ fail_msg "VirtualBox web service failed to start"
+ fi
+ fi
+ return $RETVAL
+}
+
+stop() {
+ if test -f $PIDFILE; then
+ begin_msg "Stopping VirtualBox web service" console;
+ killproc $binary
+ RETVAL=$?
+ # Be careful: wait 1 second, making sure that everything is cleaned up.
+ sleep 1
+ if ! pidof $binary > /dev/null 2>&1; then
+ rm -f $PIDFILE
+ succ_msg "VirtualBox web service stopped"
+ else
+ fail_msg "VirtualBox web service failed to stop"
+ fi
+ fi
+ return $RETVAL
+}
+
+restart() {
+ stop && start
+}
+
+status() {
+ echo -n "Checking for VBox Web Service"
+ if [ -f $PIDFILE ]; then
+ echo " ...running"
+ else
+ echo " ...not running"
+ fi
+}
+
+case "$1" in
+start)
+ start
+ ;;
+stop)
+ stop
+ ;;
+restart)
+ restart
+ ;;
+force-reload)
+ restart
+ ;;
+status)
+ status
+ ;;
+setup)
+ ;;
+cleanup)
+ ;;
+*)
+ echo "Usage: $0 {start|stop|restart|status}"
+ exit 1
+esac
+
+exit $RETVAL