Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F167166584
D58784.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
11 KB
Referenced Files
None
Subscribers
None
D58784.id.diff
View Options
diff --git a/www/linux-brave/Makefile b/www/linux-brave/Makefile
--- a/www/linux-brave/Makefile
+++ b/www/linux-brave/Makefile
@@ -1,12 +1,13 @@
PORTNAME= brave
PORTVERSION= ${BRAVE_VER}
+PORTREVISION= 1
CATEGORIES= www linux
MASTER_SITES= https://github.com/${PORTNAME}/${PORTNAME}-browser/releases/download/v${PORTVERSION}/
PKGNAMEPREFIX= linux-
DISTNAME= ${PORTNAME}-browser-${BRAVE_VER}-${BRAVE_BUILD}
DISTFILES_aarch64?= ${DISTNAME:S/$/${EXTRACT_SUFX_aarch64}/}
DISTFILES_amd64?= ${DISTNAME:S/$/${EXTRACT_SUFX_amd64}/}
-EXTRACT_ONLY?= ${DISTFILES_${ARCH}:C/:[^:]+$//}
+EXTRACT_ONLY?= ${DISTFILES_${ARCH}:C/:[^:]+$//}
MAINTAINER= emulation@FreeBSD.org
COMMENT= Brave web browser based on WebKit
@@ -14,40 +15,50 @@
LICENSE= MPL20
-RUN_DEPENDS= update-mime-database:misc/shared-mime-info
+ONLY_FOR_ARCHS= aarch64 amd64
+
+RUN_DEPENDS= dbus-run-session:devel/dbus
-USES= cpe desktop-file-utils gnome linux:rl9 shared-mime-info shebangfix
-USE_LINUX= alsalib alsa-plugins-oss alsa-plugins-pulseaudio at-spi2-atk \
+USES= cpe desktop-file-utils gnome linux:rl9 shebangfix
+USE_LINUX= alsa-plugins-oss alsa-plugins-pulseaudio alsalib at-spi2-atk \
ca-certificates cairo cups-libs curl dbuslibs dri expat \
- ffmpeg-libs gnupg gstreamer1-libav gtk3 libxkbcommon \
- nspr nss p11-kit pango sqlite3 wget xorglibs
-ONLY_FOR_ARCHS= aarch64 amd64
+ ffmpeg-libs gnupg gstreamer1-libav gtk3 libxkbcommon nspr nss \
+ p11-kit pango sqlite3 wget xorglibs
SHEBANG_FILES= opt/brave.com/brave/brave-browser
+REINPLACE_ARGS= -i ""
NO_BUILD= yes
+SUB_FILES= brave-browser
+
NO_WRKSUBDIR= yes
EXTRACT_SUFX_aarch64?= .aarch64.rpm
EXTRACT_SUFX_amd64?= .x86_64.rpm
-REINPLACE_ARGS= -i ""
-
BRAVE_VER?= 1.92.144
BRAVE_BUILD?= 1
-DATADIR= ${PREFIX}/share/${PORTNAME}
-DOCSDIR= ${PREFIX}/share/doc/${PORTNAME}
+OPTIONS_DEFINE= DOCS WIDEVINE
+OPTIONS_DEFAULT= WIDEVINE
+OPTIONS_SUB= yes
-OPTIONS_DEFINE= DOCS
+WIDEVINE_DESC= DRM playback via www/linux-widevine-cdm (Netflix etc.)
+WIDEVINE_USES= python:3.11+,run
-SUB_FILES= brave-browser
+.include <bsd.port.options.mk>
+
+.if ${PORT_OPTIONS:MWIDEVINE}
+SUB_FILES+= brave-widevine-seed
+SUB_LIST+= PYTHON_CMD=${PYTHON_CMD}
+.endif
.if make(makesum) || make(checksum)
-_ALL_DISTFILES= ${DISTFILES_aarch64} ${DISTFILES_amd64}
-DISTFILES= ${_ALL_DISTFILES:O:u}
-. else
-DISTFILES= ${DISTFILES_${ARCH}}
+_ALL_DISTFILES= ${DISTFILES_aarch64} \
+ ${DISTFILES_amd64}
+DISTFILES= ${_ALL_DISTFILES:O:u}
+.else
+DISTFILES= ${DISTFILES_${ARCH}}
.endif
post-extract:
@@ -66,5 +77,10 @@
${MKDIR} ${STAGEDIR}/etc/brave/policies/managed
${INSTALL_DATA} ${FILESDIR}/brave.json ${STAGEDIR}/etc/brave/policies/managed
${INSTALL_DATA} ${FILESDIR}/webrtc.json ${STAGEDIR}/etc/brave/policies/managed
+.if ${PORT_OPTIONS:MWIDEVINE}
+ ${RM} -rf ${STAGEDIR}${DATADIR}/WidevineCdm
+ ${LN} -sf ${LOCALBASE}/lib/WidevineCdm ${STAGEDIR}${DATADIR}/WidevineCdm
+ ${INSTALL_SCRIPT} ${WRKDIR}/brave-widevine-seed ${STAGEDIR}${PREFIX}/bin
+.endif
.include <bsd.port.mk>
diff --git a/www/linux-brave/files/brave-browser.in b/www/linux-brave/files/brave-browser.in
--- a/www/linux-brave/files/brave-browser.in
+++ b/www/linux-brave/files/brave-browser.in
@@ -2,19 +2,123 @@
get_pa_sock_path()
{
- PA_SOCK_PATH=$(sockstat | awk -v me=$(whoami) -F'[ \t]+' '
+ PA_SOCK_PATH=$(sockstat -uw | awk -v me="$(whoami)" -F'[ \t]+' '
$1 == me && $2 == "pulseaudio" && $6 ~ /native/ {
- print $6;
+ print $6
exit 0
}'
)
}
+#
+# Hardware GL needs a DRM render node the user can open and the
+# Linux-side Mesa DRI drivers (graphics/linux-rl9-dri) so the Linux
+# GL stack can drive it
+#
+brave_gpu_detect()
+{
+ local emul node found=
+
+ for node in /dev/dri/renderD*; do
+ [ -w "$node" ] || continue
+ found=1
+ break
+ done
+ [ "$found" ] || return 1
+ emul=$( sysctl -n compat.linux.emul_path 2> /dev/null ) ||
+ return 1
+ set -- "$emul"/usr/lib64/dri/*_dri.so
+ [ -e "$1" ]
+}
+
+#
+# ANGLE-on-Vulkan needs the Linux-side Vulkan loader
+# (x11-toolkits/linux-rl9-vulkan) and a hardware driver ICD (anv,
+# radv, ...); lavapipe is software rendering and does not count
+#
+brave_vulkan_detect()
+{
+ local emul icd found=
+
+ emul=$( sysctl -n compat.linux.emul_path 2> /dev/null ) ||
+ return 1
+ [ -e "$emul"/usr/lib64/libvulkan.so.1 ] || return 1
+ for icd in "$emul"/usr/share/vulkan/icd.d/*.json; do
+ [ -e "$icd" ] || continue
+ case "${icd##*/}" in
+ lvp_icd*) continue ;;
+ esac
+ found=1
+ break
+ done
+ [ "$found" ]
+}
+
+# Re-exec under a session bus when none is present (many WMs have
+# none). dbus-run-session exports DBUS_SESSION_BUS_ADDRESS to the
+# child, so the re-exec cannot loop, and tears the bus down when the
+# browser exits, where a dbus-launch daemon would outlive it and
+# stack up across launches.
+if [ ! "${DBUS_SESSION_BUS_ADDRESS-}" ] &&
+ command -v dbus-run-session > /dev/null 2>&1
+then
+ exec dbus-run-session -- "$0" "$@"
+fi
+
get_pa_sock_path
-[ -S "$PA_SOCK_PATH" ] && export PULSE_SERVER=unix:$PA_SOCK_PATH && export PULSE_COOKIE="~/.config/pulse/cookie"
+[ -S "$PA_SOCK_PATH" ] && export PULSE_SERVER=unix:$PA_SOCK_PATH &&
+ export PULSE_COOKIE="$HOME/.config/pulse/cookie"
export BRAVE_PATH="%%DATADIR%%/brave"
export BRAVE_WRAPPER="$(readlink -f "$0")"
export LIBGL_DRI3_DISABLE=1
-exec "$BRAVE_PATH" --no-sandbox --no-zygote --test-type --v=0 "$@"
+# Never inherit a FreeBSD-side LD_PRELOAD into the Linuxulator binary.
+unset LD_PRELOAD
+
+# When built with WIDEVINE we have a helper that seeds brave.widevine_opted_in
+# and the Widevine component hint once so DRM works from the very first launch.
+if [ -x "%%PREFIX%%/bin/brave-widevine-seed" ]; then
+ "%%PREFIX%%/bin/brave-widevine-seed" "$@" || : errors ignored
+fi
+
+#
+# GPU: use hardware GL when the system can support it, software
+# rendering otherwise. BRAVE_GPU=1 forces hardware GL, BRAVE_GPU=0
+# forces software rendering; unset selects by detection.
+#
+set -- --no-sandbox --no-zygote --v=0 "$@"
+gpu=
+case "${BRAVE_GPU:-auto}" in
+1|yes|YES|true|TRUE)
+ gpu=1
+ ;;
+auto)
+ brave_gpu_detect && gpu=1
+ ;;
+esac
+if [ ! "$gpu" ]; then
+ set -- --disable-gpu --disable-gpu-compositing "$@"
+ export LIBGL_ALWAYS_SOFTWARE=1
+else
+ #
+ # Prefer ANGLE-on-Vulkan when a hardware Vulkan driver is
+ # present: GL command streams from the Linux Mesa drivers have
+ # proven prone to GPU hangs on some kernel driver pairings,
+ # while the Vulkan path drives the same hardware reliably.
+ # BRAVE_VULKAN=1 forces it, BRAVE_VULKAN=0 stays on GL; unset
+ # selects by detection.
+ #
+ case "${BRAVE_VULKAN:-auto}" in
+ 1|yes|YES|true|TRUE)
+ set -- --use-angle=vulkan "$@"
+ ;;
+ auto)
+ brave_vulkan_detect &&
+ set -- --use-angle=vulkan "$@"
+ ;;
+ esac
+fi
+
+# Do not pass --test-type: it ImmediateCrashes under Linuxulator.
+exec "$BRAVE_PATH" "$@"
diff --git a/www/linux-brave/files/brave-widevine-seed.in b/www/linux-brave/files/brave-widevine-seed.in
new file mode 100644
--- /dev/null
+++ b/www/linux-brave/files/brave-widevine-seed.in
@@ -0,0 +1,79 @@
+#!/bin/sh
+#
+# Seed brave.widevine_opted_in in Brave Local State when unset, and
+# keep the Widevine component hint file pointing at an installed CDM,
+# so DRM works from the very first launch and recovers when the CDM
+# port is reinstalled. Used by the brave-browser wrapper when the
+# port is built with WIDEVINE.
+#
+
+user_data=""
+while [ $# -gt 0 ]; do
+ case "$1" in
+ --user-data-dir=*)
+ user_data="${1#--user-data-dir=}"
+ ;;
+ --user-data-dir)
+ shift
+ user_data="$1"
+ ;;
+ esac
+ shift
+done
+
+if [ ! "$user_data" ]; then
+ user_data="$HOME/.config/BraveSoftware/Brave-Browser"
+fi
+
+state="$user_data/Local State"
+mkdir -p "$user_data" || exit 0
+
+#
+# Chromium registers the Widevine CDM at browser startup from the hint
+# file, and never repairs the hint itself: Brave first writes it after
+# discovering the preinstalled component during the first run, and a
+# session that starts with a missing or stale hint runs without DRM
+# for its whole lifetime. Plant the hint pointing at the packaged CDM
+# when it is missing, and repoint it when its target no longer holds a
+# CDM (e.g. www/linux-widevine-cdm was reinstalled), so DRM works on
+# this launch instead of the next. A hint whose target is intact is
+# left alone: Brave maintains it and it may point at a newer
+# component-updated CDM.
+#
+cdm="%%LOCALBASE%%/lib/WidevineCdm"
+hint="$user_data/WidevineCdm/latest-component-updated-widevine-cdm"
+if [ -e "$cdm/manifest.json" ]; then
+ hint_path=
+ [ -e "$hint" ] &&
+ hint_path=$( sed -n 's/.*"Path":"\([^"]*\)".*/\1/p' "$hint" )
+ if [ ! "$hint_path" ] ||
+ [ ! -e "$hint_path/manifest.json" ]
+ then
+ mkdir -p "$user_data/WidevineCdm" &&
+ printf '{"Path":"%s"}' "$cdm" > "$hint.tmp" &&
+ mv "$hint.tmp" "$hint"
+ fi
+fi
+
+%%PYTHON_CMD%% - "$state" <<'PY'
+import json, os, sys
+
+path = sys.argv[1]
+data = {}
+if os.path.exists(path):
+ try:
+ with open(path, "r", encoding="utf-8") as f:
+ data = json.load(f)
+ except Exception:
+ sys.exit(0)
+
+brave = data.setdefault("brave", {})
+if brave.get("widevine_opted_in") is True:
+ sys.exit(0)
+
+brave["widevine_opted_in"] = True
+tmp = path + ".tmp"
+with open(tmp, "w", encoding="utf-8") as f:
+ json.dump(data, f, separators=(",", ":"), ensure_ascii=False)
+os.replace(tmp, path)
+PY
diff --git a/www/linux-brave/files/brave.json b/www/linux-brave/files/brave.json
--- a/www/linux-brave/files/brave.json
+++ b/www/linux-brave/files/brave.json
@@ -1,3 +1,4 @@
{
- "BraveRewardsDisabled": true
+ "BraveRewardsDisabled": true,
+ "CommandLineFlagSecurityWarningsEnabled": false
}
diff --git a/www/linux-brave/pkg-message b/www/linux-brave/pkg-message
new file mode 100644
--- /dev/null
+++ b/www/linux-brave/pkg-message
@@ -0,0 +1,31 @@
+[
+{ type: install
+ message: <<EOM
+www/linux-brave runs under the Linuxulator (linux_base-rl9):
+
+ sysrc linux_enable=YES
+ service linux start
+
+For DRM sites such as Netflix, install www/linux-widevine-cdm from
+the ports tree (Google's license does not permit distributing it as
+a package):
+
+ make -C /usr/ports/www/linux-widevine-cdm install clean
+
+With the default WIDEVINE option, no further setup is needed: DRM
+playback works as soon as the CDM is installed.
+
+For hardware acceleration, install the Linux Mesa DRI drivers and
+the Linux Vulkan loader:
+
+ pkg install linux-rl9-dri linux-rl9-vulkan
+
+With both present and a writable DRM render node, the wrapper
+renders via ANGLE-on-Vulkan, the preferred path; the Mesa GL path
+is prone to GPU hangs on some hardware. Without a hardware Vulkan
+driver the wrapper falls back to GL, and without a render node or
+DRI drivers to software rendering. BRAVE_GPU=0 forces software
+rendering; BRAVE_VULKAN=0 stays on GL.
+EOM
+}
+]
diff --git a/www/linux-brave/pkg-plist b/www/linux-brave/pkg-plist
--- a/www/linux-brave/pkg-plist
+++ b/www/linux-brave/pkg-plist
@@ -1,6 +1,7 @@
/%%ETCDIR%%/policies/managed/brave.json
/%%ETCDIR%%/policies/managed/webrtc.json
bin/brave-browser
+%%WIDEVINE%%bin/brave-widevine-seed
share/appdata/brave-browser.appdata.xml
share/applications/brave-browser.desktop
share/applications/com.brave.Browser.desktop
@@ -174,6 +175,7 @@
%%DATADIR%%/resources/brave_extension/_locales/zh_TW/messages.json
%%DATADIR%%/v8_context_snapshot.bin
%%DATADIR%%/vk_swiftshader_icd.json
+%%WIDEVINE%%%%DATADIR%%/WidevineCdm
share/gnome-control-center/default-apps/brave-browser.xml
share/icons/hicolor/128x128/apps/brave-browser.png
share/icons/hicolor/16x16/apps/brave-browser.png
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Aug 20, 3:08 PM (7 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
36998629
Default Alt Text
D58784.id.diff (11 KB)
Attached To
Mode
D58784: www/linux-brave: DRM out of the box, GPU auto-detection
Attached
Detach File
Event Timeline
Log In to Comment