Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Aug 2024 00:15:54 GMT
From:      Vladimir Druzenko <vvd@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: d2c76bc40a75 - main - emulators/86Box: add helper script to allow user to easily download ROMs
Message-ID:  <202408070015.4770FsDd056301@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by vvd:

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

commit d2c76bc40a757fd78ebd31b13616f916e6dfc012
Author:     gatekeeper <tiago.gasiba@gmail.com>
AuthorDate: 2024-08-07 00:12:33 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2024-08-07 00:12:33 +0000

    emulators/86Box: add helper script to allow user to easily download ROMs
    
    To run 86Box, users need to install the necessary ROMs. This commit
    provides a helper script called 86Box-install-roms.sh that automates
    this process.
    
    PR:     280664
---
 emulators/86Box/Makefile                       |  9 +++-
 emulators/86Box/files/86Box-install-roms.sh.in | 69 ++++++++++++++++++++++++++
 emulators/86Box/pkg-message                    |  9 ++++
 emulators/86Box/pkg-plist                      |  1 +
 4 files changed, 87 insertions(+), 1 deletion(-)

diff --git a/emulators/86Box/Makefile b/emulators/86Box/Makefile
index 9e15cd3f7f9e..8e5d63b186bd 100644
--- a/emulators/86Box/Makefile
+++ b/emulators/86Box/Makefile
@@ -1,6 +1,7 @@
 PORTNAME=	86Box
 DISTVERSIONPREFIX=	v
 DISTVERSION=	4.2
+PORTREVISION=	1
 CATEGORIES=	emulators
 
 MAINTAINER=	tiago.gasiba@gmail.com
@@ -36,7 +37,8 @@ USE_XORG=	x11 xcb xext xi
 
 .if ${FLAVOR} == qt5
 USES+=		qt:5
-USE_QT=		core gui network opengl widgets buildtools:build linguisttools:build
+USE_QT=		core gui network opengl widgets buildtools:build \
+		linguisttools:build
 .else
 BUILD_DEPENDS+=	vulkan-headers>0:graphics/vulkan-headers
 USES+=		gl qt:6
@@ -46,6 +48,10 @@ CMAKE_ON=	USE_QT6
 CXXFLAGS+=	-I${LOCALBASE}/include/qt6/QtGui/`pkg-config --modversion Qt6Gui`/QtGui
 .endif
 
+SUB_FILES=	86Box-install-roms.sh
+SUB_LIST=	DISTVERSION=${DISTVERSION} \
+		DISTVERSIONPREFIX=${DISTVERSIONPREFIX}
+
 OPTIONS_DEFINE=		NLS WAYLAND
 OPTIONS_DEFAULT=	WAYLAND
 
@@ -61,6 +67,7 @@ ICON_RESOLUTIONS=	128x128 192x192 256x256 48x48 512x512 64x64 72x72 96x96
 
 do-install:
 	${INSTALL_PROGRAM} ${WRKDIR}/.build/src/86Box ${STAGEDIR}${PREFIX}/bin
+	${INSTALL_SCRIPT} ${WRKDIR}/86Box-install-roms.sh ${STAGEDIR}${PREFIX}/bin
 	${REINPLACE_CMD} -e 's|Exec=86Box|Exec=/bin/sh -c "${PREFIX}/bin/86Box -C $${HOME}/86box.cfg"|' \
 		${WRKSRC}/src/unix/assets/net.86box.86Box.desktop
 	${INSTALL_DATA} ${WRKSRC}/src/unix/assets/net.86box.86Box.desktop \
diff --git a/emulators/86Box/files/86Box-install-roms.sh.in b/emulators/86Box/files/86Box-install-roms.sh.in
new file mode 100644
index 000000000000..0c0cf18f342b
--- /dev/null
+++ b/emulators/86Box/files/86Box-install-roms.sh.in
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+URL="https://github.com/86Box/roms/archive/refs/tags/%%DISTVERSIONPREFIX%%%%DISTVERSION%%.zip"
+DEFAULT_TARGET_DIR="$HOME/.local/share/86Box/"
+TARGET_DIR=${TARGET_DIR:-$DEFAULT_TARGET_DIR}
+
+install_roms() {
+  if [ -d "$TARGET_DIR" ] && [ "$(ls -A $TARGET_DIR)" ]; then
+    echo "ROMs already installed in $TARGET_DIR"
+    echo "To (re)install, please first remove ROMs with -r parameter"
+    exit 1
+  fi
+
+  TMP_DIR=$(mktemp -d)
+  TMP_FILE="$TMP_DIR/86Box-ROMs.zip"
+  echo "Fetching ROMs..."
+  fetch -qo "$TMP_FILE" "$URL"
+
+  if [ $? -ne 0 ]; then
+    echo "Failed to download the file from $URL"
+    exit 1
+  fi
+
+  echo "Extracting ROMs..."
+  mkdir -p "$TARGET_DIR"
+  unzip -q "$TMP_FILE" -d "$TARGET_DIR"
+
+  if [ $? -ne 0 ]; then
+    echo "Failed to decompress the file"
+    rm "$TMP_FILE"
+    exit 1
+  fi
+
+  mv "$TARGET_DIR/roms-"* "$TARGET_DIR/roms"
+  rm -rf "$TMP_DIR"
+  echo "ROMs installed successfully in $TARGET_DIR"
+}
+
+remove_roms() {
+  if [ -d "$TARGET_DIR/roms" ]; then
+    rm -rf "$TARGET_DIR/roms"
+    echo "ROMs removed successfully from $TARGET_DIR"
+  else
+    echo "No ROMs directory found in $TARGET_DIR"
+  fi
+}
+
+help() {
+  echo ""
+  echo "$0 [-h|-i|-r]"
+  echo "  -h : this help"
+  echo "  -i : install ROMs (this parameter can be omitted)"
+  echo "  -r : remove the ROMs"
+  echo ""
+}
+
+case "$1" in
+  -h)
+   help
+   ;;
+  -r)
+    remove_roms
+    ;;
+  -i|*)
+    install_roms
+    ;;
+esac
+
+exit 0
diff --git a/emulators/86Box/pkg-message b/emulators/86Box/pkg-message
new file mode 100644
index 000000000000..3d817927cd34
--- /dev/null
+++ b/emulators/86Box/pkg-message
@@ -0,0 +1,9 @@
+[
+{ type: install
+  message: <<EOM
+86Box requires you to manually install ROMS to be able to run.
+To do this, you can type in the following command:
+    86Box-install-roms.sh -i
+EOM
+}
+]
diff --git a/emulators/86Box/pkg-plist b/emulators/86Box/pkg-plist
index 9dd5dc91a4a7..8658649c65bb 100644
--- a/emulators/86Box/pkg-plist
+++ b/emulators/86Box/pkg-plist
@@ -1,4 +1,5 @@
 bin/86Box
+bin/86Box-install-roms.sh
 share/applications/net.86box.86Box.desktop
 share/icons/hicolor/128x128/apps/net.86box.86Box.png
 share/icons/hicolor/192x192/apps/net.86box.86Box.png



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202408070015.4770FsDd056301>