Skip to content

fix(install): robust D-Bus reload + correct Flatpak helper export path (#28)#29

Merged
hikaps merged 6 commits into
developfrom
issue-28
Jun 29, 2026
Merged

fix(install): robust D-Bus reload + correct Flatpak helper export path (#28)#29
hikaps merged 6 commits into
developfrom
issue-28

Conversation

@hikaps

@hikaps hikaps commented Jun 26, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the two install failures reported in #28 (reporter is on the stable release from main; these fixes land on develop and flow to main on the next release).

1. couchplay-helper.service fails to start (curl/tarball method)

The systemd unit is Type=dbus, so systemd reports "control process exited with error code" when the binary exits non-zero before taking BusName. That phrasing rules out a timeout and 203/EXEC (missing lib) — it is the helper's own return 1 in helper/main.cpp, almost certainly registerService() being denied because the ownership policy in /etc/dbus-1/system.d/ was never loaded.

Root cause: install-helper.sh ran systemctl reload dbus 2>/dev/null || true, masking the reload failure. Worked on Bazzite (the dev distro); failed on CachyOS.

Fix (scripts/install-helper.sh):

  • New reload_dbus(): tries systemctl reload dbus, falls back to SIGHUP via /run/dbus/pid (or /var/run/dbus/pid); no more || true masking.
  • install_helper: warns loudly on reload failure; on systemctl restart failure, dumps the last 30 journalctl lines + the exact follow-up command — so the next reporter sees the cause instead of a bare "Helper installation failed".
  • uninstall_helper: uses the same reload_dbus helper.

2. Flatpak export copies nothing to ~/.local/share (Flatpak method)

CONFIRMED, deterministic. The manifest had no --filesystem=home, so inside the sandbox $HOME = ~/.var/app/io.github.hikaps.couchplay. export wrote there, but the README's next command (sudo ~/.local/share/couchplay/install-helper.sh install) found an empty dir.

Fix:

  • io.github.hikaps.couchplay.json: added "--filesystem=home" to finish-args so $HOME resolves to the real host home.
  • scripts/install-helper.sh: EXPORT_DIR now resolves the real host home from /etc/passwd when running inside a Flatpak (robust whether or not $HOME is remapped).
  • README.md: documents where export writes, with an older-build fallback (sudo ~/.var/app/io.github.hikaps.couchplay/.local/share/couchplay/install-helper.sh install) for users on the current stable build.

Verification

  • bash -n scripts/install-helper.sh clean; python3 -m json.tool on the manifest valid.
  • Host-home awk resolution returns /home/notaname == $HOME exactly.
  • reload_dbus fallback exercised: with systemctl reload stubbed to fail and a live pid in the pidfile, it SIGHUPs the pid and returns 0 (signal delivery confirmed).

Behavior-change note

--filesystem=home means the Flatpak now reads/writes the real ~/.local/share/couchplay/profiles/ instead of the sandboxed copy, consistent with the non-Flatpak install. Previously-created Flatpak profiles won't carry over — worth a release note.

Notes

  • No C++/QML changed; unit-test suite is unaffected.
  • The exact return 1 branch for bug 1 is ~90% likely registerService() but is not 100% pinned without the reporter's journalctl. The fix is correct-and-diagnostic either way: the reload+fallback handles the leading cause, and the journal dump nails any other.

Refs #28

hikaps added a commit that referenced this pull request Jun 29, 2026
The install documentation — including the AppImage section — is consolidated
into PR #29 so the two PRs cannot conflict on README. This PR is now build-only
(scripts + workflow).
hikaps added 5 commits June 29, 2026 11:22
Resolve two install failures reported in #28:

1. couchplay-helper.service failed to start (Type=dbus unit exited 1).
   install-helper.sh masked D-Bus config-reload failures with || true, so
   the helper's ownership policy was never loaded and it could not register
   its service name. reload_dbus() now retries via SIGHUP on the pid file,
   failures are surfaced (not masked), and a failed start dumps the last 30
   journalctl lines.

2. Flatpak export wrote to the sandbox home (~/.var/app/...) while the
   README/host command looked in ~/.local/share/couchplay, so the host-side
   install found nothing. The manifest now grants --filesystem=home and
   export resolves the real host home from /etc/passwd. README adds an
   older-build fallback path.

Refs #28
Follow-up to the #28 install fixes based on reporter feedback:

- Flatpak export was still wrong: writing to $HOME/.local/share inside the
  sandbox vanishes (the sandbox home is not persisted to the host). Stage to
  $XDG_DATA_HOME instead, which Flatpak persists to ~/.var/app/<id>/data
  (host-visible, no extra permission needed). Reverts the unnecessary
  --filesystem=home (and the profiles behavior change it would introduce).
  README now points at ~/.var/app/.../data.

- The helper service crash on minimal Arch is an exec/load failure: the
  tarball bundles no runtime libraries, so the Qt6/KF6/Polkit/PipeWire-
  linked helper can't start where those are missing. install.sh now ldd-
  checks the helper and aborts with the missing sonames + per-distro install
  commands instead of an opaque service failure.

Refs #28
The release tarball's couchplay-helper is dynamically linked against system
Qt6/Polkit/PipeWire but bundles none, so on minimal distros (e.g. Arch) it fails
to start — the opaque exit / ERRNO 2 from #28. Bundle the helper's non-glibc
runtime libs into lib/couchplay with a $ORIGIN-relative RPATH via patchelf:

  - scripts/bundle-libs.sh: ldd-gather deps (excluding glibc/ld-linux), copy,
    patchelf --set-rpath $ORIGIN/../lib/couchplay
  - release.yml: add patchelf, run bundle-libs.sh in the Package step
  - install-helper.sh: install/uninstall lib/couchplay to $PREFIX/lib/couchplay

The helper now starts with zero system Qt6. glibc/ld-linux stay system-provided,
so the binary still has the build container's glibc floor. The GUI still needs
system Qt6 — a portable GUI is the AppImage's job (#30).

Refs #28
…e priority

Lead the install section with a 'which method should I use?' table and order
the methods by broad suitability: Flatpak (universal) -> tarball (curl one-liner
+ manual/Bazzite) -> AppImage (portable GUI). Consolidate the curl quick-install
and manual tarball steps under one Tarball section, and fold the AppImage docs in
here so this PR owns all install documentation.

Refs #28
CouchPlay's entire function depends on the privileged root helper, which
cannot run from an AppImage mount and always needs a system install. That
nullifies AppImage's core 'just download and run' promise for this app, and
Flatpak already covers the universal/portable case (without AppImage's glibc
floor). Keep Flatpak + tarball/curl only.
…e() path

Address code-review findings on PR #29:

- bundle-libs.sh: add --force-rpath so the helper gets DT_RPATH (transitive),
  not DT_RUNPATH. Without it the bundled transitive libs (Qt6Core's
  libpcre2/libdouble-conversion/libzstd) are unreachable on minimal systems and
  the helper still fails to load — defeating the #28 fix.
- install-helper.sh: guard the bundled-lib install with compgen -G so an empty
  lib dir doesn't abort the root install mid-way under set -e (partial install).
- install-helper.sh: usage() now prints the resolved $EXPORT_DIR instead of the
  stale hardcoded ~/.local/share/couchplay (which doesn't exist on host in Flatpak).

Finding C (install derefs symlinks) is N/A: bundle-libs.sh uses cp -L upstream,
so lib/couchplay holds flattened real files, no symlinks reach the install step.
@hikaps hikaps merged commit 34671e6 into develop Jun 29, 2026
1 check passed
@hikaps hikaps deleted the issue-28 branch June 29, 2026 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant