From 18cdb23c6203512bbbbbe7bb6598f7171043c42e Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Thu, 26 Sep 2024 18:16:06 +0200 Subject: [PATCH 01/10] Move "APPNAME" variable --- APP-MANAGER | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index 524f0909b..6778fc29b 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -1015,6 +1015,7 @@ function _update_determine_apps_version_changes() { } function _update_app() { + APPNAME=$(echo "$arg" | tr '[:lower:]' '[:upper:]') 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' && @@ -1030,7 +1031,6 @@ function _update_all_apps() { 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 @@ -1060,14 +1060,13 @@ function _use_update() { *) ARGS="$(echo "$@" | cut -f2- -d ' ')" for arg in $ARGS; do - APPNAME=$(echo "$arg" | tr '[:lower:]' '[:upper:]') if test -f "$APPSPATH"/"$arg"/AM-updater; then cd "$APPSPATH/$arg" 2>/dev/null || exit 1 _update_app else UPDATERS=$(cd "$APPSPATH"/"$arg" 2>/dev/null && find . -name "*update*" -print 2>/dev/null) [ -n "$UPDATERS" ] && arg_autoupdatable=", it may have its update system" - echo " ✖ Cannot manage updates for \"$APPNAME\"$arg_autoupdatable" + echo " ✖ Cannot manage updates for \"$(echo "$arg" | tr '[:lower:]' '[:upper:]')\"$arg_autoupdatable" fi done wait From c7d20f16356d909d67bc94909caa6dbb818a8e16 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Thu, 26 Sep 2024 18:35:47 +0200 Subject: [PATCH 02/10] Remove unneeded "echo -ne" command in updating application --- APP-MANAGER | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index 6778fc29b..5c59a318d 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -1017,10 +1017,9 @@ function _update_determine_apps_version_changes() { function _update_app() { APPNAME=$(echo "$arg" | tr '[:lower:]' '[:upper:]') 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!" & + start=$(date +%s) \ + && sh -x "$APPSPATH"/"$arg"/AM-updater >/dev/null 2>&1 \ + && end=$(date +%s) && echo " ◆ $APPNAME is updated, $((end - start)) seconds elapsed!" & else echo " ✖ $APPNAME is read-only, cannot update it!" fi From b7f7cc9f14bce4d21a4c4918bbb34c5391d9814a Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Thu, 26 Sep 2024 20:22:05 +0200 Subject: [PATCH 03/10] Move "start" variable in updating apps --- APP-MANAGER | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index 5c59a318d..8a0af63ff 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -1016,9 +1016,9 @@ function _update_determine_apps_version_changes() { function _update_app() { APPNAME=$(echo "$arg" | tr '[:lower:]' '[:upper:]') + start=$(date +%s) if [ -w "$APPSPATH"/"$arg"/AM-updater ]; then - start=$(date +%s) \ - && sh -x "$APPSPATH"/"$arg"/AM-updater >/dev/null 2>&1 \ + sh -x "$APPSPATH"/"$arg"/AM-updater >/dev/null 2>&1 \ && end=$(date +%s) && echo " ◆ $APPNAME is updated, $((end - start)) seconds elapsed!" & else echo " ✖ $APPNAME is read-only, cannot update it!" From ec9e96a04fae71cd62ee69d46bf5136fca07522d Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Thu, 26 Sep 2024 20:24:05 +0200 Subject: [PATCH 04/10] Exec the AM-updater directly, without "sh -x" --- APP-MANAGER | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/APP-MANAGER b/APP-MANAGER index 8a0af63ff..36b5148bf 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -1018,7 +1018,7 @@ function _update_app() { APPNAME=$(echo "$arg" | tr '[:lower:]' '[:upper:]') start=$(date +%s) if [ -w "$APPSPATH"/"$arg"/AM-updater ]; then - sh -x "$APPSPATH"/"$arg"/AM-updater >/dev/null 2>&1 \ + "$APPSPATH"/"$arg"/AM-updater >/dev/null 2>&1 \ && end=$(date +%s) && echo " ◆ $APPNAME is updated, $((end - start)) seconds elapsed!" & else echo " ✖ $APPNAME is read-only, cannot update it!" From 2d5722897b771e9ffc72d6347ee9347d62d45868 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Thu, 26 Sep 2024 21:49:00 +0200 Subject: [PATCH 05/10] Add "torsocks" support for -u/update ...for apps hosted on github.com --- APP-MANAGER | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index 36b5148bf..b1b0d3aa1 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -1,6 +1,6 @@ #!/usr/bin/env bash -AMVERSION="8.2.1" +AMVERSION="8.2.1-1" # Determine main repository and branch AMREPO="https://raw.githubusercontent.com/ivan-hc/AM/main" @@ -1014,12 +1014,34 @@ function _update_determine_apps_version_changes() { fi } +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" "$APPSPATH"/"$arg"/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 "$APPSPATH"/"$arg"/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 + "$APPSPATH"/"$arg"/AM-updater >/dev/null 2>&1 && _update_updated_app_msg + fi + else + "$APPSPATH"/"$arg"/AM-updater >/dev/null 2>&1 && _update_updated_app_msg + fi +} + function _update_app() { APPNAME=$(echo "$arg" | tr '[:lower:]' '[:upper:]') start=$(date +%s) if [ -w "$APPSPATH"/"$arg"/AM-updater ]; then - "$APPSPATH"/"$arg"/AM-updater >/dev/null 2>&1 \ - && end=$(date +%s) && echo " ◆ $APPNAME is updated, $((end - start)) seconds elapsed!" & + _update_run_updater & else echo " ✖ $APPNAME is read-only, cannot update it!" fi From cc4bc92e4ec2339fe46d6bbe4f293de5001d3763 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Thu, 26 Sep 2024 22:16:51 +0200 Subject: [PATCH 06/10] Fix https://github.com/topgrade-rs/topgrade/issues/906#issuecomment-2377834142 --- APP-MANAGER | 1 + 1 file changed, 1 insertion(+) diff --git a/APP-MANAGER b/APP-MANAGER index b1b0d3aa1..4f4d3fd4f 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -1064,6 +1064,7 @@ function _update_all_apps() { 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 From 2bbf7fc15a68e9a6d8ec910a43533df08486e014 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Thu, 26 Sep 2024 22:18:31 +0200 Subject: [PATCH 07/10] Update APP-MANAGER --- APP-MANAGER | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/APP-MANAGER b/APP-MANAGER index 4f4d3fd4f..92bf3bbdd 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -1,6 +1,6 @@ #!/usr/bin/env bash -AMVERSION="8.2.1-1" +AMVERSION="8.2.1-2" # Determine main repository and branch AMREPO="https://raw.githubusercontent.com/ivan-hc/AM/main" From 5dd4d87b1d22ad325c117e501df838f2065c603b Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Fri, 27 Sep 2024 02:35:49 +0200 Subject: [PATCH 08/10] Add "torsocks" support to the installation process --- modules/install.am | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/install.am b/modules/install.am index cce1c9177..6db411f14 100644 --- a/modules/install.am +++ b/modules/install.am @@ -229,7 +229,22 @@ _install_arg() { _apply_patches echo "" # Install script - $SUDOCMD ./"$arg" + if grep -q "api.github.com" ./"$arg"; 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 + $SUDOCMD torsocks ./"$arg" + else + echo " 💀 Cannot install \"$arg\", you have reached GitHub API limit. Install \"torsocks\" from your system package manager and retry!" \ + | fold -sw 72 | sed 's/^/ /g; s/ ✖/✖/g' + return + fi + else + $SUDOCMD ./"$arg" + fi + else + $SUDOCMD ./"$arg" + fi echo "" _post_installation_processes _ending_the_installation From e06f8c1017ba60ba1d8518d563ed6e511d721791 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Fri, 27 Sep 2024 02:41:40 +0200 Subject: [PATCH 09/10] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e1c5d40b4..56c346403 100644 --- a/README.md +++ b/README.md @@ -300,6 +300,7 @@ The following are optional dependencies that some programs may require: - "`binutils`", contains a series of basic commands, including "`ar`" which extracts .deb packages; - "`unzip`", to extract .zip packages; - "`tar`", to extract .tar* packages; +- "`torsocks`", to connect to the TOR network; - "`zsync`", about 10% of AppImages depend on this to be updated. ### Proceede From 0e721ac85a095a682bff47b907301473d66b7a12 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Fri, 27 Sep 2024 14:39:33 +0200 Subject: [PATCH 10/10] Update APP-MANAGER --- APP-MANAGER | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/APP-MANAGER b/APP-MANAGER index 92bf3bbdd..947cba385 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -1,6 +1,6 @@ #!/usr/bin/env bash -AMVERSION="8.2.1-2" +AMVERSION="8.3" # Determine main repository and branch AMREPO="https://raw.githubusercontent.com/ivan-hc/AM/main"