Page MenuHomeFreeBSD

D58784.id183896.diff
No OneTemporary

D58784.id183896.diff

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,53 @@
LICENSE= MPL20
-RUN_DEPENDS= update-mime-database:misc/shared-mime-info
+ONLY_FOR_ARCHS= aarch64 amd64
+
+RUN_DEPENDS= dbus-launch: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+= BRAVE_WIDEVINE=yes \
+ PYTHON_CMD=${PYTHON_CMD}
+.else
+SUB_LIST+= BRAVE_WIDEVINE=no
+.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 +80,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
@@ -10,11 +10,105 @@
)
}
+#
+# 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" ]
+}
+
+# Chromium helpers follow /proc/self/exe, which for a Linux binary
+# outside the emulator root resolves via the native /proc. Refuse to
+# start without it rather than fail in a hard-to-diagnose way.
+if [ ! -e /proc/self/exe ]; then
+ cat >&2 <<-EOF
+ brave-browser: procfs(5) is not mounted at /proc.
+
+ Chromium helpers follow /proc/self/exe and cannot start without it:
+
+ sudo mount -t procfs proc /proc
+
+ Add the following line to /etc/fstab to make it permanent:
+
+ proc /proc procfs rw 0 0
+ EOF
+ exit 1
+fi
+
+# Re-exec under a session bus when none is present (many WMs have
+# none). dbus-launch exports DBUS_SESSION_BUS_ADDRESS to the child,
+# so the re-exec cannot loop.
+if [ ! "${DBUS_SESSION_BUS_ADDRESS-}" ] &&
+ command -v dbus-launch > /dev/null 2>&1
+then
+ exec dbus-launch --exit-with-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"
+
+# Host ports fonts via Linuxulator ENOENT fallthrough (not /etc/fonts:
+# some helpers still miss the emulator-root copy).
+export FONTCONFIG_FILE="${FONTCONFIG_FILE:-/usr/local/etc/fonts/fonts.conf}"
+export FONTCONFIG_PATH="${FONTCONFIG_PATH:-/usr/local/etc/fonts}"
+
+# Use /var/run, not /run: linux_base's /run -> /var/run absolute symlink
+# resolves under the emulator root and misses the host dbus socket.
+# Direct /var/run/... ENOENT-falls through to FreeBSD /var/run.
+if [ -S /var/run/dbus/system_bus_socket ]; then
+ export DBUS_SYSTEM_BUS_ADDRESS="${DBUS_SYSTEM_BUS_ADDRESS:-unix:path=/var/run/dbus/system_bus_socket}"
+fi
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, seed brave.widevine_opted_in and the
+# Widevine component hint once so DRM works from the very first launch.
+if [ "%%BRAVE_WIDEVINE%%" = "yes" ] &&
+ [ -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
+ ;;
+*) : ok
+esac
+if [ ! "$gpu" ]; then
+ set -- --disable-gpu --disable-gpu-compositing "$@"
+ export LIBGL_ALWAYS_SOFTWARE=1
+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,32 @@
+[
+{ type: install
+ message: <<EOM
+www/linux-brave runs under the Linuxulator (linux_base-rl9):
+
+ sysrc linux_enable=YES
+ service linux start
+
+Chromium helpers follow /proc/self/exe, which requires procfs(5)
+mounted at the native /proc:
+
+ mount -t procfs proc /proc
+
+Add the following to /etc/fstab to make it permanent:
+
+ proc /proc procfs rw 0 0
+
+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.
+
+The wrapper uses hardware GL when a writable DRM render node and the
+Linux Mesa DRI drivers (graphics/linux-rl9-dri) are present, software
+rendering otherwise; set BRAVE_GPU=1 or BRAVE_GPU=0 to override.
+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

Mime Type
text/plain
Expires
Thu, Aug 20, 10:55 PM (15 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37011880
Default Alt Text
D58784.id183896.diff (11 KB)

Event Timeline