Update the build script to put the Orca extension into place.
Still need to do the symlinking yourself though.
This commit is contained in:
1 parent
044c1063d7
commit
e920543dcb
4 files changed
+213
-11
No files matched your search
@@ -104,7 +104,15 @@ Use `./build.sh -r` to remove the local installation, or
|
||||
`sudo ./build.sh -r` to remove the system installation. If a user has no local
|
||||
installation but a system installation exists, the script requests the latter
|
||||
command without running sudo itself. Removal deletes only the five helper
|
||||
files and leaves other directory contents untouched.
|
||||
files and the Orca extension files described below, and leaves other directory
|
||||
contents untouched.
|
||||
|
||||
When Orca 51 or later is installed, the script also installs the
|
||||
[Orca extension](orca/README.md) files to
|
||||
`$prefix/share/wine-access/orca/wine_access/` and prints the commands each
|
||||
user runs to link that copy into their Orca extension directory and approve
|
||||
it. Without a suitable Orca, the extension is skipped and only the helper is
|
||||
installed; rerun the script after installing Orca to add it.
|
||||
|
||||
Alternative build and install locations may be supplied as positional
|
||||
arguments. The second argument is the installation prefix, not the final
|
||||
@@ -341,6 +349,14 @@ What a supervisor must get right for Proton prefixes:
|
||||
reader's own bus address, not the game's. The game's `DISPLAY` and the
|
||||
server's sync mode (`WINEESYNC`/`WINEFSYNC`) must match the game's;
|
||||
copy them from a game process in the same prefix.
|
||||
- **Use a helper path the container's wineserver can see.** That server
|
||||
resolves unix paths in the container, whose `/usr` is the Steam
|
||||
Runtime, so a system-installed `/usr/libexec/wine-access` helper cannot
|
||||
be opened (`ShellExecuteEx failed: File not found` in the helper log).
|
||||
The home directory is bound at the same path in both namespaces: a
|
||||
user-local installation under `~/.local/libexec` works as-is, and the
|
||||
Orca extension stages a copy of a system installation under
|
||||
`~/.local/state/orca-wine-access/helper/` for such prefixes.
|
||||
|
||||
The Orca extension in this repository implements all of this. Cthulhu's
|
||||
supervisor needs the equivalent loader resolution in Cthulhu itself; until
|
||||
|
||||
@@ -5,7 +5,7 @@ set -euo pipefail
|
||||
usage() {
|
||||
echo "Usage: $0 [-r] [build-directory [install-prefix]]"
|
||||
echo "Build and install locally as a user, or system wide as root."
|
||||
echo " -r Remove the installed helper instead of building."
|
||||
echo " -r Remove the installed helper and Orca extension instead of building."
|
||||
echo " -h Show this help."
|
||||
}
|
||||
|
||||
@@ -35,6 +35,9 @@ prefix=${2:-"$defaultPrefix"}
|
||||
installDir="${prefix%/}/libexec/wine-access"
|
||||
installedFiles=(wine-access.exe wine-access.exe.so wine-access-menu.dll
|
||||
wine-access-menu32.dll wine-access-menu-host32.exe)
|
||||
orcaSourceDir="$projectDir/orca/wine_access"
|
||||
orcaInstallDir="${prefix%/}/share/wine-access/orca/wine_access"
|
||||
systemOrcaInstallDir="$systemPrefix/share/wine-access/orca/wine_access"
|
||||
|
||||
has_installation() {
|
||||
local candidateDir=$1
|
||||
@@ -47,16 +50,40 @@ has_installation() {
|
||||
return 1
|
||||
}
|
||||
|
||||
has_orca_extension() {
|
||||
local candidateDir=$1
|
||||
local extensionFile
|
||||
for extensionFile in "$orcaSourceDir/"*.py; do
|
||||
if [[ -e $extensionFile ]] && [[ -e "$candidateDir/${extensionFile##*/}" || -L "$candidateDir/${extensionFile##*/}" ]]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
if "$removeInstalled"; then
|
||||
removedAny=false
|
||||
if has_installation "$installDir"; then
|
||||
for installedFile in "${installedFiles[@]}"; do
|
||||
rm -f -- "$installDir/$installedFile"
|
||||
done
|
||||
echo "Removed Wine Access from $installDir"
|
||||
elif (( EUID != 0 && $# < 2 )) && has_installation "$systemPrefix/libexec/wine-access"; then
|
||||
echo "Only a system-wide installation was found. Run: sudo ./build.sh -r" >&2
|
||||
exit 1
|
||||
else
|
||||
removedAny=true
|
||||
fi
|
||||
if has_orca_extension "$orcaInstallDir"; then
|
||||
for extensionFile in "$orcaSourceDir/"*.py; do
|
||||
if [[ -e $extensionFile ]]; then
|
||||
rm -f -- "$orcaInstallDir/${extensionFile##*/}"
|
||||
fi
|
||||
done
|
||||
echo "Removed Wine Access Orca extension from $orcaInstallDir"
|
||||
removedAny=true
|
||||
fi
|
||||
if ! "$removedAny"; then
|
||||
if (( EUID != 0 && $# < 2 )) && { has_installation "$systemPrefix/libexec/wine-access" || has_orca_extension "$systemOrcaInstallDir"; }; then
|
||||
echo "Only a system-wide installation was found. Run: sudo ./build.sh -r" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "No Wine Access installation found in $installDir"
|
||||
fi
|
||||
exit 0
|
||||
@@ -103,6 +130,39 @@ check_prerequisites() {
|
||||
fi
|
||||
}
|
||||
|
||||
install_orca_extension() {
|
||||
if ! command -v orca >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
local versionOutput majorVersion=""
|
||||
versionOutput=$(orca --version 2>/dev/null || true)
|
||||
if [[ $versionOutput =~ [Vv]ersion[[:space:]]+([0-9]+) ]]; then
|
||||
majorVersion=${BASH_REMATCH[1]}
|
||||
fi
|
||||
if [[ -z $majorVersion ]]; then
|
||||
echo "Orca was found, but its version could not be determined." >&2
|
||||
echo "Skipping the Wine Access Orca extension, which requires Orca 51 or later." >&2
|
||||
return 0
|
||||
fi
|
||||
if (( 10#$majorVersion < 51 )); then
|
||||
echo "Orca $majorVersion was found, but the Wine Access Orca extension requires Orca 51 or later; skipping it."
|
||||
return 0
|
||||
fi
|
||||
|
||||
local extensionFile
|
||||
for extensionFile in "$orcaSourceDir/"*.py; do
|
||||
install -Dm644 "$extensionFile" "$orcaInstallDir/${extensionFile##*/}"
|
||||
done
|
||||
echo "Installed the Wine Access Orca extension to $orcaInstallDir"
|
||||
echo "Orca discovers extensions only in each user's extension directory."
|
||||
echo "To enable it, run as your normal user:"
|
||||
echo " mkdir -p \"\${XDG_DATA_HOME:-\$HOME/.local/share}/orca/extensions\""
|
||||
echo " ln -sT $orcaInstallDir \"\${XDG_DATA_HOME:-\$HOME/.local/share}/orca/extensions/wine_access\""
|
||||
echo " orca --approve-extension wine_access"
|
||||
echo "Then restart Orca. If wine_access already exists in that directory,"
|
||||
echo "move it aside first, and approve again after each Wine Access update."
|
||||
}
|
||||
|
||||
check_prerequisites
|
||||
|
||||
cmake \
|
||||
@@ -115,3 +175,4 @@ cmake \
|
||||
-DWINE_ACCESS_INSTALL_DIR:PATH=libexec/wine-access
|
||||
cmake --build "$buildDir" --parallel
|
||||
cmake --install "$buildDir"
|
||||
install_orca_extension
|
||||
+22
-5
@@ -30,8 +30,23 @@ must be installed separately; it is an optional package dependency.
|
||||
|
||||
### Manual installation
|
||||
|
||||
1. Build and install the helper as described in the main README.
|
||||
2. Copy `orca/wine_access/` to `~/.local/share/orca/extensions/`.
|
||||
1. Build and install the helper with `./build.sh` while Orca 51 or later is
|
||||
installed. The script installs the extension files under
|
||||
`$prefix/share/wine-access/orca/wine_access/` (`~/.local/share/...` for a
|
||||
user build, `/usr/share/...` for a system build) and prints the remaining
|
||||
commands. If Orca was not installed at build time, rerun `./build.sh`.
|
||||
2. Link that copy into your Orca extension directory, as in the package
|
||||
instructions above, using your installation prefix. For a user build:
|
||||
|
||||
```sh
|
||||
mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/orca/extensions"
|
||||
ln -sT "$HOME/.local/share/wine-access/orca/wine_access" \
|
||||
"${XDG_DATA_HOME:-$HOME/.local/share}/orca/extensions/wine_access"
|
||||
```
|
||||
|
||||
Copying `orca/wine_access/` from the source tree to
|
||||
`~/.local/share/orca/extensions/` also works, but the copy is not updated
|
||||
by later builds.
|
||||
3. Approve it with `orca --approve-extension wine_access` and restart Orca.
|
||||
Approval records a hash of the package; approve again after any update.
|
||||
|
||||
@@ -78,9 +93,11 @@ wine-access.exe --reader orca --reader-path /org/gnome/Orca1/Service/WineAccess
|
||||
with the program's own loader, display and bus, and
|
||||
`ORCA_WINE_ACCESS_MANAGED=1`. For Steam Play and Protontricks launches the
|
||||
loader is resolved to the game's real Proton `files/bin/wine` (Protontricks'
|
||||
proxy `WINELOADER` is bypassed) and the game's `WINEESYNC`/`WINEFSYNC` are
|
||||
forwarded so the helper joins the running server; see the main README's
|
||||
Steam section. A helper stops 10 seconds after its prefix
|
||||
proxy `WINELOADER` is bypassed), the game's `WINEESYNC`/`WINEFSYNC` are
|
||||
forwarded so the helper joins the running server, and the helper set is
|
||||
staged under the state directory because the container's wineserver cannot
|
||||
see a system `/usr/libexec` installation; see the main README's Steam
|
||||
section. A helper stops 10 seconds after its prefix
|
||||
goes idle and restarts with exponential backoff after quick failures. Helpers
|
||||
run in their own session and survive an Orca restart, so a newly loaded
|
||||
extension retires a marked helper it did not start before starting its own.
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
"""Check build.sh installs the Orca extension only when Orca 51+ is present.
|
||||
|
||||
The real compile is replaced with a stub cmake and stub prerequisites, so
|
||||
this runs without Wine. Orca itself is a stub whose --version output is
|
||||
controlled per case; one case uses a PATH with no orca at all.
|
||||
"""
|
||||
from pathlib import Path
|
||||
import os
|
||||
import shutil
|
||||
import stat
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
|
||||
projectDir = Path(__file__).resolve().parents[1]
|
||||
sourceFiles = sorted((projectDir / "orca/wine_access").glob("*.py"))
|
||||
assert sourceFiles, "Orca extension sources missing"
|
||||
|
||||
PREREQUISITES = ["cmake", "make", "gcc", "g++", "pkg-config", "winegcc",
|
||||
"wineg++", "widl", "x86_64-w64-mingw32-gcc",
|
||||
"i686-w64-mingw32-gcc"]
|
||||
REAL_TOOLS = ["dirname", "install", "rm"]
|
||||
|
||||
|
||||
def write_stub(directory, name, body="#!/bin/sh\nexit 0\n"):
|
||||
stub = directory / name
|
||||
stub.write_text(body)
|
||||
stub.chmod(0o755)
|
||||
|
||||
|
||||
with tempfile.TemporaryDirectory(prefix="wine-access-build-sh-") as temporary:
|
||||
temporary = Path(temporary)
|
||||
|
||||
def make_bin(orca_version):
|
||||
"""A PATH directory with every tool build.sh needs, plus stub orca."""
|
||||
binDir = Path(tempfile.mkdtemp(dir=temporary, prefix="bin-"))
|
||||
for tool in REAL_TOOLS:
|
||||
(binDir / tool).symlink_to(shutil.which(tool))
|
||||
for tool in PREREQUISITES:
|
||||
write_stub(binDir, tool)
|
||||
if orca_version is not None:
|
||||
write_stub(binDir, "orca",
|
||||
"#!/bin/sh\n"
|
||||
f'echo "Orca version {orca_version} (rev test), '
|
||||
'AT-SPI2 version: 2.0"\n')
|
||||
return binDir
|
||||
|
||||
def run_build_sh(binDir, prefix, *extra):
|
||||
environment = {"PATH": str(binDir), "HOME": str(temporary / "home")}
|
||||
result = subprocess.run(
|
||||
["/bin/bash", str(projectDir / "build.sh"), *extra,
|
||||
str(temporary / "build"), str(prefix)],
|
||||
capture_output=True, text=True, env=environment)
|
||||
assert result.returncode == 0, result.stdout + result.stderr
|
||||
return result
|
||||
|
||||
def extension_dir(prefix):
|
||||
return prefix / "share/wine-access/orca/wine_access"
|
||||
|
||||
# Orca 51 present: the shared copy is installed, identical to the
|
||||
# sources, with the per-user link/approve commands printed. The user
|
||||
# extension directory itself must not be created.
|
||||
prefix = temporary / "prefix51"
|
||||
result = run_build_sh(make_bin("51.2"), prefix)
|
||||
for source in sourceFiles:
|
||||
installed = extension_dir(prefix) / source.name
|
||||
assert installed.read_bytes() == source.read_bytes(), installed
|
||||
assert stat.S_IMODE(installed.stat().st_mode) == 0o644, installed
|
||||
assert "orca --approve-extension wine_access" in result.stdout
|
||||
assert f"ln -sT {extension_dir(prefix)}" in result.stdout
|
||||
assert not (temporary / "home/.local/share/orca").exists()
|
||||
|
||||
# Removal with no orca on PATH still removes the extension files and
|
||||
# the helper, and leaves unrelated files in place.
|
||||
helper = prefix / "libexec/wine-access/wine-access.exe"
|
||||
helper.parent.mkdir(parents=True)
|
||||
helper.write_text("helper\n")
|
||||
stray = extension_dir(prefix) / "keep.txt"
|
||||
stray.write_text("keep\n")
|
||||
run_build_sh(make_bin(None), prefix, "-r")
|
||||
assert not helper.exists()
|
||||
for source in sourceFiles:
|
||||
assert not (extension_dir(prefix) / source.name).exists(), source
|
||||
assert stray.read_text() == "keep\n"
|
||||
|
||||
# Removal also works when only the extension copy remains.
|
||||
prefix = temporary / "prefixOnlyOrca"
|
||||
run_build_sh(make_bin("51.2"), prefix)
|
||||
result = run_build_sh(make_bin(None), prefix, "-r")
|
||||
assert "No Wine Access installation" not in result.stdout
|
||||
for source in sourceFiles:
|
||||
assert not (extension_dir(prefix) / source.name).exists(), source
|
||||
|
||||
# Orca older than 51: the helper install still succeeds, but no
|
||||
# extension copy is installed and the reason is reported.
|
||||
prefix = temporary / "prefix50"
|
||||
result = run_build_sh(make_bin("50.1"), prefix)
|
||||
assert not extension_dir(prefix).exists()
|
||||
assert "51" in result.stdout + result.stderr
|
||||
|
||||
# No orca at all: nothing Orca-related is installed or printed as
|
||||
# an instruction.
|
||||
prefix = temporary / "prefixNone"
|
||||
result = run_build_sh(make_bin(None), prefix)
|
||||
assert not extension_dir(prefix).exists()
|
||||
assert "--approve-extension" not in result.stdout
|
||||
|
||||
print("PASS: build.sh installs and removes the Orca extension conditionally")
|
||||
Reference in new issue
Block a user