mirror of
https://github.com/Ponce/slackbuilds
synced 2024-11-25 10:03:03 +01:00
e8f0d7f02a
Signed-off-by: Heinz Wiesinger <pprkut@slackbuilds.org> Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
293 lines
12 KiB
Diff
293 lines
12 KiB
Diff
--- vboxdrv.sh.orig 2021-10-18 19:58:10.000000000 +0200
|
|
+++ vboxdrv.sh 2021-10-30 20:36:29.483575169 +0200
|
|
@@ -61,23 +61,8 @@
|
|
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
|
|
@@ -148,131 +133,12 @@
|
|
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\", NAME=\"vboxdrv\", OWNER=\"root\", GROUP=\"$VBOXDRV_GRP\", MODE=\"$VBOXDRV_MODE\""
|
|
- echo "KERNEL==\"vboxdrvu\", NAME=\"vboxdrvu\", OWNER=\"root\", GROUP=\"root\", MODE=\"0666\""
|
|
- echo "KERNEL==\"vboxnetctl\", NAME=\"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()
|
|
{
|
|
@@ -415,8 +281,6 @@
|
|
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"
|
|
}
|
|
|
|
@@ -497,102 +361,10 @@
|
|
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
|
|
- # We could just do "rm -f", but we only want to try deleting folders if
|
|
- # we are sure they were ours, i.e. they had our modules in beforehand.
|
|
- if test -e "${i}/misc/vboxdrv.ko" \
|
|
- || test -e "${i}/misc/vboxnetadp.ko" \
|
|
- || test -e "${i}/misc/vboxnetflt.ko" \
|
|
- || test -e "${i}/misc/vboxpci.ko"; then
|
|
- rm -f "${i}/misc/vboxdrv.ko" "${i}/misc/vboxnetadp.ko" \
|
|
- "${i}/misc/vboxnetflt.ko" "${i}/misc/vboxpci.ko"
|
|
- version=`expr "${i}" : "/lib/modules/\(.*\)"`
|
|
- depmod -a "${version}"
|
|
- sync
|
|
- fi
|
|
- # 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."
|
|
- 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 adaptor 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"
|
|
- # Secure boot on Ubuntu and Debian.
|
|
- if test -n "$HAVE_SEC_BOOT" &&
|
|
- type update-secureboot-policy >/dev/null 2>&1; then
|
|
- SHIM_NOTRIGGER=y update-secureboot-policy --new-key
|
|
- fi
|
|
- if test -f "$DEB_PUB_KEY" && test -f "$DEB_PRIV_KEY"; then
|
|
- HAVE_DEB_KEY=true
|
|
- for i in $MODULE_LIST; do
|
|
- kmodsign sha512 /var/lib/shim-signed/mok/MOK.priv \
|
|
- /var/lib/shim-signed/mok/MOK.der \
|
|
- /lib/modules/"$KERN_VER"/misc/"$i".ko
|
|
- done
|
|
- # 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
|
|
- fi
|
|
+ echo "Not implemented! Please use the virtualbox-kernel.SlackBuild available at SlackBuilds.org instead."
|
|
}
|
|
|
|
dmnstatus()
|
|
@@ -642,20 +414,7 @@
|
|
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
|
|
+ setup
|
|
;;
|
|
force-reload)
|
|
stop
|