Arch: robust AGS v1.9.0 fix — env wrapper + hardened launcher patching

Problem
- AGS v1 under GJS ESM ignores GIR Repository.prepend_*; typelibs in /usr/local aren’t discovered reliably.
- On Arch, users may install AGS into /usr/local while system typelibs can also live under /usr/lib64/ags or /usr/lib/ags.

Solution
- Keep the tolerant ESM patcher (no-op safe): remove deprecated GIR repo calls; ensure GLib import; inject GI_TYPELIB_PATH via GLib.setenv when editing the ESM main.
- Add a distro-agnostic wrapper at /usr/local/bin/ags that sets:
  - GI_TYPELIB_PATH=/usr/local/lib64/girepository-1.0:/usr/local/lib/girepository-1.0:/usr/lib64/girepository-1.0:/usr/lib/girepository-1.0:/usr/local/lib64:/usr/local/lib:/usr/lib64/ags:/usr/lib/ags:$GI_TYPELIB_PATH
  - LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib:$LD_LIBRARY_PATH
  Then execs: /usr/bin/gjs -m "$MAIN_JS" (resolved under /usr/local/share or /usr/share).

Why
- Ensures AGS v1 runs reliably on Arch without depending solely on fragile in-place edits; mirrors the working Fedora fix.

File
- install-scripts/ags.sh
This commit is contained in:
Don Williams
2025-11-03 17:08:58 -05:00
parent a9e33e5c58
commit 7afaf65973

View File

@@ -99,6 +99,23 @@ if git clone --depth=1 https://github.com/JaKooLit/ags_v1.9.0.git; then
sudo awk '{print} $0 ~ /^import GLib from "gi:\/\/GLib";$/ {print "const __old = GLib.getenv(\"GI_TYPELIB_PATH\");"; print "GLib.setenv(\"GI_TYPELIB_PATH\", \"/usr/local/lib\" + (__old ? \":\" + __old : \"\"), true);"}' "$LAUNCHER" | sudo tee "$LAUNCHER" >/dev/null sudo awk '{print} $0 ~ /^import GLib from "gi:\/\/GLib";$/ {print "const __old = GLib.getenv(\"GI_TYPELIB_PATH\");"; print "GLib.setenv(\"GI_TYPELIB_PATH\", \"/usr/local/lib\" + (__old ? \":\" + __old : \"\"), true);"}' "$LAUNCHER" | sudo tee "$LAUNCHER" >/dev/null
printf "${OK} AGS launcher patched.\n" printf "${OK} AGS launcher patched.\n"
# Create an env-setting wrapper for AGS to ensure GI typelibs/libs are discoverable
printf "${NOTE} Creating env wrapper /usr/local/bin/ags...\n"
MAIN_JS="/usr/local/share/com.github.Aylur.ags/com.github.Aylur.ags"
if ! sudo test -f "$MAIN_JS"; then
MAIN_JS="/usr/share/com.github.Aylur.ags/com.github.Aylur.ags"
fi
sudo tee /usr/local/bin/ags >/dev/null <<WRAP
#!/usr/bin/env bash
set -euo pipefail
# Ensure GI typelibs and native libs are discoverable before gjs ESM loads
export GI_TYPELIB_PATH="/usr/local/lib64/girepository-1.0:/usr/local/lib/girepository-1.0:/usr/lib64/girepository-1.0:/usr/lib/girepository-1.0:/usr/local/lib64:/usr/local/lib:/usr/lib64/ags:/usr/lib/ags:${GI_TYPELIB_PATH:-}"
export LD_LIBRARY_PATH="/usr/local/lib64:/usr/local/lib:${LD_LIBRARY_PATH:-}"
exec /usr/bin/gjs -m "$MAIN_JS" "$@"
WRAP
sudo chmod 0755 /usr/local/bin/ags
printf "${OK} AGS wrapper installed at /usr/local/bin/ags\n"
else else
printf "${WARN} Launcher not found at $LAUNCHER, skipping patch.\n" printf "${WARN} Launcher not found at $LAUNCHER, skipping patch.\n"
fi fi