Skip to content

fix(updater): package installs (AUR, deb, rpm) are updated outside the app - #1491

Open
ZhuchkaTriplesix wants to merge 1 commit into
devfrom
fix/updater-system-installs
Open

ZhuchkaTriplesix wants to merge 1 commit into
devfrom
fix/updater-system-installs

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Problem

With the AUR package, Update from 0.4.18 to 0.4.19 downloaded the update, closed the app and nothing started again; a reinstall was needed.

Cause (confirmed on the affected machine)

  • The AUR package (and the .deb / .rpm, scripts/linux/build_deb.sh) installs the bundle into /opt/querya-desktop, owned by root, with /usr/bin/querya_desktop as a symlink. Platform.resolvedExecutable resolves to /opt/querya-desktop/querya_desktop.
  • UpdateInstallContext.isManagedPackage only knew Snap and Flatpak, so the updater treated this as a portable bundle: it downloaded Querya-Desktop-0.4.19-linux.zip, extracted it, wrote a replace script and quit the app.
  • The script (set -e) could not delete or copy in /opt/querya-desktop and exited before its final exec, so the app was not restarted. The leftovers were still in /tmp: /tmp/querya-linux-update-3799797.sh (target DST='/opt/querya-desktop', it removes itself only on success) and the extracted /tmp/querya-update-1791735255359/.
  • The earlier fix (bug(updater): Linux portable update wipes QueryaData folder via rm -rf / rsync --delete #1055) protected the data of portable bundles during a replace; it did not cover installs the user cannot write.

Fix

  • UpdateInstallContext.linuxSystemPackageManager: pacman (an entry querya-desktop-* in /var/lib/pacman/local), dpkg (/var/lib/dpkg/info/querya-desktop.list) or rpm, only when the running bundle is /opt/querya-desktop, so a portable copy elsewhere is not affected.
  • isLinuxBundleReadOnly: the bundle folder exists and the user cannot write it (a probe file), whoever installed it.
  • Both make isManagedPackage true. The update dialog already handles that: no Download, a Copy update command button with yay -Syu querya-desktop, sudo apt update && sudo apt install --only-upgrade querya-desktop or sudo dnf upgrade querya-desktop; for a read-only folder of unknown origin it shows a hint and an Open release page button.
  • The zip installer refuses a managed target before the app quits.
  • The replace script checks [ -w "$DST" ] and, on any failure (not writable, rsync / rm / cp failing), writes the reason to ~/.local/state/querya-update.log and starts the app again instead of exiting.
  • CHANGELOG [Unreleased] entry.

Checked

  • The generated script passes sh -n, and I ran it against a fake bundle: with a read-only target it logs the reason and relaunches the old executable; with a writable one it installs and runs the new one and removes itself.
  • Unit tests: pacman, dpkg, a portable bundle next to an installed package (not blocked), a read-only folder (blocked, hint, no command), the installer refusing a pacman install, and the script's new guard.

Note for 0.4.19 users

The updater that runs is the installed one, so this helps from the release after it: users of the AUR / .deb / .rpm 0.4.19 should still update through their package manager. Worth a line in the next release notes.

…e app

The AUR, .deb and .rpm packages put the bundle in /opt/querya-desktop,
owned by root. The in-app updater treated it as a portable bundle: it
downloaded the zip, quit the app and ran a replace script that could not
write there, so the update failed and nothing started again (seen going
from 0.4.18 to 0.4.19 with the AUR package).

- UpdateInstallContext detects the owning package manager (pacman, dpkg,
  rpm) for /opt/querya-desktop and any bundle folder the user cannot
  write; both count as managed, so the dialog offers the update command
  (or the release page) instead of Download.
- The zip installer refuses such a target before the app quits.
- The replace script checks that the target is writable and, on any
  failure, logs the reason and starts the app again.
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