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

Initial appimageupdatetool support #928

Merged
merged 2 commits into from
Sep 7, 2024
Merged

Initial appimageupdatetool support #928

merged 2 commits into from
Sep 7, 2024

Conversation

Samueru-sama
Copy link
Contributor

I think we better first manually add this to the popular big applications and see how it turns out before adding it to all the scripts.

@ivan-hc
Copy link
Owner

ivan-hc commented Sep 6, 2024

[ ... ] before adding it to all the scripts.

Istantanea_2024-09-06_13-24-43

the above is my avidemux, not the official one

@Samueru-sama
Copy link
Contributor Author

Samueru-sama commented Sep 6, 2024

Im about to go to sleep, but remember that the script should continue if appimageupdate fails.

@ivan-hc
Copy link
Owner

ivan-hc commented Sep 6, 2024

[ ... ] but remember that the script should continue if appimageupdate fails.

consider also that sandboxed apps are not executable, being managed by Aisap, and that if appimageupdatetool works, there are some .old files that need to be removed

Im about to go to sleep [ ... ]

take care

@Samueru-sama
Copy link
Contributor Author

Samueru-sama commented Sep 6, 2024

[ ... ] but remember that the script should continue if appimageupdate fails.

consider also that sandboxed apps are not executable, being managed by Aisap, and that if appimageupdatetool works, there are some .old files that need to be removed

There should be no .old files since appimageupdate is using the -Or flag which deletes the old file.

EDIT: I tested the script already with brave and had no issues.

@ivan-hc
Copy link
Owner

ivan-hc commented Sep 6, 2024

anyway, if to add that line is all is needed and other commands and variables are unused in the AM-updater script... its enough to add the function to APP-manager directly, and instead to made it call the AM-updater, it can manage updates directly.

Just two are the functions that take care of running the AM-updater scripts, and are quite simple

function _update_app() {
	if [ -w "$APPSPATH"/"$arg"/AM-updater ]; then
		start=$(date +%s) &&
		sh -x "$APPSPATH"/"$arg"/AM-updater >/dev/null 2>&1 | echo -ne ' Updating "'"$APPNAME"'"...\r' &&
		end=$(date +%s) &&
		echo " ◆ $APPNAME is updated, $((end - start)) seconds elapsed!" &
	else
		echo " ✖ $APPNAME is read-only, cannot update it!"
	fi
}

function _update_all_apps() {
	for f in "$APPSPATH"/*/; do
		cd "$f" 2>/dev/null || exit 1
		arg=$(printf '%s\n' "${PWD##*/}")
		if test -f "$APPSPATH"/"$arg"/AM-updater; then
			APPNAME=$(echo "$arg" | tr '[:lower:]' '[:upper:]')
			_update_app
		fi
	done
	wait
	echo "$DIVIDING_LINE"
	_update_determine_apps_version_changes
	rm -Rf "$APPSPATH/*/tmp"
}

@ivan-hc
Copy link
Owner

ivan-hc commented Sep 6, 2024

you can start test the two functions above instead, without having to update all the scripts

@ivan-hc
Copy link
Owner

ivan-hc commented Sep 6, 2024

Just two are the functions that take care of running the AM-updater scripts, and are quite simple

sorry, it is even more simple: one function you should check

function _update_app() {
	if [ -w "$APPSPATH"/"$arg"/AM-updater ]; then
		start=$(date +%s) &&
		sh -x "$APPSPATH"/"$arg"/AM-updater >/dev/null 2>&1 | echo -ne ' Updating "'"$APPNAME"'"...\r' &&
		end=$(date +%s) &&
		echo " ◆ $APPNAME is updated, $((end - start)) seconds elapsed!" &
	else
		echo " ✖ $APPNAME is read-only, cannot update it!"
	fi
}

@ivan-hc
Copy link
Owner

ivan-hc commented Sep 6, 2024

The below function is just a "draft" and doesn't mean nothing, take it as a proof of concept

function _update_app() {
	if [ -w "$APPSPATH"/"$arg"/AM-updater ]; then
		if command -v appimageupdatetool >/dev/null 2>&1; then
			start=$(date +%s) &&
			appimageupdatetool -Or "$APPSPATH"/"$arg"/AM-updater && chmod a+x "$APPSPATH"/"$arg"/AM-updater && echo "$version" > "$APPSPATH"/"$arg"/version &&
			end=$(date +%s) &&
			echo " ◆ $APPNAME is updated, $((end - start)) seconds elapsed!" &
		else
			start=$(date +%s) &&
			sh -x "$APPSPATH"/"$arg"/AM-updater >/dev/null 2>&1 | echo -ne ' Updating "'"$APPNAME"'"...\r' &&
			end=$(date +%s) &&
			echo " ◆ $APPNAME is updated, $((end - start)) seconds elapsed!" &
		fi
	else
		echo " ✖ $APPNAME is read-only, cannot update it!"
	fi
}

@ivan-hc
Copy link
Owner

ivan-hc commented Sep 6, 2024

maybe the only line you must change is

sh -x "$APPSPATH"/"$arg"/AM-updater >/dev/null 2>&1 | echo -ne ' Updating "'"$APPNAME"'"...\r' &&

and you need to add an if/fi condition to that

@ivan-hc
Copy link
Owner

ivan-hc commented Sep 6, 2024

@Samueru-sama I'm not sure on how the syntax would be, but this is another proof of concept/draft

function _update_app() {
	if [ -w "$APPSPATH"/"$arg"/AM-updater ]; then
		start=$(date +%s) &&
		if command -v appimageupdatetool >/dev/null 2>&1; then
			appimageupdatetool -Or "$APPSPATH"/"$arg"/AM-updater && chmod a+x "$APPSPATH"/"$arg"/AM-updater && echo "$version" > ./version && exit 0
		else
			sh -x "$APPSPATH"/"$arg"/AM-updater >/dev/null 2>&1
		fi \
		| echo -ne ' Updating "'"$APPNAME"'"...\r' &&
		end=$(date +%s) &&
		echo " ◆ $APPNAME is updated, $((end - start)) seconds elapsed!" &
	else
		echo " ✖ $APPNAME is read-only, cannot update it!"
	fi
}

@ivan-hc
Copy link
Owner

ivan-hc commented Sep 6, 2024

since I have less apps installed than you, its better I perform the test instead of you, you may reach the GHAPI limit too soon

@ivan-hc ivan-hc merged commit 71992b9 into ivan-hc:dev Sep 7, 2024
1 check passed
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.

2 participants