git: 7811b1c17174 - main - net-im/linux-discord: Add new port

From: Nicola Vitale <nivit_at_FreeBSD.org>
Date: Mon, 26 Aug 2024 14:15:09 UTC
The branch main has been updated by nivit:

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

commit 7811b1c1717419bced96a21b319ab38f32d7dc0d
Author:     Nicola Vitale <nivit@FreeBSD.org>
AuthorDate: 2024-08-26 14:09:38 +0000
Commit:     Nicola Vitale <nivit@FreeBSD.org>
CommitDate: 2024-08-26 14:09:38 +0000

    net-im/linux-discord: Add new port
    
    Official client for the Discord platform (Linux version).
    
    Discord is great for playing games and chilling with friends, or even building
    a worldwide community. Customize your own space to talk, play, and hang out.
    
    https://discord.com/
---
 net-im/Makefile                                    |  1 +
 net-im/linux-discord/Makefile                      | 53 ++++++++++++++
 net-im/linux-discord/distinfo                      |  3 +
 net-im/linux-discord/files/linux-discord.in        | 11 +++
 .../linux-discord/files/patch-Discord_postinst.sh  | 23 ++++++
 net-im/linux-discord/files/pkg-message.in          | 17 +++++
 net-im/linux-discord/pkg-descr                     |  4 ++
 net-im/linux-discord/pkg-plist                     | 81 ++++++++++++++++++++++
 8 files changed, 193 insertions(+)

diff --git a/net-im/Makefile b/net-im/Makefile
index 5c5dd6347bc2..e56e237d586a 100644
--- a/net-im/Makefile
+++ b/net-im/Makefile
@@ -51,6 +51,7 @@
     SUBDIR += libsignal-node
     SUBDIR += libsignon-glib
     SUBDIR += libstrophe
+    SUBDIR += linux-discord
     SUBDIR += loudmouth
     SUBDIR += lurch
     SUBDIR += mastodon
