Linux desktop: optimized release build, installer, Linux gaps
Build: split Dart debug info out of libapp.so (13.96 -> 11.27 MB, symbols kept in the cache) and fix icon tree shaking, which Flutter 3.44's Linux CMake backend silently disables by quoting the define; the build image patches its SDK copy (MaterialIcons 1.6 MB -> 25 KB). Impeller cannot be enabled in a Linux release build and was slower in a profile-build bench. Install: `./install --linux --install` installs the bundle into <prefix>/lib/app-linux with com.pipelines.app.desktop (the GTK/Wayland app id), its icon and a ~/.local/bin/pipelines-app link, through scripts/install-linux-app.sh. Linux gaps: notifications through the freedesktop daemon; HTML artifacts explain the missing web view instead of throwing; no Share for files; a GTK clipboard reader for pasting files and screenshots (Ctrl+V and Omarchy's Super+V); GTK header bar only on GNOME; window icon. Bench: native fixture frame log, wheel/mark steps and tool/perf/linux_desktop_bench.py (private Xvfb); results in app/notes/linux-desktop-optimized.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -431,6 +431,8 @@ def main(argv=None):
|
||||
parser.add_argument("--notes", default="", help="APK release notes shown in Check for updates")
|
||||
parser.add_argument("--publish", action="store_true", help="Publish desktop archive and update feed to this installation")
|
||||
parser.add_argument("--output", type=Path, help="Desktop archive output directory (default: build cache)")
|
||||
parser.add_argument("--install", action="store_true",
|
||||
help="Linux: also install the client for this user (<prefix>/lib/app-linux and a desktop entry)")
|
||||
parser.add_argument("--flutter", help="Native Flutter executable for macOS and Android (or PIPELINES_FLUTTER/PATH)")
|
||||
parser.add_argument("--verbose", action="store_true", help="Show full build and tool output")
|
||||
build_mode = parser.add_mutually_exclusive_group()
|
||||
@@ -448,7 +450,8 @@ def main(argv=None):
|
||||
bundle, archive = desktop.build_desktop(args.kind, app=APP, cache=default_cache(), runner=subprocess.run,
|
||||
source_digest=digest, docker_build=build, docker_ready=docker_available,
|
||||
server_url=args.server_url, flutter=args.flutter, output=args.output,
|
||||
prune_cache=prune, update_keys=update_signing.dart_defines())
|
||||
prune_cache=prune, update_keys=update_signing.dart_defines(),
|
||||
install=args.install, prefix=args.prefix)
|
||||
if args.publish:
|
||||
manifest = load_manifest(args.prefix)
|
||||
updates = (manifest.get("web") or {}).get("updates")
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
"""Standalone desktop client artifacts; never installs or restarts a server."""
|
||||
"""Standalone desktop client artifacts; never installs or restarts a server.
|
||||
|
||||
`install=True` (Linux only) also installs the client for the current user
|
||||
with scripts/install-linux-app.sh."""
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
@@ -39,7 +42,8 @@ def _linux_archive(entry):
|
||||
try:
|
||||
with tarfile.open(staged, "w:gz") as output:
|
||||
for child in sorted(entry.iterdir()):
|
||||
if child.name not in (".complete", archive.name, staged.name):
|
||||
# Split Dart debug symbols stay in the build cache.
|
||||
if child.name not in (".complete", ".debug-info", archive.name, staged.name):
|
||||
output.add(child, arcname=f"pipelines-linux-x64/{child.name}")
|
||||
os.replace(staged, archive)
|
||||
finally:
|
||||
@@ -120,7 +124,9 @@ def _macos_build(*, app, cache, source_digest, runner, arguments, flutter, log):
|
||||
|
||||
def build_desktop(kind, *, app, cache, runner, source_digest, docker_build,
|
||||
docker_ready, server_url=None, flutter=None, output=None, log=print,
|
||||
prune_cache=None, update_keys=()):
|
||||
prune_cache=None, update_keys=(), install=False, prefix=None):
|
||||
if install and kind != "linux":
|
||||
raise ValueError("--install installs the Linux client only")
|
||||
arguments = _arguments(server_url) + tuple(update_keys)
|
||||
if kind == "macos":
|
||||
entry, bundle, archive = _macos_build(app=app, cache=cache, runner=runner,
|
||||
@@ -150,10 +156,21 @@ def build_desktop(kind, *, app, cache, runner, source_digest, docker_build,
|
||||
archive = published
|
||||
log(f"Desktop client bundle: {bundle}")
|
||||
log(f"Desktop client archive: {archive}")
|
||||
if install:
|
||||
install_linux(archive, runner=runner, prefix=prefix)
|
||||
log("No server was installed or restarted. Choose your server in the app.")
|
||||
return bundle, archive
|
||||
|
||||
|
||||
def install_linux(archive, *, runner, prefix=None):
|
||||
"""Installs [archive] into <prefix>/lib/app-linux with a desktop entry."""
|
||||
script = Path(__file__).with_name("install-linux-app.sh")
|
||||
env = dict(os.environ)
|
||||
if prefix is not None:
|
||||
env["PIPELINES_PREFIX"] = str(Path(prefix).expanduser())
|
||||
_run(runner, ["sh", str(script), str(archive)], env=env, timeout=300)
|
||||
|
||||
|
||||
def publish_desktop(kind, bundle, archive, updates, *, signer, notes="", log=print):
|
||||
"""Publish archive before its feed; versioned names preserve in-flight reads.
|
||||
|
||||
|
||||
@@ -1,43 +1,55 @@
|
||||
#!/bin/sh
|
||||
# Installs the Pipelines Linux desktop app for the current user from a release
|
||||
# archive (pipelines-linux-x64-*.tar.gz from the update feed or the build cache):
|
||||
# scripts/install-linux-app.sh <archive.tar.gz> [icon.png]
|
||||
# The app lives in ~/.local/share/pipelines-app (writable, so in-app updates
|
||||
# can swap it), with a launcher in ~/.local/bin and a desktop entry. An existing
|
||||
# install is kept as pipelines-app.previous.
|
||||
# archive (pipelines-linux-x64*.tar.gz from `./install --linux`, the build
|
||||
# cache or the update feed):
|
||||
# scripts/install-linux-app.sh <archive.tar.gz>
|
||||
# `./install --linux --install` builds the archive and runs this.
|
||||
#
|
||||
# The app lives in <prefix>/lib/app-linux (prefix: $PIPELINES_PREFIX, default
|
||||
# ~/.local/share/pipelines), whose parent is writable so in-app updates can
|
||||
# swap it. A desktop entry named after the GTK application id
|
||||
# (com.pipelines.app.desktop) lets Wayland compositors, launchers and
|
||||
# notification daemons match the window and its icon; ~/.local/bin/pipelines-app
|
||||
# links the executable. An existing install is kept as app-linux.previous.
|
||||
set -eu
|
||||
archive=$1
|
||||
icon=${2:-}
|
||||
data=${XDG_DATA_HOME:-$HOME/.local/share}
|
||||
target=$data/pipelines-app
|
||||
staging=$data/.pipelines-app-install.$$
|
||||
prefix=${PIPELINES_PREFIX:-$HOME/.local/share/pipelines}
|
||||
target=$prefix/lib/app-linux
|
||||
app_id=com.pipelines.app
|
||||
mkdir -p "$prefix/lib"
|
||||
staging=$(mktemp -d "$prefix/lib/.app-linux-install.XXXXXX")
|
||||
trap 'rm -rf "$staging"' EXIT
|
||||
mkdir -p "$staging"
|
||||
tar -xzf "$archive" -C "$staging"
|
||||
bundle=$(dirname "$(find "$staging" -maxdepth 3 -type f -name pipelines-app | head -n 1)")
|
||||
[ -x "$bundle/pipelines-app" ] && [ -d "$bundle/data/flutter_assets" ] && [ -d "$bundle/lib" ] || {
|
||||
echo "The archive has no complete pipelines-app bundle." >&2; exit 1; }
|
||||
missing=$(ldd "$bundle/pipelines-app" | grep "not found" || true)
|
||||
missing=$(ldd "$bundle/pipelines-app" 2>/dev/null | grep "not found" || true)
|
||||
[ -z "$missing" ] || { echo "Missing system libraries:" >&2; echo "$missing" >&2; exit 1; }
|
||||
rm -rf "$target.previous"
|
||||
[ -d "$target" ] && mv "$target" "$target.previous"
|
||||
mv "$bundle" "$target"
|
||||
mkdir -p "$HOME/.local/bin" "$data/applications"
|
||||
ln -sf "$target/pipelines-app" "$HOME/.local/bin/pipelines-app"
|
||||
if [ -n "$icon" ]; then
|
||||
icon=$app_id
|
||||
if [ -f "$target/data/app_icon.png" ]; then
|
||||
mkdir -p "$data/icons/hicolor/512x512/apps"
|
||||
cp "$icon" "$data/icons/hicolor/512x512/apps/pipelines-app.png"
|
||||
cp "$target/data/app_icon.png" "$data/icons/hicolor/512x512/apps/$app_id.png"
|
||||
else
|
||||
icon=utilities-terminal
|
||||
fi
|
||||
cat > "$data/applications/pipelines-app.desktop" <<DESKTOP
|
||||
cat > "$data/applications/$app_id.desktop" <<DESKTOP
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Pipelines App
|
||||
Name=Pipelines
|
||||
Comment=Pipelines native desktop app
|
||||
Exec=$target/pipelines-app
|
||||
Icon=pipelines-app
|
||||
Icon=$icon
|
||||
Terminal=false
|
||||
StartupWMClass=com.pipelines.app
|
||||
StartupWMClass=$app_id
|
||||
StartupNotify=true
|
||||
Categories=Development;
|
||||
DESKTOP
|
||||
command -v update-desktop-database >/dev/null 2>&1 && update-desktop-database "$data/applications" >/dev/null 2>&1 || true
|
||||
echo "Installed $(cat "$target/version.txt" 2>/dev/null || echo Pipelines) at $target"
|
||||
echo "Installed Pipelines at $target"
|
||||
echo "Launcher: $data/applications/$app_id.desktop (run: pipelines-app)"
|
||||
|
||||
@@ -190,6 +190,51 @@ class DesktopBuildTests(unittest.TestCase):
|
||||
run = next(c for c in self.runner.calls if c[:2] == ["docker", "run"])
|
||||
self.assertIn("--dart-define=PIPELINES_UPDATE_PUBLIC_KEY=abc", run)
|
||||
|
||||
def test_linux_archive_leaves_split_debug_symbols_in_the_cache(self):
|
||||
bundle, archive = self.build("linux")
|
||||
(bundle / ".debug-info").mkdir()
|
||||
(bundle / ".debug-info/app.linux-x64.symbols").write_bytes(b"symbols")
|
||||
archive.unlink()
|
||||
archive = desktop._linux_archive(bundle)
|
||||
with tarfile.open(archive) as package:
|
||||
self.assertFalse([n for n in package.getnames() if ".debug-info" in n])
|
||||
self.assertIn("pipelines-linux-x64/pipelines-app", package.getnames())
|
||||
|
||||
def test_linux_install_runs_the_user_installer_with_the_prefix(self):
|
||||
_, archive = self.build("linux", install=True, prefix=self.root / "prefix")
|
||||
command = self.runner.calls[-1]
|
||||
self.assertEqual(command[0], "sh")
|
||||
self.assertTrue(command[1].endswith("install-linux-app.sh"))
|
||||
self.assertEqual(command[2], str(archive))
|
||||
with self.assertRaisesRegex(ValueError, "Linux client only"):
|
||||
self.build("macos", install=True)
|
||||
|
||||
def test_linux_installer_installs_bundle_icon_and_desktop_entry(self):
|
||||
_, archive = self.build("linux")
|
||||
home = self.root / "home"
|
||||
icon = self.root / "icon-bundle"
|
||||
# A bundle with its icon, as the Linux CMake install lays it out.
|
||||
with tarfile.open(archive) as package:
|
||||
package.extractall(icon, filter="data")
|
||||
(icon / "pipelines-linux-x64/data/app_icon.png").write_bytes(b"png")
|
||||
with tarfile.open(archive, "w:gz") as package:
|
||||
package.add(icon / "pipelines-linux-x64", arcname="pipelines-linux-x64")
|
||||
environment = {"HOME": str(home), "XDG_DATA_HOME": str(home / ".local/share"),
|
||||
"PATH": "/usr/bin:/bin"}
|
||||
with patch.dict(desktop.os.environ, environment, clear=True):
|
||||
desktop.install_linux(archive, runner=subprocess.run, prefix=home / "prefix")
|
||||
desktop.install_linux(archive, runner=subprocess.run, prefix=home / "prefix")
|
||||
target = home / "prefix/lib/app-linux"
|
||||
self.assertEqual((target / "pipelines-app").read_bytes(), b"linux-client")
|
||||
self.assertTrue((home / "prefix/lib/app-linux.previous/pipelines-app").is_file())
|
||||
entry = (home / ".local/share/applications/com.pipelines.app.desktop").read_text()
|
||||
self.assertIn(f"Exec={target}/pipelines-app\n", entry)
|
||||
self.assertIn("Icon=com.pipelines.app\n", entry)
|
||||
self.assertIn("StartupWMClass=com.pipelines.app\n", entry)
|
||||
self.assertTrue((home / ".local/share/icons/hicolor/512x512/apps/com.pipelines.app.png").is_file())
|
||||
self.assertEqual((home / ".local/bin/pipelines-app").resolve(), (target / "pipelines-app").resolve())
|
||||
self.assertFalse(list((home / "prefix/lib").glob(".app-linux-install.*")))
|
||||
|
||||
def test_desktop_server_prefill_rejects_embedded_credentials(self):
|
||||
with self.assertRaisesRegex(ValueError, "embedded credentials"):
|
||||
self.build("linux", server_url="wss://secret@example.com/connect")
|
||||
|
||||
Reference in New Issue
Block a user