git: cfd09d6e9d1b - main - games/prismlauncher: New port: Minecraft launcher with ability to manage multiple instances

From: Vladimir Druzenko <vvd_at_FreeBSD.org>
Date: Mon, 09 Sep 2024 18:01:51 UTC
The branch main has been updated by vvd:

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

commit cfd09d6e9d1bca2c3f41e14500e8a1c5ad39518e
Author:     Alexander Vereeken <Alexander88207@protonmail.com>
AuthorDate: 2024-09-09 18:00:06 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2024-09-09 18:00:06 +0000

    games/prismlauncher: New port: Minecraft launcher with ability to manage multiple instances
    
    A custom launcher for Minecraft that allows you to easily manage
    multiple installations of Minecraft at once. (Fork of MultiMC)
    
    https://prismlauncher.org
    
    Differential Revision:  https://reviews.freebsd.org/D44661
---
 games/Makefile                                     |  1 +
 games/prismlauncher/Makefile                       | 35 ++++++++++++++++++++++
 games/prismlauncher/distinfo                       |  7 +++++
 .../patch-launcher_minecraft_LaunchProfile.cpp     | 18 +++++++++++
 .../patch-launcher_minecraft_MinecraftInstance.cpp | 20 +++++++++++++
 ...ch-launcher_ui_pages_global_AccountListPage.cpp | 19 ++++++++++++
 .../files/patch-libraries_javacheck_CMakeLists.txt | 11 +++++++
 .../files/patch-libraries_launcher_CMakeLists.txt  | 11 +++++++
 games/prismlauncher/pkg-descr                      |  2 ++
 games/prismlauncher/pkg-message                    | 20 +++++++++++++
 games/prismlauncher/pkg-plist                      | 10 +++++++
 11 files changed, 154 insertions(+)

diff --git a/games/Makefile b/games/Makefile
index 7755356d8c85..163b06730867 100644
--- a/games/Makefile
+++ b/games/Makefile
@@ -790,6 +790,7 @@
     SUBDIR += prboom
     SUBDIR += prboom-plus
     SUBDIR += primateplunge
+    SUBDIR += prismlauncher
     SUBDIR += puckman
     SUBDIR += punchy
     SUBDIR += pvpgn
