git: 6c5da516ce5b - main - emulators/virtualbox-ose: add option to build vboximg-mount

From: Eugene Grosbein <eugen_at_FreeBSD.org>
Date: Thu, 16 Nov 2023 11:06:02 UTC
The branch main has been updated by eugen:

URL: https://cgit.FreeBSD.org/ports/commit/?id=6c5da516ce5b8ec11e70c5b433e7164c14453d0a

commit 6c5da516ce5b8ec11e70c5b433e7164c14453d0a
Author:     Eugene Grosbein <eugen@FreeBSD.org>
AuthorDate: 2023-11-16 11:05:14 +0000
Commit:     Eugene Grosbein <eugen@FreeBSD.org>
CommitDate: 2023-11-16 11:05:42 +0000

    emulators/virtualbox-ose: add option to build vboximg-mount
    
    Introduce new port option VBOXIMG that enables building and installing
    "vboximg-mount" utility. It is not enabled by default as it needs
    fusesfs-libs as another dependency.
    
    The utility gives access to insides of VM images like .vdi files etc.
    Use "vboximg-mount -g" to get access to files on internal file systems
    not supported by native FreeBSD mount command. Refer to utility's
    internal online help for syntax details and to original documentation:
    
    https://docs.oracle.com/en/virtualization/virtualbox/6.0/user/vboximg-mount.html
    
    PR:             274817
    Tested by:      vvd
    Approved by:    vbox (maintainer timeout over 2 weeks)
---
 emulators/virtualbox-ose/Makefile                      | 18 ++++++++++++++++--
 .../virtualbox-ose/files/extrapatch-vboximg-Config.kmk | 11 +++++++++++
 emulators/virtualbox-ose/pkg-plist                     |  2 ++
 3 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/emulators/virtualbox-ose/Makefile b/emulators/virtualbox-ose/Makefile
index 47975da886fc..2d0d0538b210 100644
--- a/emulators/virtualbox-ose/Makefile
+++ b/emulators/virtualbox-ose/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	virtualbox-ose
 PORTVERSION=	6.1.48
-PORTREVISION?=	0
+PORTREVISION?=	1
 CATEGORIES=	emulators
 MASTER_SITES=	https://download.virtualbox.org/virtualbox/${PORTVERSION}/
 DISTFILES=	VirtualBox-${PORTVERSION}${EXTRACT_SUFX} ${GUESTADDITIONS}
@@ -58,7 +58,7 @@ VBOX_UTILS=	VBoxExtPackHelperApp VBoxNetAdpCtl VBoxNetDHCP VBoxNetNAT \
 SUB_FILES=	pkg-message
 
 OPTIONS_DEFINE=		AIO ALSA DBUS DEBUG DOCS GUESTADDITIONS NLS OPUS PULSEAUDIO \
-			PYTHON QT5 R0LOGGING UDPTUNNEL VDE VNC WEBSERVICE VPX X11
+			PYTHON QT5 R0LOGGING UDPTUNNEL VBOXIMG VDE VNC WEBSERVICE VPX X11
 OPTIONS_DEFAULT=	AIO DBUS QT5 UDPTUNNEL VNC WEBSERVICE X11
 # Since version 6.1.24 pulseaudio is broken at runtime, preventing
 # virtual machines from starting if configured to use it.
@@ -73,6 +73,7 @@ OPUS_DESC=		Use libvpx for audio recording (requires VPX)
 QT5_DESC=		Build with QT5 frontend (requires X11)
 R0LOGGING_DESC=		Enable R0 logging (requires DEBUG)
 UDPTUNNEL_DESC=		Build with UDP tunnel support
+VBOXIMG_DESC=		Build vboximg-mount (requires fuse-libs)
 VDE_DESC=		Build with VDE support
 VNC_DESC=		Build with VNC support
 VPX_DESC=		Use libvpx for video recording
@@ -108,6 +109,7 @@ QT5_CONFIGURE_OFF=	--disable-qt
 QT5_IMPLIES=		X11
 R0LOGGING_IMPLIES=	DEBUG
 UDPTUNNEL_CONFIGURE_OFF=	--disable-udptunnel
