Skip to content

linux: embed AppImage update information and publish .zsync files #2397

Backlog

Description

@gengurke

Summary

On Linux the update pill only opens the download link with xdg-open (features/updater/src/linux.rs). After that the user downloads the full ~190 MB AppImage, replaces the old file and runs chmod +x by hand, for every dev build.

AppImage tools like AppImageUpdate and Gear Lever can do this automatically. They read the update information embedded in the AppImage and look for a matching .zsync file in the latest GitHub release. Rune's AppImages have the section for it, but it is empty, and releases ship no .zsync. So these tools find no updates.

Proposal: embed gh-releases-zsync update information and put a .zsync next to each AppImage. Only the build changes, and it adds to the in-app updater rather than replacing it: today and with a future in-app self-update alike.

Environment

  • OpenCode (Rune) 0.0.0-dev-524 AppImage x64 (also checked dev-527, dev-528 and dev-533)
  • Fedora 45, KDE Plasma 6.8.3, Gear Lever 4.6.2

Current behaviour

$ readelf -SW OpenCode-Rune-0.0.0-dev-533-linux-x64.AppImage | grep upd_info
  [23] .upd_info  PROGBITS  00000000000e3910 0e3910 000400 00  WA  0  0  1
$ ./OpenCode-Rune-0.0.0-dev-533-linux-x64.AppImage --appimage-updateinformation
                                    # (empty)
$ appimageupdatetool -j OpenCode-Rune-0.0.0-dev-528-linux-x64.AppImage
Could not find update information in the AppImage. Please contact the author of the AppImage and ask them to embed update information.

Why it fits

  • Complements the in-app updater. The update information is metadata that only external tools read. Rune's own updater keeps working as it does now, so this needs no decision about Linux self-updates (fix(updater): follow the release protocol and only replace installs we own #1099). If Rune later updates itself on Linux (with the signing key fix(updater): follow the release protocol and only replace installs we own #1099 asks for), both can live side by side: the in-app updater stays the default, and users who manage their AppImages with a tool keep using it. An in-app updater could even use the same .zsync for delta downloads. The tools check the rebuilt file against the SHA-1 in the .zsync. That proves the bytes match the release, but it is not a publisher signature.
  • latest already resolves correctly. publish-github-release.sh mirrors each dev release to v0.0.0-dev-<n> as latest and not as a prerelease. Today /releases/latest returns v0.0.0-dev-533.
  • No publish changes. write-checksums.sh and verify-artifacts.sh cover every file in the Linux build artifact, and publish-github-release.sh mirrors every file in it to GitHub. A .zsync written next to the AppImage therefore goes out with no further changes. The release service keeps its own target list and doesn't need it.

Suggested implementation

Update information per the AppImage spec:

gh-releases-zsync|anomalyco|opencode-rune|latest|OpenCode-Rune-*-linux-x64.AppImage.zsync
gh-releases-zsync|anomalyco|opencode-rune|latest|OpenCode-Rune-*-linux-arm64.AppImage.zsync

package-linux.sh concatenates the pinned runtime with the squashfs and doesn't use appimagetool, so appimagetool -u isn't available. The equivalent is to write the string into the runtime's .upd_info section after its SHA-256 check, then run zsyncmake:

fetch_appimage_runtime "$work/runtime"
echo "$runtime_sha  $work/runtime" | sha256sum --check --status
# AppImage update information: AppImageUpdate, Gear Lever, ... fetch the newest GitHub release's .zsync.
if [[ $OPENCODE_RUNE_BUILD_CHANNEL == dev ]]; then
  update_info="gh-releases-zsync|anomalyco|opencode-rune|latest|OpenCode-Rune-*-linux-$arch.AppImage.zsync"
  upd=$(readelf -SW "$work/runtime" | sed -n 's/.*\.upd_info *PROGBITS *[0-9a-f]* *\([0-9a-f]*\) *\([0-9a-f]*\).*/\1 \2/p')
  read -r upd_off upd_size <<< "$upd"
  (( ${#update_info} < 16#${upd_size:?runtime has no .upd_info section} ))
  printf '%s' "$update_info" | dd of="$work/runtime" bs=1 seek=$((16#$upd_off)) conv=notrunc status=none
fi
...
cat "$work/runtime" "$work/app.squashfs" > "$stem.AppImage"
chmod +x "$stem.AppImage"
[[ $(cd "$work" && "$stem.AppImage" --appimage-extract-and-run --version) == "$expected" ]]
if [[ -n ${update_info:-} ]]; then
  [[ $("$stem.AppImage" --appimage-updateinformation) == "$update_info" ]]
  zsyncmake -u "$(basename "$stem").AppImage" -o "$stem.AppImage.zsync" "$stem.AppImage"
fi

The other changes:

  • Add zsync to build-linux's apt-get install in release.yml.
  • In docs/releasing.md, replace "Linux uses manual downloads".

dev and check runs both build with OPENCODE_RUNE_BUILD_CHANNEL=dev. check publishes nothing but still tests the step. PR and branch builds skip it, so they don't offer to update themselves to the latest dev build.

Done when: the next dev release has an .AppImage.zsync for x64 and arm64, and appimageupdatetool updates an older build from that release to a file whose SHA-256 matches the published AppImage.

Already installed AppImages have no update information. Users need to download a new AppImage once. After that, updates go through their tool.

Checked locally

  • Writing the string into .upd_info (offset 0xe3910, 1024 bytes) works: --appimage-updateinformation prints it, and the app still starts (opencode-rune 0.0.0-dev-528 (dev)).
  • appimageupdatetool -d reads it as "ZSync via GitHub Releases" and resolves the latest anomalyco/opencode-rune release. It stops only at "None of the artifacts matched the pattern", because the release has no .zsync yet.
  • Ubuntu 24.04's zsyncmake 0.6.2 creates the .zsync for dev-533 in 0.5 s (338 KB). I served both files locally and pointed dev-524, dev-527 and dev-528 at them. appimageupdatetool updated each one to a file byte-identical to dev-533 and downloaded about 132.6 of 197.8 MB. (Gear Lever uses the .zsync to detect the update and then downloads the full file.)

Same change elsewhere: sourcegit-org/sourcegit#2762, WowUp/WowUp#1612.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions