git: 66635b2061da - main - emulators/virtualbox-ose: Put vbox/networks.conf in the right place

From: Guido Falsi <madpilot_at_FreeBSD.org>
Date: Fri, 11 Mar 2022 21:51:50 UTC
The branch main has been updated by madpilot:

URL: https://cgit.FreeBSD.org/ports/commit/?id=66635b2061daf5993d8bbf80457ee59946d91da4

commit 66635b2061daf5993d8bbf80457ee59946d91da4
Author:     Michael Gmelin <grembo@FreeBSD.org>
AuthorDate: 2022-03-11 21:44:02 +0000
Commit:     Guido Falsi <madpilot@FreeBSD.org>
CommitDate: 2022-03-11 21:51:31 +0000

    emulators/virtualbox-ose: Put vbox/networks.conf in the right place
    
    Since virtualbox-ose 6.1.26 a new networks.conf file has been
    introduced and the software looks for it in /etc/vbox.
    
    This commit introduces a patch to make virtualbox look for it in
    PREFIX/etc/vbox.
    
    To help users with configurations already using this file in /etc/vbox
    notes to UPDATING, pkg-message and to the main virtualbox executable
    script have been added.
    
    Also adding some comments to the Makefile to note that QA warning
    due to reinplace being run but not having changed any file are
    expected due to the design of this port Makefile.
    
    PR:             261522
---
 UPDATING                                                  |  8 ++++++++
 emulators/virtualbox-ose/Makefile                         |  6 ++++++
 .../files/patch-src-VBox-Installer-freebsd-VBox.sh        | 13 ++++++++++---
 .../patch-src_VBox_HostDrivers_adpctl_VBoxNetAdpCtl.cpp   | 11 +++++++++++
 .../virtualbox-ose/{pkg-message => files/pkg-message.in}  | 15 +++++++++++++++
 5 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/UPDATING b/UPDATING
index c8e7bc2e9d04..2e49b7de64a4 100644
--- a/UPDATING
+++ b/UPDATING
@@ -5,6 +5,14 @@ they are unavoidable.
 You should get into the habit of checking this file for changes each time
 you update your ports collection, before attempting any port upgrades.
 
+20220311:
+  AFFECTS: users of emulators/virtualbox-ose
+  AUTHOR: grembo@FreeBSD.org
+
+  In order to comply to hier(7), VirtualBox's configuration of non-default
+  IP ranges to be used in host-only mode moved from /etc/vbox/networks.conf
+  to ${LOCALBASE}/etc/vbox/networks.conf.
+
 20220311:
   AFFECTS: users of net/nats-server
   AUTHOR: olgeni@FreeBSD.org
diff --git a/emulators/virtualbox-ose/Makefile b/emulators/virtualbox-ose/Makefile
index c308bb20cee7..b1c34f71bd68 100644
--- a/emulators/virtualbox-ose/Makefile
+++ b/emulators/virtualbox-ose/Makefile
@@ -2,6 +2,7 @@
 
 PORTNAME=	virtualbox-ose
 PORTVERSION=	6.1.32
+PORTREVISION=	1
 CATEGORIES=	emulators
 MASTER_SITES=	https://download.virtualbox.org/virtualbox/${PORTVERSION}/
 DISTFILES=	VirtualBox-${PORTVERSION}${EXTRACT_SUFX} ${GUESTADDITIONS}
@@ -52,6 +53,8 @@ VBOX_PROGS=	VBoxAutostart VBoxBalloonCtrl VBoxBugReport VBoxHeadless \
 VBOX_UTILS=	VBoxExtPackHelperApp VBoxNetAdpCtl VBoxNetDHCP VBoxNetNAT \
 		VBoxSVC VBoxXPCOMIPCD
 
+SUB_FILES=	pkg-message
+
 OPTIONS_DEFINE=	AIO ALSA DBUS DEBUG GUESTADDITIONS MANUAL NLS OPUS PULSEAUDIO \
 		PYTHON QT5 R0LOGGING UDPTUNNEL VDE VNC WEBSERVICE VPX X11
 OPTIONS_DEFAULT=	AIO DBUS QT5 UDPTUNNEL VNC WEBSERVICE X11
@@ -307,10 +310,12 @@ post-patch:
 	    ${LOCALBASE}/share/kBuild/tools/GXX3.kmk > \
 	    ${WRKSRC}/tools/kBuildTools/VBoxGccFreeBSD.kmk
 .endif
