diff --git a/APP-MANAGER b/APP-MANAGER index af6c5661a..ebb5db327 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -1,6 +1,6 @@ #!/usr/bin/env bash -AMVERSION="6.9-2" +AMVERSION="6.9-3" # Determine main repository and branch AMREPO="https://raw.githubusercontent.com/ivan-hc/AM/main" @@ -19,6 +19,16 @@ DATADIR="${XDG_DATA_HOME:-$HOME/.local/share}" CONFIGDIR="${XDG_CONFIG_HOME:-$HOME/.config}" CACHEDIR="${XDG_CACHE_HOME:-$HOME/.cache}" +function _create_cache_dir() { + AMCACHEDIR="$AMPATH/.cache" + mkdir -p "$AMCACHEDIR" +} + +function _clean_amcachedir() { + if [ -z "$AMCACHEDIR" ]; then exit 1; fi + rm -f "$AMCACHEDIR"/* +} + APPMANCONFIG="$CONFIGDIR/appman" export SCRIPTDIR="$(if command -v xdg-user-dir &>/dev/null; then xdg-user-dir DESKTOP; else echo $HOME; fi)" @@ -59,7 +69,7 @@ function _am() { COMPLETIONFILE="am-completion.sh" APPSPATH="/opt" AMPATH="$APPSPATH/$AMCLI" - mkdir -p "$AMPATH"/.cache + _create_cache_dir mkdir -p "$AMPATH"/modules } @@ -90,7 +100,6 @@ function _patch_bashrc_and_profile() { function _appman_initialize() { APPSDIR=$1 - mkdir -p ~/"$APPSDIR"/appman/.cache mkdir -p ~/"$APPSDIR"/appman/modules mkdir -p ~/.local/bin "$DATADIR"/applications "$DATADIR"/icons AMCLI="appman" @@ -100,6 +109,7 @@ function _appman_initialize() { COMPLETIONFILE=".bash_completion" APPSPATH="$HOME/$APPSDIR" AMPATH="$HOME/$APPSDIR/$AMCLI" + _create_cache_dir } function _appman_prompt_for_directory() { @@ -211,7 +221,7 @@ function _jq_installer() { echo -e " You need to install it at least via your package manager to use \"$AMCLI\".\n\n Missing essential command ${RED}jq\033[0m, aborted!"; exit ;; 'Y'|'y'|*) - rm -f "$AMPATH"/.cache/* + _clean_amcachedir echo "" source "$AMPATH"/modules/install.am -i jq 2>&1 | grep "INSTALLED" echo "" @@ -390,7 +400,7 @@ function _check_version_if_no_version_found() { } function _check_version() { - rm -f "$AMPATH"/.cache/version-args + rm -f "$AMCACHEDIR"/version-args cd "$APPSPATH" && INSTALLED_APPS=$(find -name 'remove' -printf "%h\n" 2>/dev/null | du -sh -- * 2> /dev/null | sort -rh | sed 's@.* @@') for arg in $INSTALLED_APPS; do @@ -415,7 +425,7 @@ function _check_version() { if [ -z "$APPVERSION" ]; then _check_version_if_no_version_found fi - echo " ◆ $arg | $APPVERSION" >> "$AMPATH"/.cache/version-args + echo " ◆ $arg | $APPVERSION" >> "$AMCACHEDIR"/version-args fi done } @@ -427,20 +437,20 @@ function _check_version_for_auto_updatable_apps() { if test -f ./$arg/updater 2>/dev/null; then if [ -z "$(strings -d "./$arg/$arg" 2>/dev/null | grep -F 'appimage')" ] 2>/dev/null; then _check_version_if_an_updater_exists - OLDAPPVERSION=$(cat "$AMPATH"/.cache/version-args | grep " ◆ $arg |" | tr '|' '\n' | sed 's/ //g' | head -2 | tail -1) - sed -i "/ ◆ $arg |/s#$OLDAPPVERSION#$APPVERSION#" "$AMPATH"/.cache/* + OLDAPPVERSION=$(cat "$AMCACHEDIR"/version-args | grep " ◆ $arg |" | tr '|' '\n' | sed 's/ //g' | head -2 | tail -1) + sed -i "/ ◆ $arg |/s#$OLDAPPVERSION#$APPVERSION#" "$AMCACHEDIR"/* fi fi done } -if test -f "$AMPATH"/.cache/version-args; then - _check_version_for_auto_updatable_apps +if test -f "$AMCACHEDIR"/version-args; then + _check_version_for_auto_updatable_apps 2>/dev/null fi function _remove_info_files() { - rm -f "$AMPATH"/.cache/files-args* - rm -f "$AMPATH"/.cache/version-args + rm -f "$AMCACHEDIR"/files-args* + rm -f "$AMCACHEDIR"/version-args } ################################################################################### @@ -492,50 +502,53 @@ function _use_enable_completion() { } # Generate a list of words to use in bash completion -rm -rf "$AMPATH/options" -cat <<-HEREDOC >> "$AMPATH/options" - about - apikey - backup - clean - download - files - install - list - lock - neodb - newrepo - nolibfuse - overwrite - query - remove - sync - template - test - unlock - update - web - --apps - --byname - --convert - --debug - --devmode-disable - --devmode-enable - --disable-completion - --enable-completion - --firejail - --force-latest - --home - --launcher - --less - --rollback - --sandbox - --silent - --system - --user -HEREDOC +function _generate_options_list() { + rm -rf "$AMPATH/options" + cat <<-HEREDOC >> "$AMPATH/options" + about + apikey + backup + clean + download + files + install + list + lock + neodb + newrepo + nolibfuse + overwrite + query + remove + sync + template + test + unlock + update + web + --apps + --byname + --convert + --debug + --devmode-disable + --devmode-enable + --disable-completion + --enable-completion + --firejail + --force-latest + --home + --launcher + --less + --rollback + --sandbox + --silent + --system + --user + HEREDOC +} function _completion_lists() { + _generate_options_list # Remove existing lists and download new ones rm -Rf "$AMPATH"/{$arch-apps,list,libs-list} && wget -q "$APPSLISTDB" -P "$AMPATH" && @@ -543,7 +556,7 @@ function _completion_lists() { # THIRD PARTY APPS if test -f "$AMPATH/neodb"; then - rm -R -f "$AMPATH/.cache/multirepo-args" + rm -R -f "$AMCACHEDIR/multirepo-args" MULTIREPO=$(cat "$AMPATH/neodb" | grep "List=" | grep -E "$arch-apps" | sed 's/List=//g') for anyrepo in $MULTIREPO; do if curl --output /dev/null --silent --head --fail "$anyrepo" 1>/dev/null; then @@ -671,7 +684,7 @@ function _use_clean() { for i in {1000..0000}; do echo -ne " $i\r" && sleep 0.0001 done - rm -R -f "$AMPATH"/.cache/* && echo " ◆ Cleaning up the content of $AMPATH/.cache" + _clean_amcachedir && echo " ◆ Cleaning up the content of $AMCACHEDIR" rm -R -f "$APPSPATH"/*/tmp && echo ' ◆ Removed all '"$APPSPATH"'/*/tmp directories' if test -f "$DATADIR"/applications/AppImages/*.desktop 2> /dev/null; then _clean_launchers && echo ' ◆ Removed orphaned launchers produced with the "--launcher" option' @@ -707,20 +720,20 @@ function _update_github_api() { function _list_updatable_apps() { _check_version - cd "$APPSPATH" && find -name 'AM-updater' -printf " %h\n" 2>/dev/null | sort -u | xargs -n 1 basename 2>/dev/null > "$AMPATH"/.cache/updatable-args - ARGS=$(cat "$AMPATH"/.cache/updatable-args) + cd "$APPSPATH" && find -name 'AM-updater' -printf " %h\n" 2>/dev/null | sort -u | xargs -n 1 basename 2>/dev/null > "$AMCACHEDIR"/updatable-args + ARGS=$(cat "$AMCACHEDIR"/updatable-args) for arg in $ARGS; do - app_version=$(cat "$AMPATH/.cache/version-args" | grep -w " ◆ $arg |" | sed 's:.*| ::') - echo " ◆ $arg $app_version" >> $AMPATH/.cache/updatable-args-list + app_version=$(cat "$AMCACHEDIR/version-args" | grep -w " ◆ $arg |" | sed 's:.*| ::') + echo " ◆ $arg $app_version" >> "$AMCACHEDIR"/updatable-args-list done } function _sync_installation_scripts() { echo "-----------------------------------------------------------------------------" echo -e " Checking for changes of the installation scripts in the online database..." - rm -R -f "$AMPATH"/.cache/sync-args && echo "" >> "$AMPATH"/.cache/sync-args - cd "$APPSPATH" && find -name 'AM-updater' -printf "%h\n" 2>/dev/null | sort -u | cut -c 3- > "$AMPATH"/.cache/sync-args - ARGS=$(cat "$AMPATH"/.cache/sync-args) + rm -R -f "$AMCACHEDIR"/sync-args && echo "" >> "$AMCACHEDIR"/sync-args + cd "$APPSPATH" && find -name 'AM-updater' -printf "%h\n" 2>/dev/null | sort -u | cut -c 3- > "$AMCACHEDIR"/sync-args + ARGS=$(cat "$AMCACHEDIR"/sync-args) for arg in $ARGS; do mkdir -p "$APPSPATH/$arg/.am-installer" if test -f "$APPSPATH/$arg/.am-installer/$arg"; then @@ -759,12 +772,11 @@ function _sync_modules() { echo -ne "\r" 2> /dev/null else echo " ◆ Updating $MODULENAME..." - mkdir tmp - cd tmp || return + mkdir "$AMCACHEDIR"/tmp + cd "$AMCACHEDIR"/tmp || return wget -q "$v" cd .. - mv tmp/*.am ./ - chmod a+x ./*.am + echo y | mv tmp/*.am "$AMPATH"/modules/ rmdir tmp fi done @@ -782,15 +794,15 @@ function _sync_amcli() { CURRENT_AM_VERSION=$("$AMCLIPATH" -v) fi echo -ne '\n ◆ SYNCHRONIZING "'"$(echo "$AMCLI" | tr a-z A-Z)"'" VERSION '"$CURRENT_AM_VERSION"'...\r'; sleep 1 - rm -R -f "$AMPATH"/.cache/* 1>/dev/null; cd "$AMPATH"/.cache || return + _clean_amcachedir 1>/dev/null; cd "$AMCACHEDIR" || return if [ "$AMCLI" == am ] 2>/dev/null; then wget -q "$AMREPO"/APP-MANAGER && chmod a+x ./APP-MANAGER && chmod 777 ./APP-MANAGER cd .. - echo y | mv "$AMPATH"/.cache/APP-MANAGER /opt/am/APP-MANAGER + echo y | mv "$AMCACHEDIR"/APP-MANAGER /opt/am/APP-MANAGER else wget -q "$AMREPO"/APP-MANAGER -O appman && chmod a+x ./"$AMCLI" cd .. - echo y | mv "$AMPATH"/.cache/"$AMCLI" "$AMCLIPATH" + echo y | mv "$AMCACHEDIR"/"$AMCLI" "$AMCLIPATH" fi if [ ! "$CURRENT_AM_VERSION" == "$("$AMCLIPATH" -v)" ] ; then echo -ne ' A new release of "'"$(echo "$AMCLI" | tr a-z A-Z)"'" is available, please wait...\r' @@ -810,17 +822,53 @@ function _use_sync() { fi } +function _update_all_apps() { + for f in "$APPSPATH"/*/; do + cd $f 2>/dev/null && + if test -f ./AM-updater; then + if [ -w ./AM-updater ]; then + APPNAME=$(echo "$(printf '%s\n' "${PWD##*/}")") + start=$(date +%s) && sh -x ./AM-updater > /dev/null 2>&1 | echo -ne ' Updating "'"$APPNAME"'"...\r' && end=$(date +%s) && + echo -e " ◆ $(echo "$APPNAME" | tr a-z A-Z) is updated, $(($end-$start)) seconds elapsed!" & + else + APPNAME=$(echo "$(printf '%s\n' "${PWD##*/}")") + echo -e " - $(echo "$APPNAME" | tr a-z A-Z) is read-only, cannot update it!" + fi + else + echo "" > /dev/null 2>&1 + fi + done + wait + echo '-----------------------------------------------------------------------------' + if test -f "$AMCACHEDIR"/updatable-args-list; then + mv "$AMCACHEDIR"/updatable-args-list "$AMCACHEDIR"/updatable-args-list-old + _list_updatable_apps + OLDVER="$AMCACHEDIR/updatable-args-list-old" + NEWVER="$AMCACHEDIR/updatable-args-list" + if cmp --silent -- "$NEWVER" "$OLDVER"; then + echo ' Nothing to do here!' + else + echo -e " The following apps have been updated:\n" + diff --new-line-format="" --unchanged-line-format="" "$NEWVER" "$OLDVER" + echo "" + fi + else + echo ' No apps to update here!' + fi + rm -R -f "$APPSPATH/*/tmp" +} + function _use_update() { _update_github_api while [ -n "$1" ]; do case $2 in ''|'--apps') - rm -R -f "$AMPATH"/.cache/* + _clean_amcachedir _list_updatable_apps echo '-----------------------------------------------------------------------------' echo -e ' "'"$(echo "$AMCLI" | tr a-z A-Z)"'" CAN MANAGE UPDATES FOR THE FOLLOWING PROGRAMS:\n' - if test -f "$AMPATH/.cache/updatable-args-list"; then - cat "$AMPATH/.cache/updatable-args-list" + if test -f "$AMCACHEDIR/updatable-args-list"; then + cat "$AMCACHEDIR/updatable-args-list" else echo " None" fi @@ -829,36 +877,8 @@ function _use_update() { echo ' >> START OF ALL PROCESSES <<' echo '-----------------------------------------------------------------------------' - for f in "$APPSPATH"/*/; do - cd $f 2>/dev/null && - if test -f ./AM-updater; then - APPNAME=$(echo "$(printf '%s\n' "${PWD##*/}")") - start=$(date +%s) && sh -x ./AM-updater > /dev/null 2>&1 | echo -ne ' Updating "'"$APPNAME"'"...\r' && end=$(date +%s) && - echo -e " ◆ $(echo "$APPNAME" | tr a-z A-Z) is updated, $(($end-$start)) seconds elapsed!" & - else - echo "" > /dev/null 2>&1 - fi - done - wait - - echo '-----------------------------------------------------------------------------' + _update_all_apps - if test -f "$AMPATH"/.cache/updatable-args-list; then - mv "$AMPATH"/.cache/updatable-args-list "$AMPATH"/.cache/updatable-args-list-old - _list_updatable_apps - OLDVER="$AMPATH/.cache/updatable-args-list-old" - NEWVER="$AMPATH/.cache/updatable-args-list" - if cmp --silent -- "$NEWVER" "$OLDVER"; then - echo ' Nothing to do here!' - else - echo -e " The following apps have been updated:\n" - diff --new-line-format="" --unchanged-line-format="" "$NEWVER" "$OLDVER" - echo "" - fi - else - echo ' No apps to update here!' - fi - rm -R -f $APPSPATH/*/tmp if [ -z "$2" ]; then echo "-----------------------------------------------------------------------------" _use_sync @@ -870,11 +890,16 @@ function _use_update() { exit;; *) if test -f "$APPSPATH"/$2/AM-updater; then - start=$(date +%s); "$APPSPATH"/$2/AM-updater > /dev/null 2>&1 | echo -ne " UPDATING $(echo $2 | tr a-z A-Z)\r"; end=$(date +%s) - echo -e " ◆ $(echo $2 | tr a-z A-Z) is updated, $(($end-$start)) seconds elapsed!" - rm -R -f "$AMPATH"/.cache/* - _list_updatable_apps - break + if [ -w "$APPSPATH"/$2/AM-updater ]; then + start=$(date +%s); "$APPSPATH"/$2/AM-updater > /dev/null 2>&1 | echo -ne " UPDATING $(echo $2 | tr a-z A-Z)\r"; end=$(date +%s) + echo -e " ◆ $(echo $2 | tr a-z A-Z) is updated, $(($end-$start)) seconds elapsed!" + _clean_amcachedir + _list_updatable_apps + break + else + echo -e " - $(echo "$2" | tr a-z A-Z) is read-only, cannot update it!" + exit + fi else echo ' "'"$(echo "$AMCLI" | tr a-z A-Z)"'" CANNOT MANAGE UPDATES FOR "'"$(echo $2 | tr a-z A-Z)"'"' UPDATERS=$(cd "$APPSPATH"/$2 2>/dev/null && find . -name "*update*" -print 2>/dev/null) @@ -882,7 +907,7 @@ function _use_update() { echo ' This program probably includes its own update system!' fi exit - fi + fi;; esac done shift diff --git a/INSTALL b/INSTALL index b41f11c61..35b812502 100755 --- a/INSTALL +++ b/INSTALL @@ -20,10 +20,6 @@ _check_dependency() { _check_dependency 'wget' _check_dependency 'curl' -web_get() { - wget -q "$@" -} - # CREATING THE MAIN DIRECTORY FOR "AM" mkdir -p /opt/am/.cache /opt/am/modules || exit 1 cd /opt/am || exit 1 @@ -36,14 +32,14 @@ rm -R -f /usr/local/bin/am /opt/am /etc/bash_completion.d/am-completion.sh' >> / chmod a+x /opt/am/remove || exit 1 # DOWNLOAD THE MAIN SCRIPT -web_get https://raw.githubusercontent.com/ivan-hc/AM/main/APP-MANAGER +wget -q https://raw.githubusercontent.com/ivan-hc/AM/main/APP-MANAGER chmod a+x /opt/am/APP-MANAGER || exit 1 # LINK THE MAIN SCRIPT TO A KNOWN PATH ln -s /opt/am/APP-MANAGER /usr/local/bin/am || echo "WARNING: Something went wrong!" # DOWNLOAD THE LIST OF THE AVAILABLE PROGRAMS -web_get "https://raw.githubusercontent.com/ivan-hc/AM/main/programs/$arch-apps" || exit 1 +wget -q "https://raw.githubusercontent.com/ivan-hc/AM/main/programs/$arch-apps" || exit 1 # DOWNLOAD MODULES MODULES=$(curl -Ls https://api.github.com/repos/ivan-hc/AM/contents/modules | sed 's/[()",{}]/ /g; s/ /\n/g' | grep -o 'https.*raw.*modules.*am$' | grep -v "sync\|update") diff --git a/modules/database.am b/modules/database.am index 2bcb972b9..fe6d8bfee 100644 --- a/modules/database.am +++ b/modules/database.am @@ -13,7 +13,7 @@ function download_markdown() { local disk_usage="" local app_version="" local markdown_url="$AMCATALOGUEMARKDOWNS/${1}.md" - local cache_dir="$AMPATH/.cache/about" + local cache_dir="$AMCACHEDIR/about" local app_status=" STATUS: NOT INSTALLED" local package_name=${1^^} if curl -o /dev/null -sIf "$markdown_url"; then @@ -23,7 +23,7 @@ function download_markdown() { printf ' PACKAGE: %s\n' "$package_name" if [ -f "$APPSPATH/$1/remove" ]; then disk_usage=$(du -sm "$APPSPATH/$1" | cut -f1) - app_version=$(cat "$AMPATH"/.cache/version-args 2>/dev/null | grep -w " ◆ $1 |" | sed 's:.*| ::') + app_version=$(cat "$AMCACHEDIR"/version-args 2>/dev/null | grep -w " ◆ $1 |" | sed 's:.*| ::') app_status=$(echo -e " STATUS: INSTALLED, ABOUT $disk_usage MB OF DISK SPACE IN USE\n VERSION: $app_version") fi printf '%s\n' "$app_status" @@ -43,7 +43,7 @@ function generate_3rd_party() { printf ' PACKAGE: %s\n' "$arg" | tr a-z A-Z if [ -f "$APPSPATH/$1/remove" ]; then disk_usage=$(du -sm "$APPSPATH/$1" | cut -f1) - app_version=$(cat "$AMPATH"/.cache/version-args 2>/dev/null | grep -w " ◆ $1 |" | sed 's:.*| ::') + app_version=$(cat "$AMCACHEDIR"/version-args 2>/dev/null | grep -w " ◆ $1 |" | sed 's:.*| ::') app_status=$(echo -e " STATUS: INSTALLED, ABOUT $disk_usage MB OF DISK SPACE IN USE\n VERSION: $app_version") fi printf '%s\n' "$app_status" @@ -83,12 +83,12 @@ function _list() { ITEMSNUMBER=$(("$ITEMSNUMBER"-1)) fi APPSNUMBER=$(echo "$(("$ITEMSNUMBER" - "$LIBNUMBER"))") - if test -f "$AMPATH"/.cache/version-args; then - INSTALLED=$(cat "$AMPATH"/.cache/version-args 2>/dev/null | sort | sed 's/ | / /g' | grep -v "◆ am ") + if test -f "$AMCACHEDIR"/version-args; then + INSTALLED=$(cat "$AMCACHEDIR"/version-args 2>/dev/null | sort | sed 's/ | / /g' | grep -v "◆ am ") MESSAGE2="\n$INSTALLED\n" else _check_version - INSTALLED=$(cat "$AMPATH"/.cache/version-args 2>/dev/null | sort | sed 's/ | / /g' | grep -v "◆ am ") + INSTALLED=$(cat "$AMCACHEDIR"/version-args 2>/dev/null | sort | sed 's/ | / /g' | grep -v "◆ am ") MESSAGE2="\n$INSTALLED\n" fi @@ -123,7 +123,7 @@ case "$1" in exit ;; esac - if ! test -f "$AMPATH"/.cache/version-args; then + if ! test -f "$AMCACHEDIR"/version-args; then _check_version fi diff --git a/modules/download.am b/modules/download.am index 1ed914ee6..b8fc674ce 100644 --- a/modules/download.am +++ b/modules/download.am @@ -5,7 +5,7 @@ ##################################################################################### function _convert_to_appman_compatible_script() { - if grep -q -- "--convert" "$AMPATH"/.cache/download-args; then + if grep -q -- "--convert" "$AMCACHEDIR"/download-args; then if test -f "$APPMANCONFIG"/appman-config; then APPSPATH=$(cat "$APPMANCONFIG"/appman-config) sed -i "s# /usr/local/bin# $HOME/.local/bin#g" ./$arg @@ -36,34 +36,34 @@ function _download() { '--convert') ;; *) if test -f "$AMPATH/neodb"; then - rm -R -f "$AMPATH/.cache/multirepo-args" + rm -R -f "$AMCACHEDIR/multirepo-args" MULTIREPO=$(cat "$AMPATH/neodb" | grep "Source=" | sed 's/Source=//g') for anyrepo in $MULTIREPO; do if curl --output /dev/null --silent --head --fail $anyrepo/$arg 1>/dev/null; then - echo "$anyrepo" >> "$AMPATH/.cache/multirepo-args" + echo "$anyrepo" >> "$AMCACHEDIR/multirepo-args" fi done - if test -f "$AMPATH/.cache/multirepo-args"; then - anyrepoargs=$(cat "$AMPATH/.cache/multirepo-args" 2>/dev/null | wc -l) + if test -f "$AMCACHEDIR/multirepo-args"; then + anyrepoargs=$(cat "$AMCACHEDIR/multirepo-args" 2>/dev/null | wc -l) if [ $anyrepoargs -gt 0 ]; then if curl --output /dev/null --silent --head --fail $APPSDB/$arg 1>/dev/null; then - echo "$APPSDB" >> "$AMPATH/.cache/multirepo-args" + echo "$APPSDB" >> "$AMCACHEDIR/multirepo-args" fi - anyrepoargall=$(cat "$AMPATH/.cache/multirepo-args" 2>/dev/null | wc -l) + anyrepoargall=$(cat "$AMCACHEDIR/multirepo-args" 2>/dev/null | wc -l) if [ $anyrepoargall == 1 ]; then - cd "$SCRIPTDIR" || return; wget -q "$(cat "$AMPATH/.cache/multirepo-args" | head -1)/$arg"; _convert_to_appman_compatible_script - rm -R -f "$AMPATH/.cache/multirepo-args" + cd "$SCRIPTDIR" || return; wget -q "$(cat "$AMCACHEDIR/multirepo-args" | head -1)/$arg"; _convert_to_appman_compatible_script + rm -R -f "$AMCACHEDIR/multirepo-args" echo ' ◆ "'$arg'" third-party installation script downloaded! ' else echo -e " ◆ FOUND $(echo '"'$arg'"' | tr a-z A-Z) FROM MULTIPLE SOURCES:\n" && printf " Select a URL from this menu (read carefully) or press CTRL+C to abort:\n\n"; sleep 1; - select d in $(cat "$AMPATH/.cache/multirepo-args"); do test -n "$d" && break; echo ">>> Invalid Selection"; done - rm -R -f "$AMPATH/.cache/multirepo-args" + select d in $(cat "$AMCACHEDIR/multirepo-args"); do test -n "$d" && break; echo ">>> Invalid Selection"; done + rm -R -f "$AMCACHEDIR/multirepo-args" cd "$SCRIPTDIR" || return; wget -q $d/$arg; _convert_to_appman_compatible_script echo ' ◆ "'$arg'" installation script downloaded! ' fi elif curl --output /dev/null --silent --head --fail $APPSDB/$arg 1>/dev/null; then - rm -R -f "$AMPATH/.cache/multirepo-args" + rm -R -f "$AMCACHEDIR/multirepo-args" cd "$SCRIPTDIR" || return; wget -q $APPSDB/$arg; _convert_to_appman_compatible_script echo ' ◆ "'$arg'" installation script downloaded! ' else @@ -93,9 +93,9 @@ case $2 in esac while [ -n "$1" ]; do - rm -f $AMPATH/.cache/download-args - echo "$@" | tr ' ' '\n' >> $AMPATH/.cache/download-args && echo STOP >> $AMPATH/.cache/download-args - ARGS=$(tail -n +2 $AMPATH/.cache/download-args) + rm -f "$AMCACHEDIR"/download-args + echo "$@" | tr ' ' '\n' >> "$AMCACHEDIR"/download-args && echo STOP >> "$AMCACHEDIR"/download-args + ARGS=$(tail -n +2 "$AMCACHEDIR"/download-args) for arg in $ARGS; do if [ $arg == STOP ]; then diff --git a/modules/files.am b/modules/files.am index c4cf3ed96..ea7d7eb69 100644 --- a/modules/files.am +++ b/modules/files.am @@ -27,27 +27,27 @@ function _files_sizes() { } function _files_if_binary_executable() { - echo " ◆ $arg | $APPVERSION | binary/executable | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args + echo " ◆ $arg | $APPVERSION | binary/executable | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args } function _files_if_unknown() { - echo " ◆ $arg | $APPVERSION | unknown | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args + echo " ◆ $arg | $APPVERSION | unknown | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args } function _files_if_other() { - echo " ◆ $arg | $APPVERSION | other | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args + echo " ◆ $arg | $APPVERSION | other | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args } function _files_if_launcher() { - echo " ◆ $arg | $APPVERSION | launcher | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args + echo " ◆ $arg | $APPVERSION | launcher | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args } function _files_if_set_tools() { - echo " ◆ $arg | $APPVERSION | set/tools | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args + echo " ◆ $arg | $APPVERSION | set/tools | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args } function _files_if_library() { - echo " ◆ $arg | $APPVERSION | library | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args + echo " ◆ $arg | $APPVERSION | library | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args } function _files_if_script() { @@ -56,20 +56,20 @@ function _files_if_script() { elif test -f $APPSPATH/$arg/$arg-bin; then _files_if_binary_executable else - echo " ◆ $arg | $APPVERSION | script | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args + echo " ◆ $arg | $APPVERSION | script | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args fi } function _files_if_appimage() { if [ -z "$(strings -d "./$arg/$arg" 2>/dev/null | grep -F 'AppImages require FUSE to run')" ] 2>/dev/null; then - echo " ◆ $arg | $APPVERSION | appimage-type3 | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args + echo " ◆ $arg | $APPVERSION | appimage-type3 | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args else - echo " ◆ $arg | $APPVERSION | appimage-type2 | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMPATH"/.cache/files-args + echo " ◆ $arg | $APPVERSION | appimage-type2 | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args fi } function _files_type() { - APPVERSION=$(cat "$AMPATH"/.cache/version-args | grep -w " ◆ $arg |" | sed 's:.*| ::') + APPVERSION=$(cat "$AMCACHEDIR"/version-args | grep -w " ◆ $arg |" | sed 's:.*| ::') if [ -z "$(strings -d "./$arg/$arg" 2>/dev/null | grep -F 'if you run it with the --appimage-extract option')" ] 2>/dev/null; then string=$(strings -d "./$arg/$arg" 2>/dev/null | head -1 ) if grep -q "usr/local/lib" ./$arg/remove; then @@ -118,10 +118,10 @@ function _files_type() { } function _files() { - rm -f "$AMPATH"/.cache/files-args* + rm -f "$AMCACHEDIR"/files-args* cd $APPSPATH && INSTALLED_APPS=$(find -name 'remove' -printf "%h\n" 2>/dev/null | du -sh -- * 2> /dev/null | sort -rh | sed 's@.* @@') - if ! test -f "$AMPATH"/.cache/version-args; then + if ! test -f "$AMCACHEDIR"/version-args; then _check_version fi for arg in $INSTALLED_APPS; do @@ -140,31 +140,31 @@ function _files_show_only_number() { function _files_sort_by_name() { _files_header - rm -f "$AMPATH"/.cache/files-args-byname - if test -f "$AMPATH"/.cache/files-args; then - echo -e "- APPNAME | VERSION | TYPE | SIZE \n- ------- | ------- | ---- | ----" >> "$AMPATH"/.cache/files-args-byname - cat "$AMPATH"/.cache/files-args 2>/dev/null | sort >> "$AMPATH"/.cache/files-args-byname + rm -f "$AMCACHEDIR"/files-args-byname + if test -f "$AMCACHEDIR"/files-args; then + echo -e "- APPNAME | VERSION | TYPE | SIZE \n- ------- | ------- | ---- | ----" >> "$AMCACHEDIR"/files-args-byname + cat "$AMCACHEDIR"/files-args 2>/dev/null | sort >> "$AMCACHEDIR"/files-args-byname else _files - echo -e "- APPNAME | VERSION | TYPE | SIZE \n- ------- | ------- | ---- | ----" >> "$AMPATH"/.cache/files-args-byname - cat "$AMPATH"/.cache/files-args 2>/dev/null | sort >> "$AMPATH"/.cache/files-args-byname + echo -e "- APPNAME | VERSION | TYPE | SIZE \n- ------- | ------- | ---- | ----" >> "$AMCACHEDIR"/files-args-byname + cat "$AMCACHEDIR"/files-args 2>/dev/null | sort >> "$AMCACHEDIR"/files-args-byname fi - cat "$AMPATH"/.cache/files-args-byname | column -t + cat "$AMCACHEDIR"/files-args-byname | column -t echo "" } function _files_sort_by_size() { _files_header - rm -f "$AMPATH"/.cache/files-args-bysize - if test -f "$AMPATH"/.cache/files-args; then - echo -e "- APPNAME | VERSION | TYPE | SIZE \n- ------- | ------- | ---- | ----" >> "$AMPATH"/.cache/files-args-bysize - cat "$AMPATH"/.cache/files-args >> "$AMPATH"/.cache/files-args-bysize 2>/dev/null + rm -f "$AMCACHEDIR"/files-args-bysize + if test -f "$AMCACHEDIR"/files-args; then + echo -e "- APPNAME | VERSION | TYPE | SIZE \n- ------- | ------- | ---- | ----" >> "$AMCACHEDIR"/files-args-bysize + cat "$AMCACHEDIR"/files-args >> "$AMCACHEDIR"/files-args-bysize 2>/dev/null else _files - echo -e "- APPNAME | VERSION | TYPE | SIZE \n- ------- | ------- | ---- | ----" >> "$AMPATH"/.cache/files-args-bysize - cat "$AMPATH"/.cache/files-args >> "$AMPATH"/.cache/files-args-bysize 2>/dev/null + echo -e "- APPNAME | VERSION | TYPE | SIZE \n- ------- | ------- | ---- | ----" >> "$AMCACHEDIR"/files-args-bysize + cat "$AMCACHEDIR"/files-args >> "$AMCACHEDIR"/files-args-bysize 2>/dev/null fi - cat "$AMPATH"/.cache/files-args-bysize | column -t + cat "$AMCACHEDIR"/files-args-bysize | column -t echo "" } diff --git a/modules/install.am b/modules/install.am index edf75343e..6acebf96b 100644 --- a/modules/install.am +++ b/modules/install.am @@ -65,14 +65,14 @@ function _if_missing_dependence() { # If you use the --latest option, add the "latest" flag to scripts that point to a very common "release" function _if_latest() { - if grep -q 'force-latest' $AMPATH/.cache/install-args; then + if grep -q 'force-latest' "$AMCACHEDIR"/install-args; then sed -i 's#/releases | jq #/releases/latest | jq #g' ./$arg fi } # Patch to apply to installation scripts function _install_common_patch() { - if ! grep -q -- "--debug" $AMPATH/.cache/install-args; then + if ! grep -q -- "--debug" "$AMCACHEDIR"/install-args; then # Patch "wget" (version 1.x) to have a progress bar and fix errors when applying patches if wget --version | head -1 | grep -q ' 1.'; then sed -i "s#wget #wget -q --no-verbose --show-progress --progress=bar #g" ./$arg @@ -175,7 +175,7 @@ function _ending_the_installation() { echo -e " 💀 ERROR DURING INSTALLATION, REMOVED $(echo '"'$arg'"' | tr a-z A-Z)!" $AMCLIPATH -R $LATESTDIR 1> /dev/null else - chown -R $currentuser $AMPATH/.cache/about 2> /dev/null + chown -R $currentuser "$AMCACHEDIR"/about 2> /dev/null for metapackage in $(echo "$METAPACKAGES"); do if grep -q "$metapackage" ./$arg 2> /dev/null; then metascript=$(cd $APPSPATH && ls -td * | head -1) @@ -187,10 +187,10 @@ function _ending_the_installation() { else echo -ne " $(echo '"'$arg'"' | tr a-z A-Z) INSTALLED ($(du -sm $APPSPATH/$(cd $APPSPATH && ls -td * | head -1) | awk '{print $1}' ) MB OF DISK SPACE)\n" fi - $SUDOCOMMAND rm $AMPATH/.cache/$arg + $SUDOCOMMAND rm "$AMCACHEDIR"/$arg _check_version - app_version=$(cat $AMPATH/.cache/version-args | grep -w " ◆ $LATESTDIR |" | sed 's:.*| ::') - echo " ◆ $LATESTDIR $app_version" >> $AMPATH/.cache/installed + app_version=$(cat "$AMCACHEDIR"/version-args | grep -w " ◆ $LATESTDIR |" | sed 's:.*| ::') + echo " ◆ $LATESTDIR $app_version" >> "$AMCACHEDIR"/installed fi else echo " INSTALLATION ABORTED!" @@ -243,20 +243,20 @@ while [ -n "$1" ]; do echo "## START OF ALL INSTALLATION PROCESSES ##" echo "## ##" echo "############################################################################" - rm -R -f $AMPATH/.cache/* - echo "$@" | tr ' ' '\n' >> $AMPATH/.cache/install-args - echo STOP >> $AMPATH/.cache/install-args - ARGS=$(tail -n +2 $AMPATH/.cache/install-args) + _clean_amcachedir + echo "$@" | tr ' ' '\n' >> "$AMCACHEDIR"/install-args + echo STOP >> "$AMCACHEDIR"/install-args + ARGS=$(tail -n +2 "$AMCACHEDIR"/install-args) METAPACKAGES="kdegames kdeutils libreoffice nodejs platform-tools" for arg in $ARGS; do if [ $arg == STOP ]; then - if test -f $AMPATH/.cache/installed; then + if test -f "$AMCACHEDIR"/installed; then echo "############################################################################" echo -e "\n END OF ALL INSTALLATION PROCESSES\n" echo -e " The following new programs have been installed:\n" - grep -w -v "◆ am" 0<$AMPATH/.cache/installed + grep -w -v "◆ am" 0<"$AMCACHEDIR"/installed echo -e "\n############################################################################" exit else @@ -283,55 +283,55 @@ while [ -n "$1" ]; do echo " ◆ $(echo '"'$arg'"' | tr a-z A-Z): app already installed previously! Try removing it." else if test -f ./$arg 2> /dev/null; then - mkdir -p $AMPATH/.cache/tmp; cp ./$arg $AMPATH/.cache/tmp/$arg; cd $AMPATH/.cache || return; mv ./tmp/$arg ./$arg; rmdir ./tmp + mkdir -p "$AMCACHEDIR"/tmp; cp ./$arg "$AMCACHEDIR"/tmp/$arg; cd "$AMCACHEDIR" || return; mv ./tmp/$arg ./$arg; rmdir ./tmp _install_arg elif test -f $arg 2> /dev/null; then path2arg=$(echo "$arg") arg=$(echo "$path2arg" | sed 's:.*/::') - cd $AMPATH/.cache || return; mkdir -p tmp; cd tmp || return; cp $path2arg ./$arg; cd ..; mv ./tmp/$arg ./$arg; rmdir ./tmp + cd "$AMCACHEDIR" || return; mkdir -p tmp; cd tmp || return; cp $path2arg ./$arg; cd ..; mv ./tmp/$arg ./$arg; rmdir ./tmp _install_arg elif test -f "$AMPATH/neodb"; then - rm -R -f "$AMPATH/.cache/multirepo-args" + rm -R -f "$AMCACHEDIR/multirepo-args" MULTIREPO=$(cat "$AMPATH/neodb" | grep "Source=" | sed 's/Source=//g') for anyrepo in $MULTIREPO; do if curl --output /dev/null --silent --head --fail $anyrepo/$arg 1>/dev/null; then - echo "$anyrepo" >> "$AMPATH/.cache/multirepo-args" + echo "$anyrepo" >> "$AMCACHEDIR/multirepo-args" fi done - if test -f "$AMPATH/.cache/multirepo-args"; then - anyrepoargs=$(cat "$AMPATH/.cache/multirepo-args" 2>/dev/null | wc -l) + if test -f "$AMCACHEDIR/multirepo-args"; then + anyrepoargs=$(cat "$AMCACHEDIR/multirepo-args" 2>/dev/null | wc -l) if [ $anyrepoargs -gt 0 ]; then if curl --output /dev/null --silent --head --fail $APPSDB/$arg 1>/dev/null; then - echo "$APPSDB" >> "$AMPATH/.cache/multirepo-args" + echo "$APPSDB" >> "$AMCACHEDIR/multirepo-args" fi - anyrepoargall=$(cat "$AMPATH/.cache/multirepo-args" 2>/dev/null | wc -l) + anyrepoargall=$(cat "$AMCACHEDIR/multirepo-args" 2>/dev/null | wc -l) if [ $anyrepoargall == 1 ]; then - cd $AMPATH/.cache || return; mkdir -p tmp; cd tmp || return; wget -q "$(cat "$AMPATH/.cache/multirepo-args" | head -1)/$arg"; cd ..; mv ./tmp/$arg ./$arg; rmdir ./tmp - rm -R -f "$AMPATH/.cache/multirepo-args" + cd "$AMCACHEDIR" || return; mkdir -p tmp; cd tmp || return; wget -q "$(cat "$AMCACHEDIR/multirepo-args" | head -1)/$arg"; cd ..; mv ./tmp/$arg ./$arg; rmdir ./tmp + rm -R -f "$AMCACHEDIR/multirepo-args" _install_arg else echo -e "\n ◆ FOUND $(echo '"'$arg'"' | tr a-z A-Z) FROM MULTIPLE SOURCES:\n" && printf " Select a URL from this menu (read carefully) or press CTRL+C to abort:\n\n"; sleep 1; - select d in $(cat "$AMPATH/.cache/multirepo-args"); do test -n "$d" && break; echo ">>> Invalid Selection"; done - cd $AMPATH/.cache || return; mkdir -p tmp; cd tmp || return; wget -q "$d/$arg"; cd ..; mv ./tmp/$arg ./$arg; rmdir ./tmp - rm -R -f "$AMPATH/.cache/multirepo-args" + select d in $(cat "$AMCACHEDIR/multirepo-args"); do test -n "$d" && break; echo ">>> Invalid Selection"; done + cd "$AMCACHEDIR" || return; mkdir -p tmp; cd tmp || return; wget -q "$d/$arg"; cd ..; mv ./tmp/$arg ./$arg; rmdir ./tmp + rm -R -f "$AMCACHEDIR/multirepo-args" _install_arg fi elif curl --output /dev/null --silent --head --fail $APPSDB/$arg 1>/dev/null; then - cd $AMPATH/.cache || return; mkdir -p tmp; cd tmp || return; wget -q $APPSDB/$arg; cd ..; mv ./tmp/$arg ./$arg; rmdir ./tmp - rm -R -f "$AMPATH/.cache/multirepo-args" + cd "$AMCACHEDIR" || return; mkdir -p tmp; cd tmp || return; wget -q $APPSDB/$arg; cd ..; mv ./tmp/$arg ./$arg; rmdir ./tmp + rm -R -f "$AMCACHEDIR/multirepo-args" _install_arg else echo ' 💀 ERROR: "'$arg'" does NOT exist in the database, see "'$AMCLI' -l"' fi elif curl --output /dev/null --silent --head --fail $APPSDB/$arg 1>/dev/null; then - cd $AMPATH/.cache || return; mkdir -p tmp; cd tmp || return; wget -q $APPSDB/$arg; cd ..; mv ./tmp/$arg ./$arg; rmdir ./tmp + cd "$AMCACHEDIR" || return; mkdir -p tmp; cd tmp || return; wget -q $APPSDB/$arg; cd ..; mv ./tmp/$arg ./$arg; rmdir ./tmp _install_arg else echo ' 💀 ERROR: "'$arg'" does NOT exist in the database, see "'$AMCLI' -l"' fi elif curl --output /dev/null --silent --head --fail $APPSDB/$arg 1>/dev/null; then - cd $AMPATH/.cache || return; mkdir -p tmp; cd tmp || return; wget -q $APPSDB/$arg; cd ..; mv ./tmp/$arg ./$arg; rmdir ./tmp + cd "$AMCACHEDIR" || return; mkdir -p tmp; cd tmp || return; wget -q $APPSDB/$arg; cd ..; mv ./tmp/$arg ./$arg; rmdir ./tmp _install_arg else echo ' 💀 ERROR: "'$arg'" does NOT exist in the database, see "'$AMCLI' -l"' diff --git a/modules/launcher.am b/modules/launcher.am index 16cafb26f..0429e3123 100644 --- a/modules/launcher.am +++ b/modules/launcher.am @@ -108,9 +108,9 @@ case $2 in esac while [ -n "$1" ]; do - rm -f "$AMPATH"/.cache/tolaunch-args - echo "$@" | tr ' ' '\n' >> "$AMPATH"/.cache/tolaunch-args && echo STOP >> "$AMPATH"/.cache/tolaunch-args - ARGS=$(tail -n +2 "$AMPATH"/.cache/tolaunch-args) + rm -f "$AMCACHEDIR"/tolaunch-args + echo "$@" | tr ' ' '\n' >> "$AMCACHEDIR"/tolaunch-args && echo STOP >> "$AMCACHEDIR"/tolaunch-args + ARGS=$(tail -n +2 "$AMCACHEDIR"/tolaunch-args) for arg in $ARGS; do if [ $arg == STOP ]; then diff --git a/modules/management.am b/modules/management.am index 7af1e092a..937676872 100644 --- a/modules/management.am +++ b/modules/management.am @@ -13,17 +13,17 @@ esac ######################################## function _remove_check_removals() { - if test -f "$AMPATH"/.cache/unavailable-args; then + if test -f "$AMCACHEDIR"/unavailable-args; then echo -e "-----------------------------------------------------------------------\n" if [ "$AMCLI" == am ] 2>/dev/null; then - echo -e " 💀 ERROR, the following programs you want to remove are NOT in $APPSPATH :\n\n$(cat "$AMPATH"/.cache/unavailable-args | sort)" + echo -e " 💀 ERROR, the following programs you want to remove are NOT in $APPSPATH :\n\n$(cat "$AMCACHEDIR"/unavailable-args | sort)" else - echo -e " 💀 ERROR, the following programs you want to remove are NOT in\n $APPSPATH :\n\n$(cat "$AMPATH"/.cache/unavailable-args | sort)" + echo -e " 💀 ERROR, the following programs you want to remove are NOT in\n $APPSPATH :\n\n$(cat "$AMCACHEDIR"/unavailable-args | sort)" fi echo -e '\n INVALID "APPNAME"!' echo -e "\n-----------------------------------------------------------------------\n" echo ' ◆ INSTALLED PROGRAMS/VALID ARGUMENTS (SEE THE "APPNAME" COLUMN):' - $AMCLIPATH -f | grep -v "STANDALONE PROGRAMS MANAGED"; rm "$AMPATH"/.cache/unavailable-args + $AMCLIPATH -f | grep -v "STANDALONE PROGRAMS MANAGED"; rm "$AMCACHEDIR"/unavailable-args echo -e "-----------------------------------------------------------------------" exit else @@ -35,7 +35,7 @@ function _REMOVE() { if ls "$APPSPATH"/$arg > /dev/null 2>&1; then $SUDOCOMMAND "$APPSPATH"/$arg/remove && sleep 0.5 && echo ' ◆ "'"$(echo $arg | tr a-z A-Z)"'" HAS BEEN SUCCESSFULLY REMOVED!' else - echo " - $arg" >> "$AMPATH"/.cache/unavailable-args + echo " - $arg" >> "$AMCACHEDIR"/unavailable-args fi } @@ -52,7 +52,7 @@ function _remove() { esac esac else - echo " - $arg" >> "$AMPATH"/.cache/unavailable-args + echo " - $arg" >> "$AMCACHEDIR"/unavailable-args fi } @@ -72,12 +72,12 @@ function _do_rollback() { echo ' When an executable called "updater" is available, the app is only updateable.'; exit else if grep -q "api.github.com" "$APPSPATH"/$2/AM-updater; then - rm -f "$AMPATH/.cache/rollback-args"; + rm -f "$AMCACHEDIR/rollback-args"; extension=$(cat "$APPSPATH"/$2/version | tr '.' '\n' | tail -1) REPO=$(grep -i "REPO=" "$APPSPATH"/$2/AM-updater | grep -o -P '(?<=").*(?=")') printf "%s\n" "$(curl -Ls $HeaderAuthWithGITPAT https://api.github.com/repos/$REPO/releases?per_page=100 \ - | grep browser_download_url | cut -d '"' -f 4)" | tr ' ' '\n' | grep -i "$extension$" >> "$AMPATH/.cache/rollback-args" - if ! grep -q "[0-9]" "$AMPATH"/.cache/rollback-args; then + | grep browser_download_url | cut -d '"' -f 4)" | tr ' ' '\n' | grep -i "$extension$" >> "$AMCACHEDIR/rollback-args" + if ! grep -q "[0-9]" "$AMCACHEDIR"/rollback-args; then echo " ERROR: No valid links found, sorry!" exit else @@ -86,7 +86,7 @@ function _do_rollback() { echo "Rollback will be done from https://github.com/$REPO" echo "-----------------------------------------------------------------------" printf "Select a URL from this menu (read carefully) or press CTRL+C to abort:\n-----------------------------------------------------------------------\n"; sleep 1; - select d in $(cat "$AMPATH/.cache/rollback-args"); do test -n "$d" && break; echo ">>> Invalid Selection"; done + select d in $(cat "$AMCACHEDIR/rollback-args"); do test -n "$d" && break; echo ">>> Invalid Selection"; done cp "$APPSPATH"/$2/AM-updater "$APPSPATH"/$2/AM-rollback sed -i 's/version0/#version0/g' "$APPSPATH"/$2/AM-rollback sed -i '/show-progress/c\wget -q --show-progress '$d'' "$APPSPATH"/$2/AM-rollback @@ -104,7 +104,7 @@ function _do_rollback() { rm -f "$APPSPATH"/$2/AM-rollback rm -f "$APPSPATH"/$2/version echo $d >> "$APPSPATH"/$2/version - rm -R -f "$AMPATH"/.cache/* + _clean_amcachedir _list_updatable_apps echo -e "\nROLLBACK SUCCESSFUL!" exit @@ -200,9 +200,9 @@ function _backup() { function _do_backup() { while [ -n "$1" ]; do - rm -f $AMPATH/.cache/backup-args; - echo "$@" | tr ' ' '\n' >> $AMPATH/.cache/backup-args && echo STOP >> $AMPATH/.cache/backup-args; - ARGS=$(tail -n +2 $AMPATH/.cache/backup-args) + rm -f "$AMCACHEDIR"/backup-args; + echo "$@" | tr ' ' '\n' >> "$AMCACHEDIR"/backup-args && echo STOP >> "$AMCACHEDIR"/backup-args; + ARGS=$(tail -n +2 "$AMCACHEDIR"/backup-args) for arg in $ARGS; do if [ $arg == STOP ]; then exit @@ -238,14 +238,15 @@ function _overwrite() { function _do_overwrite() { while [ -n "$1" ]; do - rm -f "$AMPATH"/.cache/overwrite-args - echo "$@" | tr ' ' '\n' >> "$AMPATH"/.cache/overwrite-args && echo STOP >> "$AMPATH"/.cache/overwrite-args - ARGS=$(tail -n +2 $AMPATH/.cache/overwrite-args) + rm -f "$AMCACHEDIR"/overwrite-args + echo "$@" | tr ' ' '\n' >> "$AMCACHEDIR"/overwrite-args && echo STOP >> "$AMCACHEDIR"/overwrite-args + ARGS=$(tail -n +2 "$AMCACHEDIR"/overwrite-args) for arg in $ARGS; do if [ $arg == STOP ]; then exit else _overwrite + _remove_info_files fi done done @@ -372,9 +373,9 @@ case "$1" in '-R') # THIS OPTION REMOVES PROGRAMS WITHOUT ASKING while [ -n "$1" ]; do - rm -f "$AMPATH"/.cache/remove-args - echo "$@" | tr ' ' '\n' >> "$AMPATH"/.cache/remove-args && echo STOP >> "$AMPATH"/.cache/remove-args - ARGS=$(tail -n +2 "$AMPATH"/.cache/remove-args) + rm -f "$AMCACHEDIR"/remove-args + echo "$@" | tr ' ' '\n' >> "$AMCACHEDIR"/remove-args && echo STOP >> "$AMCACHEDIR"/remove-args + ARGS=$(tail -n +2 "$AMCACHEDIR"/remove-args) for arg in $ARGS; do if [ $arg == STOP ]; then _remove_check_removals @@ -389,9 +390,9 @@ case "$1" in '-r'|'remove') # THIS OPTION ALLOWS YOU TO CHOOSE WHETHER TO REMOVE PROGRAMS OR NOT while [ -n "$1" ]; do - rm -f "$AMPATH"/.cache/remove-args - echo "$@" | tr ' ' '\n' >> "$AMPATH"/.cache/remove-args && echo STOP >> "$AMPATH"/.cache/remove-args - ARGS=$(tail -n +2 "$AMPATH"/.cache/remove-args) + rm -f "$AMCACHEDIR"/remove-args + echo "$@" | tr ' ' '\n' >> "$AMCACHEDIR"/remove-args && echo STOP >> "$AMCACHEDIR"/remove-args + ARGS=$(tail -n +2 "$AMCACHEDIR"/remove-args) for arg in $ARGS; do if [ $arg == STOP ]; then _remove_check_removals diff --git a/modules/sandboxes.am b/modules/sandboxes.am index bebfc2a58..1c8e5f1f2 100644 --- a/modules/sandboxes.am +++ b/modules/sandboxes.am @@ -129,9 +129,9 @@ case "$1" in esac while [ -n "$1" ]; do - rm -f $AMPATH/.cache/home-args - echo "$@" | tr ' ' '\n' >> $AMPATH/.cache/home-args && echo STOP >> $AMPATH/.cache/home-args - ARGS=$(tail -n +2 $AMPATH/.cache/home-args) + rm -f "$AMCACHEDIR"/home-args + echo "$@" | tr ' ' '\n' >> "$AMCACHEDIR"/home-args && echo STOP >> "$AMCACHEDIR"/home-args + ARGS=$(tail -n +2 "$AMCACHEDIR"/home-args) for arg in $ARGS; do if [ $arg == STOP ]; then exit diff --git a/modules/template.am b/modules/template.am index 9abc1d084..470b7214f 100644 --- a/modules/template.am +++ b/modules/template.am @@ -9,9 +9,9 @@ case $2 in esac while [ -n "$1" ]; do - rm -f $AMPATH/.cache/template-args - echo "$@" | tr ' ' '\n' >> $AMPATH/.cache/template-args && echo STOP >> $AMPATH/.cache/template-args - ARGS=$(tail -n +2 $AMPATH/.cache/template-args) + rm -f "$AMCACHEDIR"/template-args + echo "$@" | tr ' ' '\n' >> "$AMCACHEDIR"/template-args && echo STOP >> "$AMCACHEDIR"/template-args + ARGS=$(tail -n +2 "$AMCACHEDIR"/template-args) for arg in $ARGS; do if [ $arg == STOP ]; then diff --git a/programs/aarch64-apps b/programs/aarch64-apps index 1df053f13..668f45899 100644 --- a/programs/aarch64-apps +++ b/programs/aarch64-apps @@ -16,5 +16,6 @@ ◆ vivaldi-snapshot : Advanced Web Browser (Testing Version). ◆ vivaldi-stable : Advanced Web Browser (Stable Version). ◆ vscodium : Community-driven, freely-licensed binary distribution of MS VSCode. +◆ yazi : Blazing fast terminal file manager written in Rust. ◆ zap : Delightful command line AppImage package manager for appimage.github.io. -◆ zmninja : Ionic app for Home/Commerical Security Surveillance. +◆ zmninja : Ionic app for Home/Commerical Security Surveillance. diff --git a/programs/aarch64/yazi b/programs/aarch64/yazi new file mode 100644 index 000000000..ec3dd2e73 --- /dev/null +++ b/programs/aarch64/yazi @@ -0,0 +1,53 @@ +#!/bin/sh + +# AM INSTALL SCRIPT VERSION 3. + +set -u +APP=yazi +SITE="sxyazi/yazi" + +# CREATE DIRECTORIES AND ADD REMOVER +[ -n "$APP" ] && mkdir -p "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 +echo "#!/bin/sh\nset -e\nrm -f /usr/local/bin/$APP\nrm -R -f /opt/$APP" > "/opt/$APP/remove" +echo "rm -f /usr/local/bin/ya" >> "/opt/$APP/remove" +chmod a+x "/opt/$APP/remove" + +# DOWNLOAD AND PREPARE THE APP +# $version is also used for updates + + +version=$(curl -Ls https://api.github.com/repos/"$SITE"/releases | jq '.' | sed 's/[()",{}]/ /g; s/ /\n/g' | grep -o 'https.*aarch64.*linux.*gnu.*zip$' | head -1) +wget "$version" && echo "$version" > "/opt/$APP/version" || exit 1 +unzip ./*zip || exit 1 +cd .. +mv --backup=t ./tmp/*/* ./ && rm -R -f ./tmp || exit 1 +chmod a+x "/opt/$APP/$APP" "/opt/$APP/ya" || exit 1 + +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" && ln -s "/opt/$APP/ya" "/usr/local/bin/ya" + +# SCRIPT TO UPDATE THE PROGRAM +cat >> "/opt/$APP/AM-updater" << 'EOF' +#!/bin/sh +set -u +APP=yazi +SITE="sxyazi/yazi" +version0=$(cat /opt/$APP/version) +version=$(curl -Ls https://api.github.com/repos/"$SITE"/releases | jq '.' | sed 's/[()",{}]/ /g; s/ /\n/g' | grep -o 'https.*aarch64.*linux.*gnu.*zip$' | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ]; then + notify-send "A new version of $APP is available, please wait" + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + wget "$version" || exit 1 + unzip ./*zip || exit 1 + cd .. + mv --backup=t ./tmp/*/* ./ && rm -R -f ./tmp || exit 1 + echo "$version" > ./version + rm -R -f ./tmp ./*~ + chmod a+x "/opt/$APP/$APP" "/opt/$APP/ya" || exit 1 + notify-send "$APP is updated!" + exit 0 +fi +echo "Update not needed!" +EOF +chmod a+x "/opt/$APP/AM-updater" || exit 1 diff --git a/programs/x86_64-apps b/programs/x86_64-apps index 0181c7d29..e73dace57 100644 --- a/programs/x86_64-apps +++ b/programs/x86_64-apps @@ -1688,6 +1688,7 @@ ◆ sunsama-appimage : The daily planner for elite professionals. ◆ sunshine : Sunshine is a Gamestream host for Moonlight. ◆ sup : A Slack client with WhatsApp like UI. +◆ superfile : Pretty fancy and modern terminal file manager. ◆ superpaper : A cross-platform multi monitor wallpaper manager. ◆ superproductivity : An advanced todo list app with integrated Timeboxing. ◆ superslicer-bin : G-code generator for 3D printers. @@ -1977,6 +1978,7 @@ ◆ yangdownloader-appimage : Downloads best-quality audio and video from YouTube. ◆ yank-note : A Hackable Markdown Note Application for Programmers. ◆ yaya : Yet Another Yahtzee-esque Application. +◆ yazi : Blazing fast terminal file manager written in Rust. ◆ yesplaymusic : A third party music player for Netease Music. ◆ youtube-music : Amazing electron wrapper for YouTube Music featuring plugins. ◆ youtubesearchfilter : YouTube searches with/without a pre-filter from CLI. diff --git a/programs/x86_64/superfile b/programs/x86_64/superfile new file mode 100644 index 000000000..85f450b5c --- /dev/null +++ b/programs/x86_64/superfile @@ -0,0 +1,53 @@ +#!/bin/sh + +# AM INSTALL SCRIPT VERSION 3. + +set -u +APP=superfile +SITE="yorukot/superfile" + +# CREATE DIRECTORIES AND ADD REMOVER +[ -n "$APP" ] && mkdir -p "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 +echo "#!/bin/sh\nset -e\nrm -f /usr/local/bin/spf\nrm -R -f /opt/$APP" > "/opt/$APP/remove" +#echo "rm -f /usr/share/applications/AM-$APP.desktop" >> "/opt/$APP/remove" +chmod a+x "/opt/$APP/remove" + +# DOWNLOAD AND PREPARE THE APP +# $version is also used for updates + + +version=$(curl -Ls https://api.github.com/repos/"$SITE"/releases | jq '.' | sed 's/[()",{}]/ /g; s/ /\n/g' | grep -o 'https.*linux.*amd64.*tar.gz$' | head -1) +wget "$version" && echo "$version" > "/opt/$APP/version" || exit 1 +tar fx ./*tar* || exit 1 +cd .. +mv --backup=t ./tmp/*/*/* ./ && rm -R -f ./tmp || exit 1 +chmod a+x "/opt/$APP/spf" || exit 1 + +# LINK TO PATH +ln -s "/opt/$APP/spf" "/usr/local/bin/spf" + +# SCRIPT TO UPDATE THE PROGRAM +cat >> "/opt/$APP/AM-updater" << 'EOF' +#!/bin/sh +set -u +APP=superfile +SITE="yorukot/superfile" +version0=$(cat /opt/$APP/version) +version=$(curl -Ls https://api.github.com/repos/"$SITE"/releases | jq '.' | sed 's/[()",{}]/ /g; s/ /\n/g' | grep -o 'https.*linux.*amd64.*tar.gz$' | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ]; then + notify-send "A new version of $APP is available, please wait" + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + wget "$version" || exit 1 + tar fx ./*tar* || exit 1 + cd .. + mv --backup=t ./tmp/*/*/* ./ && rm -R -f ./tmp || exit 1 + echo "$version" > ./version + rm -R -f ./tmp ./*~ + chmod a+x "/opt/$APP/spf" || exit 1 + notify-send "$APP is updated!" + exit 0 +fi +echo "Update not needed!" +EOF +chmod a+x "/opt/$APP/AM-updater" || exit 1 diff --git a/programs/x86_64/yazi b/programs/x86_64/yazi new file mode 100644 index 000000000..b4695f1f4 --- /dev/null +++ b/programs/x86_64/yazi @@ -0,0 +1,53 @@ +#!/bin/sh + +# AM INSTALL SCRIPT VERSION 3. + +set -u +APP=yazi +SITE="sxyazi/yazi" + +# CREATE DIRECTORIES AND ADD REMOVER +[ -n "$APP" ] && mkdir -p "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 +echo "#!/bin/sh\nset -e\nrm -f /usr/local/bin/$APP\nrm -R -f /opt/$APP" > "/opt/$APP/remove" +echo "rm -f /usr/local/bin/ya" >> "/opt/$APP/remove" +chmod a+x "/opt/$APP/remove" + +# DOWNLOAD AND PREPARE THE APP +# $version is also used for updates + + +version=$(curl -Ls https://api.github.com/repos/"$SITE"/releases | jq '.' | sed 's/[()",{}]/ /g; s/ /\n/g' | grep -o 'https.*x86_64.*linux.*gnu.*zip$' | head -1) +wget "$version" && echo "$version" > "/opt/$APP/version" || exit 1 +unzip ./*zip || exit 1 +cd .. +mv --backup=t ./tmp/*/* ./ && rm -R -f ./tmp || exit 1 +chmod a+x "/opt/$APP/$APP" "/opt/$APP/ya" || exit 1 + +# LINK TO PATH +ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" && ln -s "/opt/$APP/ya" "/usr/local/bin/ya" + +# SCRIPT TO UPDATE THE PROGRAM +cat >> "/opt/$APP/AM-updater" << 'EOF' +#!/bin/sh +set -u +APP=yazi +SITE="sxyazi/yazi" +version0=$(cat /opt/$APP/version) +version=$(curl -Ls https://api.github.com/repos/"$SITE"/releases | jq '.' | sed 's/[()",{}]/ /g; s/ /\n/g' | grep -o 'https.*x86_64.*linux.*gnu.*zip$' | head -1) +[ -n "$version" ] || { echo "Error getting link"; exit 1; } +if [ "$version" != "$version0" ]; then + notify-send "A new version of $APP is available, please wait" + mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 + wget "$version" || exit 1 + unzip ./*zip || exit 1 + cd .. + mv --backup=t ./tmp/*/* ./ && rm -R -f ./tmp || exit 1 + echo "$version" > ./version + rm -R -f ./tmp ./*~ + chmod a+x "/opt/$APP/$APP" "/opt/$APP/ya" || exit 1 + notify-send "$APP is updated!" + exit 0 +fi +echo "Update not needed!" +EOF +chmod a+x "/opt/$APP/AM-updater" || exit 1