~fd/public-inbox

[PATCH mc-bwrap] Make it work under Arch Linux

Details
Message ID
<CTQ6FL56B79A.35FX77R0QEJY8@blackbox>
DKIM signature
missing
Download raw message
Thanks for introducing me to bubblewrap. I tweaked your mc-bwrap script to
bind /etc/java-*-openjdk/amd64/jvm.cfg and symlink usr/lib to /lib64.
Without that, Minecraft doesn't start on my Arch Linux system.

I also fixed undefined environment variables like $RUN_USER, which I have
never seen before, and replaced some instances of `which` with `command -v`
for portability and performance (`which` is not a shell builtin).

I couldn't get X11 isolation to work, it immediately fails with

    Error: A JNI error has occurred, please check your installation and try again
    Exception in thread "main" 
    java.lang.UnsatisfiedLinkError: /usr/lib/jvm/java-8-openjdk/jre/lib/amd64/libnio.so: /usr/lib/jvm/java-8-openjdk/jre/lib/amd64/libnio.so: undefined symbol: NET_Bind, version SUNWprivate_1.1

but I don't care too much about it.
---
--- a/mc-bwrap
+++ b/mc-bwrap
@@ -10,6 +10,11 @@
 DISABLE_X=false # If using Minecraft on pure Wayland
 ISOLATED_DISPLAY=39 # Should not need to change
 
+: "${XDG_CONFIG_HOME:=$HOME/.config}"
+: "${XDG_CACHE_HOME:=$HOME/.cache}"
+: "${XDG_DATA_HOME:=$HOME/.local/share}"
+: "${XDG_STATE_HOME:=$HOME/.local/state}"
+
 if [[ "$ISOLATE_X" = "true" ]]; then
 	echo "Isolating X!"
 	if [ -z ${WAYLAND_DISPLAY+x} ]; then echo "Isolating X requires Wayland!"; exit 1; fi
@@ -22,7 +27,8 @@
 	unset DISPLAY
 fi
 
-if [ ! $(which bwrap 2>/dev/null) ]; then echo "bwrap not found! Install bubblewrap!"; exit 1; fi
+if ! command -v bwrap &>/dev/null; then echo "bwrap not found! Install bubblewrap!"; exit 1; fi
+if [ "$ISOLATE_X" == "true" ] && ! command -v vglrun &>/dev/null; then echo "vglrun not found! Install virtualgl!"; exit 1; fi
 
 if [ -z ${LAUNCHER_DIR+x} ]; then echo "LAUNCHER_DIR is unset! It needs to be set in the code. Edit this shell file and read the instructions."; exit 1; fi
 if [ -z ${INST_DIR+x} ]; then echo "INST_DIR is unset. Use this script from PrismLauncher."; exit 1; fi
@@ -51,7 +57,7 @@
 	--tmpfs /tmp
 	--proc /proc
 	--dev /dev
-	--dir "$RUN_USER"
+	--dir "$XDG_RUNTIME_DIR"
 	--dir "$HOME"
 	--dir "$XDG_CONFIG_HOME"
 	--dir "$XDG_CACHE_HOME"
@@ -61,6 +67,7 @@
 	--share-net \
 	--die-with-parent \
 	--new-session \
+	--symlink usr/lib /lib64 \
 )
 
 robind \
@@ -74,9 +81,9 @@
 
 bind \
 	"$HOME/.Xauthority" \
-	"$RUN_USER"/pipewire* \
-	"$RUN_USER"/pulse* \
-	"$RUN_USER"/wayland* \
+	"$XDG_RUNTIME_DIR"/pipewire* \
+	"$XDG_RUNTIME_DIR"/pulse* \
+	"$XDG_RUNTIME_DIR"/wayland* \
 	"$XDG_CACHE_HOME/mesa_shader_cache" \
 	"$XDG_CACHE_HOME/nv" \
 	"$XDG_CACHE_HOME/nvidia" \
@@ -84,7 +91,8 @@
 	"$XDG_CONFIG_HOME/MangoHud" \
 	"$XDG_CONFIG_HOME/pulse" \
 	"$XDG_CONFIG_HOME/unity3d" \
-	"$INST_DIR"
+	"$INST_DIR" \
+	/etc/java-*-openjdk/amd64/jvm.cfg
 
 if [ "$ISOLATE_X" = "true" ]; then
 	bind /tmp/.X11-unix/X$ISOLATED_DISPLAY
Reply to thread Export thread (mbox)