Skip to content
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

Migrating to appimageupdatetool to get delta updates #853

Closed
Samueru-sama opened this issue Aug 17, 2024 · 6 comments
Closed

Migrating to appimageupdatetool to get delta updates #853

Samueru-sama opened this issue Aug 17, 2024 · 6 comments

Comments

@Samueru-sama
Copy link
Contributor

Samueru-sama commented Aug 17, 2024

Since we already have appimageupdatetool in the repo, all that we need to do is use it if available.

I took a look at the update function in the main script, and it actually doesn't know the name of the applications, all it does is look for AM-updater scripts in APPSPATH.

I think it is simpler to simply insert something that would use appimageupdatetool in AM-updater and then exit, like this:

if command -v appimageupdatetool >/dev/null 2>&1; then
    appimageupdatetool -O -r "/opt/$APP/$APP" && chmod a+x "/opt/$APP/$APP" && exit 0
fi

...rest of the AM-updater...

I did some testing and it seems to work perfectly, some appimages have broken update info in them so I need to make sure that the script doesn't continue to exit 0 when that happens.

EDIT: It works even when the zsync info is broken as appimageupdatetool does indeed not exit with a zero status when that happens, phew!

@ivan-hc
Copy link
Owner

ivan-hc commented Aug 17, 2024

we can apply the patch the same way we do with the "remove" script, to prevent unprivileged users removing the app

@Samueru-sama
Copy link
Contributor Author

we can apply the patch the same way we do with the "remove" script, to prevent unprivileged users removing the app

In that case I think it is easier to turn it into a single line, like this:

command -v appimageupdatetool && appimageupdatetool -O -r "/opt/$APP/$APP" && chmod a+x "/opt/$APP/$APP" && exit 0

and insert it between lines 4 and 5 in the typical AM-updater script for appimages.

@Samueru-sama
Copy link
Contributor Author

Samueru-sama commented Aug 18, 2024

I've found something interesting.

I tested adding this to the script, after the [ -n "$version" ] check, since we will have to add $version after the update is done to keep the version file up to date.

if command -v appimageupdatetool >/dev/null 2>&1; then
	cd "/opt/$APP" || exit 1
	appimageupdatetool -Or ./"$APP" && chmod a+x ./"$APP" && echo "$version" > ./version && exit 0
fi

Turns out that when you give relative paths to appimageupdatetool instead of full paths like I was doing before, it deletes the wrong file wtf

Testing it with brave.

~/Local/opt/brave/ ./AM-updater                                                                              2313ms 
Checking for updates...
Fetching release information for tag "stable" from GitHub API.
Fetching release information for tag "stable" from GitHub API.
zsync2: Using CA bundle found on system: /etc/ssl/cert.pem
... done!
Starting update...

Fetching release information for tag "stable" from GitHub API.
0% done
Updating from GitHub Releases via ZSync
Fetching release information for tag "stable" from GitHub API.
zsync2: Using CA bundle found on system: /etc/ssl/cert.pem
0% done
zsync2: /home/samuel/Local/opt/brave/./brave found, using as seed file
zsync2: Target file: /home/samuel/Local/opt/brave/./brave
zsync2: Reading seed file: /home/samuel/Local/opt/brave/./brave
5.27% done (7.79 of 147.71 MiB)...
zsync2: Usable data from seed files: 5.273040%
zsync2: Renaming temp file
zsync2: Fetching remaining blocks
5.27% done (7.79 of 147.71 MiB)...
zsync2: Downloading from https://objects.githubusercontent.com/github-production-release-asset-2e65be/321930328/f2885778-c984-4c24-80e0-89115ad655b2?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20240818%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240818T105710Z&X-Amz-Expires=300&X-Amz-Signature=aa9118e2a5faa04592467fe821434abaeecdf85fa38e013de1490dcd0acb85cb&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=321930328&response-content-disposition=attachment%3B%20filename%3DBrave-stable-v1.69.147-x86_64.AppImage&response-content-type=application%2Foctet-stream
zsync2: optimized ranges, old requests count 247, new requests count 6

96.95% done (143.21 of 147.71 MiB)...
zsync2: Verifying downloaded file
100.00% done (147.71 of 147.71 MiB)...
zsync2: checksum matches OK
zsync2: used 8167424 local, fetched 151826832
100.00% done (147.71 of 147.71 MiB)...
Validation warning: AppImage not signed
Removing old AppImage: /home/samuel/Local/opt/brave/brave
Update successful. Updated existing file /home/samuel/Local/opt/brave/./brave
chmod: cannot access './brave': No such file or directory

This left me with a brave.zs-old file and deleted the brave appimage.

@Samueru-sama
Copy link
Contributor Author

Now all that's left is waiting for this PR to get merged.

@Samueru-sama
Copy link
Contributor Author

The PR has been merged so now we can continue.

@ivan-hc
Copy link
Owner

ivan-hc commented Sep 8, 2024

the conversion is already in progress, while you are updating old scripts, the new scripts will adopt the template you created. I am doing the same, at least with my Conty-based AppImages.

Thanks for the contribution. I think I can close this issue.

@ivan-hc ivan-hc closed this as completed Sep 8, 2024
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

No branches or pull requests

2 participants