diff --git a/games/prismlauncher/Makefile b/games/prismlauncher/Makefile
new file mode 100644
index 000000000000..714390e18e4d
--- /dev/null
+++ b/games/prismlauncher/Makefile
@@ -0,0 +1,35 @@
+PORTNAME=	prismlauncher
+DISTVERSION=	8.4
+CATEGORIES=	games java
+
+MAINTAINER=	Alexander88207@protonmail.com
+COMMENT=	Minecraft launcher with ability to manage multiple instances
+WWW=		https://prismlauncher.org/
+
+LICENSE=	GPLv3
+LICENSE_FILE=	${WRKSRC}/COPYING.md
+
+LIB_DEPENDS=	libcmark.so:textproc/cmark \
+		libquazip1-qt6.so:archivers/quazip@qt6 \
+		libtomlplusplus.so:devel/tomlplusplus
+RUN_DEPENDS=	lwjgl>0:games/lwjgl \
+		lwjgl3>0:games/lwjgl3 \
+		openjdk21>0:java/openjdk21 \
+		xrandr:x11/xrandr
+
+USES=		cmake compiler:c++17-lang desktop-file-utils gl kde:6 qt:6 \
+		shared-mime-info
+USE_GITHUB=	yes
+GH_ACCOUNT=	PrismLauncher
+GH_PROJECT=	${GH_ACCOUNT}
+GH_TUPLE=	gulrak:filesystem:2fc4b463:filesystem/libraries/filesystem \
+		PrismLauncher:libnbtplusplus:23b95512:libnbtplusplus/libraries/libnbtplusplus
+USE_GL=		opengl
+USE_JAVA=	yes
+USE_KDE=	ecm:build
+USE_QT=		5compat base
+
+CMAKE_ARGS=	-DJAVA_HOME=${JAVA_HOME} -DJava_JAVAC_EXECUTABLE=${JAVAC} \
+		-DLauncher_BUILD_PLATFORM=FreeBSD
+
+.include <bsd.port.mk>
diff --git a/games/prismlauncher/distinfo b/games/prismlauncher/distinfo
new file mode 100644
index 000000000000..a3fff46f0bd9
--- /dev/null
+++ b/games/prismlauncher/distinfo
@@ -0,0 +1,7 @@
+TIMESTAMP = 1725714249
+SHA256 (PrismLauncher-PrismLauncher-8.4_GH0.tar.gz) = e3268a787d326c7c71f63093a2b411d6735c07b3751b426db6d50a0386311c76
+SIZE (PrismLauncher-PrismLauncher-8.4_GH0.tar.gz) = 4397390
+SHA256 (gulrak-filesystem-2fc4b463_GH0.tar.gz) = 270eead1276da3af72e6f1c5b819d0b2a7b24ddc3e4e7a1a0b69ffba8d07228f
+SIZE (gulrak-filesystem-2fc4b463_GH0.tar.gz) = 211853
+SHA256 (PrismLauncher-libnbtplusplus-23b95512_GH0.tar.gz) = 4393bc210d2025029fc364d761d339c88223a3cdd03b401ebee58d5e3cddb4dc
+SIZE (PrismLauncher-libnbtplusplus-23b95512_GH0.tar.gz) = 48603
diff --git a/games/prismlauncher/files/patch-launcher_minecraft_LaunchProfile.cpp b/games/prismlauncher/files/patch-launcher_minecraft_LaunchProfile.cpp
new file mode 100644
index 000000000000..e44a7c27b8bb
--- /dev/null
+++ b/games/prismlauncher/files/patch-launcher_minecraft_LaunchProfile.cpp
@@ -0,0 +1,18 @@
+# Patch taken from er2off: https://github.com/er2off/freebsd-ports
+--- launcher/minecraft/LaunchProfile.cpp.orig        2023-11-27 12:45:04 UTC
++++ launcher/minecraft/LaunchProfile.cpp
+@@ -344,6 +344,14 @@ void LaunchProfile::getLibraryFiles(const RuntimeConte
+     jars.clear();
+     nativeJars.clear();
+     for (auto lib : getLibraries()) {
++#ifdef Q_OS_FREEBSD
++        // HACKHACK: use system lwjgl3 until mojang will fix it
++        QString artifact = lib->artifactId();
++        if (artifact.startsWith("lwjgl") && lib->version().startsWith("3.")) {
++            jars += "/usr/local/share/java/classes/lwjgl3/" + artifact + ".jar";
++            continue;
++        }
++#endif
+         lib->getApplicableFiles(runtimeContext, jars, nativeJars, native32, native64, overridePath);
+     }
+     // NOTE: order is important here, add main jar last to the lists
diff --git a/games/prismlauncher/files/patch-launcher_minecraft_MinecraftInstance.cpp b/games/prismlauncher/files/patch-launcher_minecraft_MinecraftInstance.cpp
new file mode 100644
index 000000000000..eb4cc4ed4837
--- /dev/null
+++ b/games/prismlauncher/files/patch-launcher_minecraft_MinecraftInstance.cpp
@@ -0,0 +1,20 @@
+# Patch taken from er2off: https://github.com/er2off/freebsd-ports
+--- launcher/minecraft/MinecraftInstance.cpp.orig        2023-11-27 12:44:40 UTC
++++ launcher/minecraft/MinecraftInstance.cpp
+@@ -305,7 +305,16 @@ QString MinecraftInstance::getNativePath() const
+ 
+ QString MinecraftInstance::getNativePath() const
+ {
++#ifdef Q_OS_FREEBSD
++    Version instance_ver{ getPackProfile()->getComponentVersion("net.minecraft") };
++    QDir natives_dir;
++    if (instance_ver < Version("1.13.0"))
++        natives_dir = QDir("/usr/local/lib/lwjgl/");
++    else
++        natives_dir = QDir("/usr/local/lib/lwjgl3/");
++#else
+     QDir natives_dir(FS::PathCombine(instanceRoot(), "natives/"));
++#endif
+     return natives_dir.absolutePath();
+ }
+ 
diff --git a/games/prismlauncher/files/patch-launcher_ui_pages_global_AccountListPage.cpp b/games/prismlauncher/files/patch-launcher_ui_pages_global_AccountListPage.cpp
new file mode 100644
index 000000000000..0c15ed8b6577
--- /dev/null
+++ b/games/prismlauncher/files/patch-launcher_ui_pages_global_AccountListPage.cpp
@@ -0,0 +1,19 @@
+# Patch taken from er2off: https://github.com/er2off/freebsd-ports
+--- launcher/ui/pages/global/AccountListPage.cpp.orig        2024-03-03 19:37:21 UTC
++++ launcher/ui/pages/global/AccountListPage.cpp
+@@ -147,6 +147,7 @@ void AccountListPage::on_actionAddOffline_triggered()
+ 
+ void AccountListPage::on_actionAddOffline_triggered()
+ {
++#ifdef NO_OFFLINE
+     if (!m_accounts->anyAccountIsValid()) {
+         QMessageBox::warning(this, tr("Error"),
+                              tr("You must add a Microsoft account that owns Minecraft before you can add an offline account."
+@@ -154,6 +155,7 @@ void AccountListPage::on_actionAddOffline_triggered()
+                                 "If you have lost your account you can contact Microsoft for support."));
+         return;
+     }
++#endif
+ 
+     MinecraftAccountPtr account =
+         OfflineLoginDialog::newAccount(this, tr("Please enter your desired username to add your offline account."));
diff --git a/games/prismlauncher/files/patch-libraries_javacheck_CMakeLists.txt b/games/prismlauncher/files/patch-libraries_javacheck_CMakeLists.txt
new file mode 100644
index 000000000000..58dca6f362f4
--- /dev/null
+++ b/games/prismlauncher/files/patch-libraries_javacheck_CMakeLists.txt
@@ -0,0 +1,11 @@
+--- libraries/javacheck/CMakeLists.txt.orig	2024-06-18 18:07:06 UTC
++++ libraries/javacheck/CMakeLists.txt
+@@ -4,7 +4,7 @@ set(CMAKE_JAVA_JAR_ENTRY_POINT JavaCheck)
+ 
+ include(UseJava)
+ set(CMAKE_JAVA_JAR_ENTRY_POINT JavaCheck)
+-set(CMAKE_JAVA_COMPILE_FLAGS -target 7 -source 7 -Xlint:deprecation -Xlint:unchecked)
++set(CMAKE_JAVA_COMPILE_FLAGS -target 8 -source 8 -Xlint:deprecation -Xlint:unchecked)
+ 
+ set(SRC
+     JavaCheck.java
diff --git a/games/prismlauncher/files/patch-libraries_launcher_CMakeLists.txt b/games/prismlauncher/files/patch-libraries_launcher_CMakeLists.txt
new file mode 100644
index 000000000000..35c7badf6a7d
--- /dev/null
+++ b/games/prismlauncher/files/patch-libraries_launcher_CMakeLists.txt
@@ -0,0 +1,11 @@
+--- libraries/launcher/CMakeLists.txt.orig	2024-06-18 18:07:06 UTC
++++ libraries/launcher/CMakeLists.txt
+@@ -4,7 +4,7 @@ set(CMAKE_JAVA_JAR_ENTRY_POINT org.prismlauncher.Entry
+ 
+ include(UseJava)
+ set(CMAKE_JAVA_JAR_ENTRY_POINT org.prismlauncher.EntryPoint)
+-set(CMAKE_JAVA_COMPILE_FLAGS -target 7 -source 7)
++set(CMAKE_JAVA_COMPILE_FLAGS -target 8 -source 8)
+ 
+ set(SRC
+     org/prismlauncher/EntryPoint.java
diff --git a/games/prismlauncher/pkg-descr b/games/prismlauncher/pkg-descr
new file mode 100644
index 000000000000..4387573cea53
--- /dev/null
+++ b/games/prismlauncher/pkg-descr
@@ -0,0 +1,2 @@
+A custom launcher for Minecraft that allows you to easily manage
+multiple installations of Minecraft at once. (Fork of MultiMC)
diff --git a/games/prismlauncher/pkg-message b/games/prismlauncher/pkg-message
new file mode 100644
index 000000000000..91697adac6df
--- /dev/null
+++ b/games/prismlauncher/pkg-message
@@ -0,0 +1,20 @@
+[
+{
+message: <<EOM
+
+NVIDIA users have probably to add the following to the
+environment variables section:
+
+LD_LIBMAP       libGLX.so       libGL-NVIDIA.so
+                libGLX.so.0     libGL-NVIDIA.so.1
+
+For older cards that dont support OpenGL 4
+you have to add the following to the environment variables section:
+
+MESA_GL_VERSION_OVERRIDE 3.2
+MESA_GLSL_VERSION_OVERRIDE 330
+
+Have Fun!
+EOM
+}
+]
diff --git a/games/prismlauncher/pkg-plist b/games/prismlauncher/pkg-plist
new file mode 100644
index 000000000000..a30a2f2f55d7
--- /dev/null
+++ b/games/prismlauncher/pkg-plist
@@ -0,0 +1,10 @@
+bin/prismlauncher
+share/PrismLauncher/JavaCheck.jar
+share/PrismLauncher/NewLaunch.jar
+share/PrismLauncher/NewLaunchLegacy.jar
+share/PrismLauncher/qtlogging.ini
+share/applications/org.prismlauncher.PrismLauncher.desktop
+share/icons/hicolor/scalable/apps/org.prismlauncher.PrismLauncher.svg
+share/metainfo/org.prismlauncher.PrismLauncher.metainfo.xml
+share/mime/packages/modrinth-mrpack-mime.xml
+share/qlogging-categories6/prismlauncher.categories