-
Notifications
You must be signed in to change notification settings - Fork 88
feat(linux): make a wry build #1852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
eleboucher
wants to merge
4
commits into
dev
Choose a base branch
from
feat/wry-embedded-webkit
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
af0121c
feat(linux): embed a WebRTC-enabled WebKitGTK in wry builds
eleboucher 71c9e4a
fix(webkit): pin the built runtime and fix the manifest read
eleboucher c9dc4cc
fix(webkit): keep the host's GStreamer plugins out of the bundled run…
eleboucher bdfa905
fix(webkit): declare the host libraries the runtime actually needs
eleboucher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # yaml-language-server: $schema=https://nfpm.goreleaser.com/schema.json | ||
| # wry flavour. The embedded WebKit runtime carries its own private libraries | ||
| # (ICU, libsoup3, GStreamer, bwrap), so the only dependencies left are the ones | ||
| # the app and the engine must share a single instance of. | ||
|
|
||
| name: sable | ||
| arch: ${PKG_ARCH} | ||
| platform: linux | ||
| version: ${PKG_VERSION} | ||
| release: ${PKG_RELEASE} | ||
| version_schema: semver | ||
| section: net | ||
| maintainer: SableClient | ||
| description: Sable, a Matrix client | ||
| homepage: https://sable.moe | ||
|
|
||
| contents: | ||
| - src: ${PKGROOT}/opt/sable/ | ||
| dst: /opt/sable | ||
| type: tree | ||
| expand: true | ||
| - src: ${PKGROOT}/usr/ | ||
| dst: /usr | ||
| type: tree | ||
| expand: true | ||
| - src: src-tauri/packaging/deb/apparmor/sable | ||
| dst: /etc/apparmor.d/sable | ||
| type: config | ||
| packager: deb | ||
|
|
||
| overrides: | ||
| deb: | ||
| scripts: | ||
| postinstall: src-tauri/packaging/deb/postinst | ||
| preremove: src-tauri/packaging/deb/prerm | ||
| depends: | ||
| - apparmor | ||
| - libgtk-3-0 | ||
| - libglib2.0-0 | ||
| - libcairo2 | ||
| - libpango-1.0-0 | ||
| - libgdk-pixbuf-2.0-0 | ||
| - libatk1.0-0 | ||
| - libharfbuzz0b | ||
| - libfreetype6 | ||
| - libfontconfig1 | ||
| - libx11-6 | ||
| - libgl1 | ||
| - libegl1 | ||
| - libxkbcommon0 | ||
| - xdg-utils | ||
| - libayatana-appindicator3-1 | ||
| rpm: | ||
| depends: | ||
| - gtk3 | ||
| - glib2 | ||
| - cairo | ||
| - pango | ||
| - gdk-pixbuf2 | ||
| - atk | ||
| - harfbuzz | ||
| - freetype | ||
| - fontconfig | ||
| - libX11 | ||
| - mesa-libGL | ||
| - mesa-libEGL | ||
| - libxkbcommon | ||
| - xdg-utils | ||
| - libayatana-appindicator3.so.1()(64bit) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| #!/usr/bin/env bash | ||
| #MISE description="Copy the WebRTC WebKitGTK runtime next to the built binary" | ||
| # Copy the portable WebKitGTK runtime next to a built binary so wry builds get | ||
| # WebRTC regardless of the host's webkit2gtk. The bundle carries its own rpaths | ||
| # and private dependencies. | ||
| # | ||
| # Usage: scripts/webkit/copy-libs.sh [debug|release] [dest-dir] | ||
| # dest-dir defaults to src-tauri/target/<profile> (beside the built binary). | ||
| set -euo pipefail | ||
| PROFILE="${1:-debug}" | ||
| ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" | ||
| DEST="${2:-$ROOT/src-tauri/target/$PROFILE}" | ||
|
|
||
| if [ "$(uname -m)" != x86_64 ]; then | ||
| echo "❌ the WebKit runtime is only built for x86_64 (got $(uname -m))." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| SRC="${SABLE_WEBKIT_RUNTIME_DIR:-}" | ||
| if [ -z "$SRC" ]; then | ||
| CACHE="$ROOT/src-tauri/target/webkit-runtime" | ||
| bash "$ROOT/scripts/webkit/fetch.sh" "$CACHE" | ||
| SRC="$CACHE/runtime" | ||
| fi | ||
|
|
||
| WEBKIT_LIB="$SRC/libwebkit2gtk-4.1.so.0" | ||
| [ -f "$WEBKIT_LIB" ] || { | ||
| echo "❌ libwebkit2gtk-4.1.so.0 not found in $SRC." >&2 | ||
| exit 1 | ||
| } | ||
|
|
||
| # Without the patch the library silently forks the host's helpers instead. | ||
| # Process substitution, not a pipe: grep -q exits early and SIGPIPEs strings, | ||
| # which trips pipefail. | ||
| if ! grep -qx WEBKIT_EXEC_PATH < <(strings -a "$WEBKIT_LIB"); then | ||
| echo "❌ $WEBKIT_LIB was built without relocatable-exec-path.patch." >&2 | ||
| echo " Re-pin scripts/webkit/runtime.json at a patched build." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| NEED="$(node -e 'process.stdout.write(require(process.argv[1]).glibc_floor)' \ | ||
| "$SRC/runtime.json" 2>/dev/null || echo 0)" | ||
| HAVE="$(ldd --version | sed -n '1s/.*[^0-9]\([0-9]\+\.[0-9]\+\)$/\1/p')" | ||
| if [ "$(printf '%s\n%s\n' "$NEED" "$HAVE" | sort -V | tail -1)" != "$HAVE" ]; then | ||
| echo "❌ runtime needs glibc $NEED, this host has $HAVE." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| rm -rf "$DEST/webkit" | ||
| mkdir -p "$DEST" | ||
| cp -a "$SRC" "$DEST/webkit" | ||
|
|
||
| echo "✅ WebKit runtime staged in $DEST/webkit (glibc floor $NEED)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| #!/usr/bin/env bash | ||
| #MISE description="Download the WebRTC-enabled WebKitGTK runtime" | ||
| # Downloads the pinned webkitgtk-webrtc portable artifact into a cache dir. | ||
| # | ||
| # Usage: scripts/webkit/fetch.sh [cache-dir] | ||
| # cache-dir defaults to src-tauri/target/webkit-runtime. | ||
| # | ||
| # Override the source with SABLE_WEBKIT_ARTIFACT_URL, or point | ||
| # SABLE_WEBKIT_RUNTIME_DIR at an already-unpacked tree to skip this entirely. | ||
| set -euo pipefail | ||
| ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" | ||
| CACHE="${1:-$ROOT/src-tauri/target/webkit-runtime}" | ||
| MANIFEST="$ROOT/scripts/webkit/runtime.json" | ||
|
|
||
| read -r REPO RUN ARTIFACT VERSION < <( | ||
| node -e ' | ||
| const m = require(process.argv[1]); | ||
| process.stdout.write([m.repository, m.run, m.artifact, m.version].join(" ") + "\n"); | ||
| ' "$MANIFEST" | ||
| ) | ||
|
|
||
| URL="${SABLE_WEBKIT_ARTIFACT_URL:-$REPO/actions/runs/$RUN/artifacts/$ARTIFACT}" | ||
| STAMP="$CACHE/.stamp" | ||
| WANT="$URL $VERSION" | ||
|
|
||
| if [ -f "$STAMP" ] && [ "$(cat "$STAMP")" = "$WANT" ]; then | ||
| echo "→ WebKit runtime already cached in $CACHE" | ||
| exit 0 | ||
| fi | ||
|
|
||
| WORK="$(mktemp -d)" | ||
| trap 'rm -rf "$WORK"' EXIT | ||
|
|
||
| echo "→ downloading $URL" | ||
| curl -fL --retry 3 --progress-bar -o "$WORK/artifact.zip" "$URL" | ||
| unzip -q -j "$WORK/artifact.zip" -d "$WORK" | ||
|
|
||
| TARBALL="$(find "$WORK" -maxdepth 1 -name '*-portable-*.tar.zst' -print -quit)" | ||
| [ -n "$TARBALL" ] || { | ||
| echo "❌ no portable runtime tarball in the artifact." >&2 | ||
| exit 1 | ||
| } | ||
|
|
||
| rm -rf "$CACHE" | ||
| mkdir -p "$CACHE" | ||
| tar --zstd -xf "$TARBALL" -C "$CACHE" | ||
|
|
||
| echo "$WANT" > "$STAMP" | ||
| echo "✅ WebKit runtime $VERSION unpacked into $CACHE" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.