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

Add Info screen on terminal when updating any installed package #1106

Open
Premjit-Developer opened this issue Nov 12, 2024 · 13 comments
Open

Comments

@Premjit-Developer
Copy link

Is your feature request related to a problem? Please describe.

When updating any installed package it's really difficult to understand how much data is required to update the package or how much data left to update that package.

Describe the solution you'd like

Write here

Describe alternatives you've considered

Write here

@Samueru-sama
Copy link
Contributor

that would be very hard to implement because all the scripts do is parse github to get the latest version and then update.

We would need to figure out of the size of the package before updating, and not to mention this will be different for other sites.

@ivan-hc
Copy link
Owner

ivan-hc commented Nov 12, 2024

This is an interesting issue.

I also find it annoying to have to go and see the download status in the app folder directly, to be honest.

I've been wanting to do something APT or PacMan-style for a long time, regarding updates... but that would require some additional scripting tool that I don't know about.

Currently, it is possible to simply "unsilence" the scripts during the download process... but since the updates happen "in parallel", the information would end up crossing each other, creating confusion.

I need to find a way to create a "fixed" screen where each process continues to run, before continuing the entire update process.

I would like to see the list of updateable programs, and all the progress bars that are going on, and only at the end of all the updates, continue the general update process. Like APT and Pacman do.

Is there a solution that does this?

@ivan-hc
Copy link
Owner

ivan-hc commented Nov 12, 2024

@Premjit-Developer is this what you are looking for?

simplescreenrecorder-2024-11-13_00.46.46.mkv.mp4

It's completely doable, but I'd like to provide a better interface... if I find one.

@xplshn
Copy link
Contributor

xplshn commented Nov 13, 2024

What about using gum?

@ivan-hc
Copy link
Owner

ivan-hc commented Nov 13, 2024

What about using gum?

Adding gum means adding a dependency, while instead I would like to try to have as few dependencies as possible.

I already talked about it with @zen0bit , who is working on a TUI based on gum, see here #175

@xplshn
Copy link
Contributor

xplshn commented Nov 14, 2024

Well, fancy progress bars in pure sh are possible, and in bash it is also common, a quick duckduckgo search shows a stackoverflow with an OK implementation of one: https://github.com/fearside/ProgressBar/blob/master/progressbar.sh

@Premjit-Developer
Copy link
Author

Premjit-Developer commented Nov 16, 2024

@Premjit-Developer is this what you are looking for?
simplescreenrecorder-2024-11-13_00.46.46.mkv.mp4

It's completely doable, but I'd like to provide a better interface... if I find one.

Yes, And also If a user cancels the update, the partially updated program remains in the temp folder. To ensure consistency, the temp folder should be cleared when rechecking for updates.

@ivan-hc
Copy link
Owner

ivan-hc commented Nov 17, 2024

Yes, And also If a user cancels the update, the partially updated program remains in the temp folder. To ensure consistency, the temp folder should be cleared when rechecking for updates.

this is already covered by this function

function _clean_all_tmp_directories_from_appspath() {
	for arg in $ARGPATHS; do
		if test -d "$arg"/tmp; then
			rm -Rf "$arg"/tmp && echo " ✔ Removed $arg/tmp"
		fi
	done
}

this runs also when am -u starts

function _use_update() {
	_online_check
	_update_github_api_key_in_the_updater_files
	_clean_all_tmp_directories_from_appspath >/dev/null
	case $2 in
	''|'--apps')
		_clean_amcachedir
		_update_list_updatable_apps
[ ... ]

this function is also a part of am -c

@ivan-hc
Copy link
Owner

ivan-hc commented Nov 17, 2024

In this example I removed the three >/dev/null 2>&1 references to unsilence sunning the AM-updater scripts and I have updated 3 apps, and two of these (Libreoffice and Kdenlive, the official ones) are old type2 AppImages that I update and convert not to have the libfuse2 dependence (see option nolibfuse).

This is what is happened, with parallel updates

simplescreenrecorder-2024-11-17_02.52.09.mkv.mp4

@ivan-hc
Copy link
Owner

ivan-hc commented Nov 17, 2024

in brief, what you are asking for can be already done... but without the parallel updates

@ivan-hc
Copy link
Owner

ivan-hc commented Nov 17, 2024

The two functions involved for the previous video were these

function _update_updated_app_msg() {
	end=$(date +%s)
	echo " ◆ $APPNAME is updated, $((end - start)) seconds elapsed!"
}

function _update_run_updater() {
	if grep -q "api.github.com" "$argpath"/AM-updater; then
		GH_API_ALLOWED=$(curl -Ls $HeaderAuthWithGITPAT https://api.github.com/repos/ivan-hc/AM/releases/latest | sed 's/[()",{} ]/\n/g' | grep "^ivan-hc" | head -1)
		if [ -z "$GH_API_ALLOWED" ]; then
			if command -v torsocks 1>/dev/null; then
				torsocks "$argpath"/AM-updater >/dev/null 2>&1 && _update_updated_app_msg
			else
				echo " ✖ $APPNAME cannot be updated, you have reached GitHub API limit. Install \"torsocks\" from your system package manager and retry!" \
				| fold -sw 72 | sed 's/^/   /g; s/   ✖/✖/g'
			fi
		else
			"$argpath"/AM-updater >/dev/null 2>&1 && _update_updated_app_msg
		fi
	else
		"$argpath"/AM-updater >/dev/null 2>&1 && _update_updated_app_msg
	fi
}

changed like this

function _update_updated_app_msg() {
	end=$(date +%s)
	echo "◆ $APPNAME is updated, $((end - start)) seconds elapsed!"
	echo "$DIVIDING_LINE"
}

function _update_run_updater() {
	if grep -q "api.github.com" "$argpath"/AM-updater; then
		GH_API_ALLOWED=$(curl -Ls $HeaderAuthWithGITPAT https://api.github.com/repos/ivan-hc/AM/releases/latest | sed 's/[()",{} ]/\n/g' | grep "^ivan-hc" | head -1)
		if [ -z "$GH_API_ALLOWED" ]; then
			if command -v torsocks 1>/dev/null; then
				torsocks "$argpath"/AM-updater && _update_updated_app_msg
			else
				echo " ✖ $APPNAME cannot be updated, you have reached GitHub API limit. Install \"torsocks\" from your system package manager and retry!" \
				| fold -sw 72 | sed 's/^/   /g; s/   ✖/✖/g'
			fi
		else
			"$argpath"/AM-updater && _update_updated_app_msg
		fi
	else
		"$argpath"/AM-updater && _update_updated_app_msg
	fi
}

@ivan-hc
Copy link
Owner

ivan-hc commented Nov 17, 2024

the command to run the AM-updater script is "$argpath"/AM-updater, of course, and it is repeated three times in that function, depending if the app is hosted on github or not and if github APIs are reachable

@ivan-hc
Copy link
Owner

ivan-hc commented Nov 17, 2024

and this is the function responfile of running the above function in parallel for all apps installed

function _update_app() {
	APPNAME=$(echo "$arg" | tr '[:lower:]' '[:upper:]')
	start=$(date +%s)
	if [ -w "$argpath"/AM-updater ]; then
		_update_run_updater &
	else
		echo " ✖ $APPNAME is read-only, cannot update it!"
	fi
}

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

4 participants