+VBOXIMG_LIB_DEPENDS=	libfuse.so.2:sysutils/fusefs-libs
 VDE_CONFIGURE_ON=	--enable-vde
 VDE_RUN_DEPENDS=	vde_switch:net/vde2
 VNC_CONFIGURE_ON=	--enable-vnc
@@ -183,6 +185,14 @@ PLIST_SUB+=	SDK=""
 PLIST_SUB+=	SDK="@comment "
 .endif
 
+.if ${PORT_OPTIONS:MVBOXIMG}
+EXTRA_PATCHES+=	${PATCHDIR}/extrapatch-vboximg-Config.kmk
+VBOX_UTILS+=	vboximg-mount
+PLIST_SUB+=	VBOXIMG=""
+.else
+PLIST_SUB+=	VBOXIMG="@comment "
+.endif
+
 KMK_ARCH=	freebsd.${ARCH}
 PLIST_SUB+=	ARCH="${KMK_ARCH}"
 
@@ -410,6 +420,10 @@ do-install:
 	    ${STAGEDIR}${VBOX_DIR}/ExtensionPacks/VNC/${KMK_ARCH}/
 .endif
 
+.if ${PORT_OPTIONS:MVBOXIMG}
+	${LN} -fs ../${VBOX_DIR_REL}/vboximg-mount ${STAGEDIR}${PREFIX}/bin/
+.endif
+
 .if ${PORT_OPTIONS:MWEBSERVICE}
 	${MKDIR} ${STAGEDIR}${DATADIR}/sdk/bindings/webservice
 	${INSTALL_DATA} ${KMK_BUILDDIR}/obj/webservice/vboxweb.wsdl \
diff --git a/emulators/virtualbox-ose/files/extrapatch-vboximg-Config.kmk b/emulators/virtualbox-ose/files/extrapatch-vboximg-Config.kmk
new file mode 100644
index 000000000000..d84209faa8cd
--- /dev/null
+++ b/emulators/virtualbox-ose/files/extrapatch-vboximg-Config.kmk
@@ -0,0 +1,11 @@
+--- Config.kmk.orig	2023-10-12 15:43:35.000000000 +0700
++++ Config.kmk	2023-10-30 22:11:09.119922000 +0700
+@@ -869,7 +869,7 @@
+ # windows versions (only define when buildling win.x86).
+ #VBOX_WITH_MORE_NT4_COMPAT_BINARIES = 1
+ # Set this to enable building of the vboximg-mount FUSE mounting utility.
+-if1of ($(KBUILD_TARGET), darwin linux)
++if1of ($(KBUILD_TARGET), darwin freebsd linux)
+  VBOX_WITH_VBOXIMGMOUNT = 1
+ endif
+ # Set this to enable packaging the fuse related bits into our installer.
diff --git a/emulators/virtualbox-ose/pkg-plist b/emulators/virtualbox-ose/pkg-plist
index ee26bfa71c09..93a4dcd48c29 100644
--- a/emulators/virtualbox-ose/pkg-plist
+++ b/emulators/virtualbox-ose/pkg-plist
@@ -11,6 +11,7 @@ bin/vboxautostart
 bin/vboxballoonctrl
 bin/vboxbugreport
 bin/vboxheadless
+%%VBOXIMG%%bin/vboximg-mount
 bin/vboxmanage
 %%X11%%bin/vboxsdl
 %%WEBSERVICE%%bin/vboxwebsrv
@@ -420,6 +421,7 @@ lib/virtualbox/VMMR0.r0
 %%QT%%@(root,%%VBOXGROUP%%,4510) lib/virtualbox/VirtualBoxVM
 %%QT%%lib/virtualbox/VirtualBoxVM.so
 %%SDK%%lib/virtualbox/sdk
+%%VBOXIMG%%lib/virtualbox/vboximg-mount
 %%WEBSERVICE%%lib/virtualbox/vboxwebsrv
 %%WEBSERVICE%%lib/virtualbox/webtest
 %%VNC%%lib/virtualbox/ExtensionPacks/VNC/ExtPack-license.html