diff --git a/net-im/linux-discord/Makefile b/net-im/linux-discord/Makefile
new file mode 100644
index 000000000000..8d8088975131
--- /dev/null
+++ b/net-im/linux-discord/Makefile
@@ -0,0 +1,53 @@
+PORTNAME=	discord
+DISTVERSION=	0.0.65
+CATEGORIES=	net-im
+MASTER_SITES=	https://dl.discordapp.net/apps/linux/${DISTVERSION}/
+PKGNAMEPREFIX=	linux-
+
+MAINTAINER=	nivit@FreeBSD.org
+COMMENT=	Official client for the Discord platform (Linux version)
+WWW=		https://discord.com/
+
+LICENSE=	AGPLv3 BSD3CLAUSE CC-BY-2.5 CC-BY-3.0 DISCORD LGPL21 MIT MPL11
+LICENSE_COMB=	multi
+LICENSE_NAME_DISCORD=	Discord's Term of Service
+LICENSE_TEXT_DISCORD=	https://discord.com/terms
+LICENSE_PERMS_DISCORD=	dist-mirror pkg-mirror auto-accept
+
+ONLY_FOR_ARCHS=	amd64
+
+RUN_DEPENDS=	linux-rl9-libatomic>=11.4.1:devel/linux-rl9-libatomic \
+		pulseaudio:audio/pulseaudio
+
+USES=		linux:rl9
+USE_LINUX=	alsa-plugins-oss alsa-plugins-pulseaudio alsalib at-spi2-atk \
+		atk ca-certificates cups-libs dbuslibs devtools gtk3 libdrm \
+		libsigsegv nspr nss opus
+
+DATADIR=	${PREFIX}/share/${PKGBASE}
+
+NO_BUILD=	yes
+SUB_FILES=	${PKGBASE} pkg-message
+SUB_LIST=	LINUXBASE=${LINUXBASE}
+
+NO_WRKSUBDIR=	yes
+
+ICONS_DIR=	${STAGEDIR}${PREFIX}/share/icons/hicolor/256x256/apps
+
+post-patch:
+	${REINPLACE_CMD} -i "" \
+		-e 's,/usr,${PREFIX},g' \
+		-e 's,\(^Exec=\).*,\1${PREFIX}/bin/${PKGBASE},1' \
+		${WRKSRC}/Discord/discord.desktop
+
+do-install:
+	@${MKDIR} ${STAGEDIR}${DATADIR}
+	(cd ${WRKSRC}/Discord && \
+		${COPYTREE_SHARE} . ${STAGEDIR}${DATADIR} \
+		"-not -regex \./discord.*")
+	${INSTALL_SCRIPT} ${WRKDIR}/${PKGBASE} ${STAGEDIR}${LOCALBASE}/bin/${PKGBASE}
+	${INSTALL_DATA} ${WRKSRC}/Discord/discord.desktop ${STAGEDIR}${DESKTOPDIR}/${PKGBASE}.desktop
+	@${MKDIR} ${ICONS_DIR}
+	${INSTALL_DATA} ${WRKSRC}/Discord/discord.png ${ICONS_DIR}
+
+.include <bsd.port.mk>
diff --git a/net-im/linux-discord/distinfo b/net-im/linux-discord/distinfo
new file mode 100644
index 000000000000..1cdf053b3879
--- /dev/null
+++ b/net-im/linux-discord/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1724402306
+SHA256 (discord-0.0.65.tar.gz) = 93360b65c8ee1bb93c4528dce68a0394c29a025307be6d320a5e4aae786aabc0
+SIZE (discord-0.0.65.tar.gz) = 103550088
diff --git a/net-im/linux-discord/files/linux-discord.in b/net-im/linux-discord/files/linux-discord.in
new file mode 100755
index 000000000000..e4c462613861
--- /dev/null
+++ b/net-im/linux-discord/files/linux-discord.in
@@ -0,0 +1,11 @@
+#!%%LINUXBASE%%/bin/bash
+
+# workaround Chromium bug https://bugs.chromium.org/p/chromium/issues/detail?id=918234
+if [ "$DBUS_SESSION_BUS_ADDRESS" = "" ]; then
+    export DBUS_SESSION_BUS_ADDRESS="autolaunch:"
+fi
+export ELECTRON_IS_DEV=0
+export LIBGL_DRI3_DISABLE=1
+export NODE_ENV=production
+
+exec -a "$0" "%%DATADIR%%/Discord" --no-sandbox --no-zygote "$@"
diff --git a/net-im/linux-discord/files/patch-Discord_postinst.sh b/net-im/linux-discord/files/patch-Discord_postinst.sh
new file mode 100644
index 000000000000..2464e095a7eb
--- /dev/null
+++ b/net-im/linux-discord/files/patch-Discord_postinst.sh
@@ -0,0 +1,23 @@
+--- Discord/postinst.sh.orig	2024-08-22 19:49:42 UTC
++++ Discord/postinst.sh
+@@ -16,16 +16,16 @@ for DIR in /home/* ; do
+ # This is probably just paranoia, but some people claim that clearing out
+ # cache and/or the sock file fixes bugs for them, so here we go
+ for DIR in /home/* ; do
+-  rm -rf "$DIR/.config/discord/Cache"
+-  rm -rf "$DIR/.config/discord/GPUCache"
++  rm -Rf "$DIR/.config/discord/Cache"
++  rm -Rf "$DIR/.config/discord/GPUCache"
+ 
+   # A previous bug made some files in this folder owned by root
+   # and discord will hang if those files are present
+   SETTINGS_FILE="$DIR/.config/discord/Crashpad/settings.dat"
+   if [ -f "$SETTINGS_FILE" ]; then
+-    OWNER=$(stat -c "%U" "$SETTINGS_FILE")
++    OWNER=$(stat -f "%Su" "$SETTINGS_FILE")
+     if [ "$OWNER" = "root" ]; then
+-      rm -rf "$DIR/.config/discord/Crashpad"
++      rm -Rf "$DIR/.config/discord/Crashpad"
+     fi
+   fi
+ done
diff --git a/net-im/linux-discord/files/pkg-message.in b/net-im/linux-discord/files/pkg-message.in
new file mode 100644
index 000000000000..9006df957430
--- /dev/null
+++ b/net-im/linux-discord/files/pkg-message.in
@@ -0,0 +1,17 @@
+[
+{ type: install
+  message: <<EOM
+
+If the user's directory is located in /usr/home/ and doesn't exist the link
+/home, then create one with the command:
+
+  ln -s /usr/home /home
+
+Discord uses pulseaudio(1), so you have to start the relative server.
+
+If you have updated the port/package, you have to run the following command:
+
+  %%DATADIR%%/postinst.sh
+EOM
+}
+]
diff --git a/net-im/linux-discord/pkg-descr b/net-im/linux-discord/pkg-descr
new file mode 100644
index 000000000000..37715a2ca799
--- /dev/null
+++ b/net-im/linux-discord/pkg-descr
@@ -0,0 +1,4 @@
+Official client for the Discord platform (Linux version).
+
+Discord is great for playing games and chilling with friends, or even building
+a worldwide community. Customize your own space to talk, play, and hang out.
diff --git a/net-im/linux-discord/pkg-plist b/net-im/linux-discord/pkg-plist
new file mode 100644
index 000000000000..22fcbea8b5fd
--- /dev/null
+++ b/net-im/linux-discord/pkg-plist
@@ -0,0 +1,81 @@
+bin/linux-discord
+share/applications/linux-discord.desktop
+share/icons/hicolor/256x256/apps/discord.png
+%%DATADIR%%/chrome_100_percent.pak
+%%DATADIR%%/chrome_200_percent.pak
+%%DATADIR%%/icudtl.dat
+%%DATADIR%%/libEGL.so
+%%DATADIR%%/libGLESv2.so
+%%DATADIR%%/libffmpeg.so
+%%DATADIR%%/libvk_swiftshader.so
+%%DATADIR%%/libvulkan.so.1
+%%DATADIR%%/locales/af.pak
+%%DATADIR%%/locales/am.pak
+%%DATADIR%%/locales/ar.pak
+%%DATADIR%%/locales/bg.pak
+%%DATADIR%%/locales/bn.pak
+%%DATADIR%%/locales/ca.pak
+%%DATADIR%%/locales/cs.pak
+%%DATADIR%%/locales/da.pak
+%%DATADIR%%/locales/de.pak
+%%DATADIR%%/locales/el.pak
+%%DATADIR%%/locales/en-GB.pak
+%%DATADIR%%/locales/en-US.pak
+%%DATADIR%%/locales/es-419.pak
+%%DATADIR%%/locales/es.pak
+%%DATADIR%%/locales/et.pak
+%%DATADIR%%/locales/fa.pak
+%%DATADIR%%/locales/fi.pak
+%%DATADIR%%/locales/fil.pak
+%%DATADIR%%/locales/fr.pak
+%%DATADIR%%/locales/gu.pak
+%%DATADIR%%/locales/he.pak
+%%DATADIR%%/locales/hi.pak
+%%DATADIR%%/locales/hr.pak
+%%DATADIR%%/locales/hu.pak
+%%DATADIR%%/locales/id.pak
+%%DATADIR%%/locales/it.pak
+%%DATADIR%%/locales/ja.pak
+%%DATADIR%%/locales/kn.pak
+%%DATADIR%%/locales/ko.pak
+%%DATADIR%%/locales/lt.pak
+%%DATADIR%%/locales/lv.pak
+%%DATADIR%%/locales/ml.pak
+%%DATADIR%%/locales/mr.pak
+%%DATADIR%%/locales/ms.pak
+%%DATADIR%%/locales/nb.pak
+%%DATADIR%%/locales/nl.pak
+%%DATADIR%%/locales/pl.pak
+%%DATADIR%%/locales/pt-BR.pak
+%%DATADIR%%/locales/pt-PT.pak
+%%DATADIR%%/locales/ro.pak
+%%DATADIR%%/locales/ru.pak
+%%DATADIR%%/locales/sk.pak
+%%DATADIR%%/locales/sl.pak
+%%DATADIR%%/locales/sr.pak
+%%DATADIR%%/locales/sv.pak
+%%DATADIR%%/locales/sw.pak
+%%DATADIR%%/locales/ta.pak
+%%DATADIR%%/locales/te.pak
+%%DATADIR%%/locales/th.pak
+%%DATADIR%%/locales/tr.pak
+%%DATADIR%%/locales/uk.pak
+%%DATADIR%%/locales/ur.pak
+%%DATADIR%%/locales/vi.pak
+%%DATADIR%%/locales/zh-CN.pak
+%%DATADIR%%/locales/zh-TW.pak
+%%DATADIR%%/resources.pak
+%%DATADIR%%/resources/app.asar
+%%DATADIR%%/resources/bootstrap/manifest.json
+%%DATADIR%%/resources/build_info.json
+%%DATADIR%%/snapshot_blob.bin
+%%DATADIR%%/v8_context_snapshot.bin
+%%DATADIR%%/vk_swiftshader_icd.json
+@mode 555
+%%DATADIR%%/Discord
+%%DATADIR%%/chrome_crashpad_handler
+%%DATADIR%%/postinst.sh
+@mode
+@mode 4555
+%%DATADIR%%/chrome-sandbox
+@mode