+	# Causes a "reinplace" QA warning with default LOCALBASE
 	@${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|g' \
 	    ${WRKSRC}/Config.kmk ${WRKSRC}/configure \
 	    ${WRKSRC}/kBuild/header.kmk ${WRKSRC}/kBuild/units/qt4.kmk \
 	    ${WRKSRC}/kBuild/units/qt5.kmk ${WRKSRC}/kBuild/sdks/LIBSDL.kmk \
+	    ${WRKSRC}/src/VBox/HostDrivers/adpctl/VBoxNetAdpCtl.cpp \
 	    ${WRKSRC}/src/libs/xpcom18a4/python/gen_python_deps.py
 	@${REINPLACE_CMD} \
 	    -e 's|\$$KBUILDDIR_BIN/kmk_sed|${LOCALBASE}/bin/kmk_sed|g' \
@@ -321,6 +326,7 @@ post-patch:
 	    ${WRKSRC}/src/VBox/Runtime/Makefile.kmk
 	@${ECHO_CMD} 'VBOX_ICONV_DEFS = LIBICONV_PLUG' >> ${WRKSRC}/LocalConfig.kmk
 .endif
+	# Causes a "reinplace" QA warning with default PREFIX/VBOX_DIR
 	@${REINPLACE_CMD} -e 's|/usr/local/lib/virtualbox|${VBOX_DIR}|' \
 	    -e 's|/usr/local|${PREFIX}|' \
 	    ${WRKSRC}/src/VBox/Installer/freebsd/VBox.sh
diff --git a/emulators/virtualbox-ose/files/patch-src-VBox-Installer-freebsd-VBox.sh b/emulators/virtualbox-ose/files/patch-src-VBox-Installer-freebsd-VBox.sh
index deb51288deb1..6511a665a219 100644
--- a/emulators/virtualbox-ose/files/patch-src-VBox-Installer-freebsd-VBox.sh
+++ b/emulators/virtualbox-ose/files/patch-src-VBox-Installer-freebsd-VBox.sh
@@ -1,6 +1,6 @@
 --- src/VBox/Installer/freebsd/VBox.sh.orig	2016-08-27 05:10:34 UTC
 +++ src/VBox/Installer/freebsd/VBox.sh
-@@ -0,0 +1,67 @@
+@@ -0,0 +1,74 @@
 +#!/bin/sh
 +#
 +# Oracle VM VirtualBox startup script, FreeBSD hosts.
@@ -26,10 +26,17 @@
 +        test -f /usr/local/lib/virtualbox/VBoxRT.so; then
 +        INSTALL_DIR=/usr/local/lib/virtualbox
 +    else
-+        echo "Could not find VirtualBox installation. Please reinstall."
++        >&2 echo "Could not find VirtualBox installation. Please reinstall."
 +        exit 1
 +    fi
 +
++if [ -d /etc/vbox ]; then
++    >&2 cat <<-EOH
++	WARNING: Directory /etc/vbox found, but ignored. VirtualBox
++	         configuration files are stored in /usr/local/etc/vbox/.
++	EOH
++fi
++
 +# workaround for the KDE dialog problem
 +KDE_FORK_SLAVES=1; export KDE_FORK_SLAVES
 +
@@ -63,7 +70,7 @@
 +        exec "$INSTALL_DIR/vboxwebsrv" "$@"
 +        ;;
 +    *)
-+        echo "Unknown application - $APP"
++        >&2 echo "Unknown application - $APP"
 +        exit 1
 +        ;;
 +esac
diff --git a/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_adpctl_VBoxNetAdpCtl.cpp b/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_adpctl_VBoxNetAdpCtl.cpp
new file mode 100644
index 000000000000..dfd9105f8390
--- /dev/null
+++ b/emulators/virtualbox-ose/files/patch-src_VBox_HostDrivers_adpctl_VBoxNetAdpCtl.cpp
@@ -0,0 +1,11 @@
+--- src/VBox/HostDrivers/adpctl/VBoxNetAdpCtl.cpp.orig	2022-01-13 18:57:40 UTC
++++ src/VBox/HostDrivers/adpctl/VBoxNetAdpCtl.cpp
+@@ -737,7 +737,7 @@ int Adapter::doIOCtl(unsigned long iCmd, VBOXNETADPREQ
+ *   Global config file implementation                                                                                            *
+ *********************************************************************************************************************************/
+ 
+-#define VBOX_GLOBAL_NETWORK_CONFIG_PATH "/etc/vbox/networks.conf"
++#define VBOX_GLOBAL_NETWORK_CONFIG_PATH "/usr/local/etc/vbox/networks.conf"
+ #define VBOXNET_DEFAULT_IPV4MASK "255.255.255.0"
+ 
+ class NetworkAddress
diff --git a/emulators/virtualbox-ose/pkg-message b/emulators/virtualbox-ose/files/pkg-message.in
similarity index 79%
rename from emulators/virtualbox-ose/pkg-message
rename to emulators/virtualbox-ose/files/pkg-message.in
index 20fa96d594fa..8df5a0a47ffd 100644
--- a/emulators/virtualbox-ose/pkg-message
+++ b/emulators/virtualbox-ose/files/pkg-message.in
@@ -60,6 +60,10 @@ vfs.aio.max_aio_per_proc=8192
 vfs.aio.max_aio_queue=65536
 To check if AIO is used use: kldstat -v | grep aio
 
+When assigning IP addresses in host-only mode from ranges outside
+of VirtualBox's defaults, the respective ranges need to be listed
+in %%LOCALBASE%%/etc/vbox/networks.conf (PR#259399).
+
 Check wiki page for known issues and troubleshooting:
 http://wiki.freebsd.org/VirtualBox
 
@@ -78,4 +82,15 @@ machines using the Pulseaudio host audio driver to use another
 supported one.
 EOM
 }
+{ type: upgrade
+  minimum_version: 6.1.26
+  maximum_version: 6.1.32_1
+  message: <<EOM
+To comply to hier(7) requirements, networks.conf's location changed
+to %%LOCALBASE%%/etc/vbox/networks.conf.
+
+In case /etc/vbox/networks.conf exists, it needs to be moved to
+%%LOCALBASE%%/etc/vbox and /etc/vbox should be deleted.
+EOM
+}
 ]