From f60142b7ba0ba1f40dcd5783a5710e7cecb48159 Mon Sep 17 00:00:00 2001 From: Samuel <36420837+Samueru-sama@users.noreply.github.com> Date: Mon, 26 Aug 2024 19:47:42 -0400 Subject: [PATCH 01/36] allow appman to work outside `$HOME` APP-MANAGER --- APP-MANAGER | 282 +++++++++++++++++++++++----------------------------- 1 file changed, 124 insertions(+), 158 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index a29cf0ee5..fb0a22311 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -25,35 +25,98 @@ export DATADIR="${XDG_DATA_HOME:-$HOME/.local/share}" export CONFIGDIR="${XDG_CONFIG_HOME:-$HOME/.config}" export CACHEDIR="${XDG_CACHE_HOME:-$HOME/.cache}" +export APPMANCONFIG="$CONFIGDIR/appman" +export SCRIPTDIR="$(xdg-user-dir DESKTOP 2>/dev/null || echo "$HOME")" +APPMANCONFIG="$CONFIGDIR/appman" +SCRIPTDIR="$(xdg-user-dir DESKTOP 2>/dev/null || echo "$HOME")" +export SCRIPTDIR + +# Colors +RED='\033[0;31m' +Gold='\033[0;33m' +Green='\033[0;32m' +LightBlue='\033[1;34m' +DIVIDING_LINE="-----------------------------------------------------------------------------" + +# Prevent the use of "sudo" ("AM") +[ -n "$SUDO_COMMAND" ] && echo -e "\n Please do not use \"sudo\" to execute \"$CLI\", try again.\n" && exit 1 + function _create_cache_dir() { AMCACHEDIR="$CACHEDIR/$AMCLI" mkdir -p "$AMCACHEDIR" } function _clean_amcachedir() { - if [ -z "$AMCACHEDIR" ]; then exit 1; fi + [ -z "$AMCACHEDIR" ] && exit 1 rm -f "$AMCACHEDIR"/* } -APPMANCONFIG="$CONFIGDIR/appman" -SCRIPTDIR="$(xdg-user-dir DESKTOP 2>/dev/null || echo "$HOME")" -export SCRIPTDIR +################################################################################ +# AM/APPMAN +################################################################################ -# Colors -RED='\033[0;31m'; Gold='\033[0;33m'; Green='\033[0;32m'; LightBlue='\033[1;34m'; -DIVIDING_LINE="--------------------\ ----------------------------------------------------------" +# "APPMAN" CORE VARIABLES AND FUNCTIONS +function _appman_check() { + if [ ! -f "$APPMANCONFIG"/appman-config ]; then + echo "$DIVIDING_LINE" + echo ">>> Thank you for choosing AppMan!" + echo "$DIVIDING_LINE" + echo " Before proceeding with any task, where do you want to install apps?" + printf '\n%s\n' " SYNTAX: /FULLPATH/TO/DIRNAME" + printf '%s\n\n' " EXAMPLE: $HOME/My-apps" + echo " NOTE: Any spaces in the path will be replaced for dashes" + echo " NOTE: If no input is given then \"~/Applications\" will be used as default" + echo "" + echo " if you wish to later change the location, first remove all the programs" + echo " and then edit the "$APPMANCONFIG"/appman-config file." + echo "$DIVIDING_LINE" + read -r -ep " Write the path or just press enter to use default: " location + location="$(echo "$location" | sed 's/[ \t]/-/g' 2>/dev/null)" + [ -z "$location" ] && location="$HOME/Applications" + if [ "$location" = "$BINDIR" ]; then + echo "$DIVIDING_LINE" + echo " πŸ’€ ERROR, you can't install applications in \"$BINDIR\"" + echo " $BINDIR is normally used for executables, Please choose a different path and retry!" + echo "$DIVIDING_LINE" + exit 1 + elif ! echo "$location" | grep "^/" >/dev/null 2>&1; then + echo " πŸ’€ ERROR: You need to specify a full path and not a relative path" + exit 1 + fi + if ! mkdir -p "$location" >/dev/null 2>&1; then + echo " πŸ’€ ERROR: You don't have write access to $location or it is invalid" + exit 1 + fi + mkdir -p "$APPMANCONFIG" || exit 1 + echo "${location%/}" > "$APPMANCONFIG"/appman-config || exit 1 + echo "$DIVIDING_LINE" + echo " You are ready! Start installing your favorite apps locally!" + echo " All apps will be installed in $location" + echo " In case of problems, use the option \"-h\"." + echo "$DIVIDING_LINE" + fi +} -# Prevent the use of "sudo" ("AM") -function _no_sudo() { - if [ -n "$SUDO_COMMAND" ]; then - echo -e "\n Please do not use \"sudo\" to execute \"$CLI\", try again.\n" +function _appman() { + APPSDIR="$(cat "$APPMANCONFIG"/appman-config | head -1)" + mkdir -p "$APPSDIR"/appman/modules || exit 1 + mkdir -p "$BINDIR" "$DATADIR"/applications "$DATADIR"/icons || exit 1 + AMCLI="appman" + AMCLIPATH="$DIR/$AMCLI" + SUDOCMD="" + APPSPATH="$APPSDIR" + AMPATH="$APPSDIR/$AMCLI" + _create_cache_dir + if [ ! -w "$APPSPATH" ]; then + echo " ERROR: You don't have write access to $APPSPATH" exit 1 + elif ! echo "$PATH" | grep "$BINDIR" >/dev/null 2>&1; then + echo "$DIVIDING_LINE" + echo " ⚠️ WARNING: \"$BINDIR\" is not in PATH, apps may not run." + echo "$DIVIDING_LINE" fi } -_no_sudo - # "AM" CORE VARIABLES function _am() { AMCLI="am" @@ -72,76 +135,20 @@ function _am() { mkdir -p "$AMPATH"/modules } -# "APPMAN" CORE VARIABLES AND FUNCTIONS -function _appman_initialize() { - APPSDIR=$1 - mkdir -p ~/"$APPSDIR"/appman/modules - mkdir -p "$BINDIR" "$DATADIR"/applications "$DATADIR"/icons - AMCLI="appman" - AMCLIPATH="$DIR/$AMCLI" - SUDOCMD="" - APPSPATH="$HOME/$APPSDIR" - AMPATH="$HOME/$APPSDIR/$AMCLI" - _create_cache_dir -} - -function _appman_prompt_for_directory() { - local location - read -r -ep " Please, write the name or the path of your custom application's folder: $(echo -e '\n\n '"$HOME"'/')" location - echo "$location" -} - -function _appman_validate_directory() { - location=$1 - if [ "$location" = "" ]; then - echo -e "$DIVIDING_LINE\nOPERATION ABORTED!" - exit 1 - elif [ "$location" = ".local/bin" ]; then - echo -e "$DIVIDING_LINE\n πŸ’€ ERROR, you can't install applications into a \"\$PATH\"" - echo -e " The ~/.local/bin directory is normally used for executables.\n Please, choose a different path and retry! \n$DIVIDING_LINE" - exit 1 - else - location_appman="${location/#$HOME}" - location_appman="${location_appman// /-}" - location_appman="${location_appman#/}" - location_appman="${location_appman%/}" - echo "$location_appman" - fi -} - -function _appman() { - if [ ! -f "$APPMANCONFIG"/appman-config ]; then - echo -e "$DIVIDING_LINE\n >>> Thank you for choosing AppMan! \n$DIVIDING_LINE" - echo " Before proceeding with any task, write the name of the directory in which" - echo " you will install the apps, for example \"Programs\" or \"My-apps\", you can" - echo " also choose a subfolder, for example \".local/My-apps\" or a deeper path." - echo -e "\n The destination folder will be created in $HOME\n" - echo -e " SYNTAX: PATH/TO/DIRNAME\n" - echo " NOTE, any spaces or "/" at the beginning and end will be removed. If you" - echo " decide to change your choice in the future, first remove all the programs" - echo -e " and then edit the ~/.config/appman/appman-config text file.\n$DIVIDING_LINE\n" - location=$(_appman_prompt_for_directory) - validated_location=$(_appman_validate_directory "$location") - mkdir -p "$APPMANCONFIG" - echo "$validated_location" >> "$APPMANCONFIG"/appman-config - echo -e "$DIVIDING_LINE\n You are ready! Start installing your favorite apps locally!" - echo " All apps will be installed in $HOME/$validated_location" - echo -e "\n In case of problems, use the option \"-h\".\n$DIVIDING_LINE" - fi - _appman_initialize "$(<"$APPMANCONFIG"/appman-config)" - if ! echo "$PATH" | grep -q "$BINDIR"; then - echo -e "$DIVIDING_LINE\n ⚠️ WARNING: \"$BINDIR\" is not in PATH, apps may not run.\n$DIVIDING_LINE" - fi -} - # DETERMINE WHEN TO USE "AM" OR "APPMAN" -if [ "$(realpath $0)" = "/opt/am/APP-MANAGER" ]; then +if [ "$(realpath "$0")" = "/opt/am/APP-MANAGER" ]; then _am -elif [ "$(realpath $0)" = "/usr/bin/am" ]; then +elif [ "$(realpath "$0")" = "/usr/bin/am" ]; then _am else + _appman_check _appman fi + +################################################################################ +# FINALIZE +################################################################################ + AMCLIUPPER=$(echo "$AMCLI" | tr '[:lower:]' '[:upper:]') # Create new data directory and move important files there @@ -158,9 +165,7 @@ if test -f "$AMDATADIR"/betatester; then fi function _betatester_message_on() { - if test -f "$AMDATADIR"/betatester; then - echo -e "$DIVIDING_LINE\n\"$AMCLIUPPER\" $AMVERSION: DEVELOPER MODE\n$DIVIDING_LINE" - fi + [ -f "$AMDATADIR"/betatester ] && echo -e "$DIVIDING_LINE\n\"$AMCLIUPPER\" $AMVERSION: DEVELOPER MODE\n$DIVIDING_LINE" } # Apps database in use @@ -199,9 +204,7 @@ function _am_dependences_check() { function _am_security_check() { _am_dependences_check # Check and create the $AMPATH directory if it does not exist - if [ ! -d "$AMPATH" ]; then - $SUDOCMD mkdir -p "$AMPATH" - fi + [ ! -d "$AMPATH" ] && $SUDOCMD mkdir -p "$AMPATH" } _am_security_check @@ -328,11 +331,8 @@ function _check_version_if_any_version_reference_is_somewhere() { } function _check_version_if_zsync_file_exists() { - APPVERSION=$(strings -d ./"$arg"/*.zsync | grep -i "$(echo "$arg" | sed 's/-appimage//g')" | - _check_version_grep_numbers) - if [ -z "$APPVERSION" ]; then - APPVERSION=$(date -r ./"$arg"/*.zsync "+%Y.%m.%d") - fi + APPVERSION=$(strings -d ./"$arg"/*.zsync | grep -i "$(echo "$arg" | sed 's/-appimage//g')" | _check_version_grep_numbers) + [ -z "$APPVERSION" ] && APPVERSION=$(date -r ./"$arg"/*.zsync "+%Y.%m.%d") } function _check_version_if_version_file_exists() { @@ -358,9 +358,7 @@ function _check_version_if_version_file_exists() { function _check_version_if_an_updater_exists() { APPVERSION=$("$APPSPATH"/"$arg"/updater -d "$APPSPATH"/"$arg"/"$arg" 2>/dev/null | grep -i "$arg" |\ _check_version_grep_numbers) - if [ -z "$APPVERSION" ]; then - _check_version_if_any_version_reference_is_somewhere - fi + [ -z "$APPVERSION" ] && _check_version_if_any_version_reference_is_somewhere } function _check_version_if_library() { @@ -375,7 +373,7 @@ function _check_version_if_binary_in_place() { function _check_version() { rm -f "$AMCACHEDIR"/version-args cd "$APPSPATH" && - INSTALLED_APPS=$(find . -name 'remove' -printf "%h\n" 2>/dev/null | du -sh -- * 2> /dev/null |\ + 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 if test -f ./"$arg"/remove 2>/dev/null; then @@ -391,17 +389,13 @@ function _check_version() { _check_version_if_any_version_reference_is_somewhere elif echo "$arg" | grep -q "ffwa-"; then APPVERSION="WebApp" - elif grep -q "usr/local/lib" "$APPSPATH"/"$arg"/remove 2> /dev/null; then + elif grep -q "usr/local/lib" "$APPSPATH"/"$arg"/remove 2>/dev/null; then _check_version_if_library else APPVERSION="unknown" fi if [ -z "$APPVERSION" ]; then - if test -f ./"$arg"/"$arg" 2>/dev/null; then - _check_version_if_binary_in_place - else - APPVERSION="unknown" - fi + [ -f ./"$arg"/"$arg" ] && _check_version_if_binary_in_place || APPVERSION="unknown" fi echo " β—† $arg | $APPVERSION" >> "$AMCACHEDIR"/version-args fi @@ -410,7 +404,7 @@ function _check_version() { function _check_version_for_auto_updatable_apps() { cd "$APPSPATH" && - INSTALLED_APPS=$(find . -name 'remove' -printf "%h\n" 2>/dev/null | du -sh -- * 2> /dev/null | sort -rh | sed 's@.* @@') + 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 if test -f ./"$arg"/updater 2>/dev/null; then _check_version_if_an_updater_exists @@ -476,49 +470,29 @@ function _update_github_api_key_in_the_updater_files() { } # "APPMAN MODE" FOR "AM" USERS -function _appman_mode_enabled_message() { - if [ "$CLI" = am ]; then - echo -e "$DIVIDING_LINE\n \"AM\" is running as \"AppMan\", use ${Green}am --system\033[0m to switch it back to \"AM\"\n$DIVIDING_LINE" - fi -} +APPMAN_MSG="$DIVIDING_LINE\n \"AM\" is running as \"AppMan\", use ${Green}am --system\033[0m to switch it back to \"AM\"\n$DIVIDING_LINE" +APPMAN_MSG_OFF="$DIVIDING_LINE\n \"AppMan Mode\" disabled! \n$DIVIDING_LINE" function _if_appman_mode_enabled() { - [ "$CLI" = am ] && [ -f "$APPMANCONFIG"/appman-mode ] && _appman_mode_enabled_message + [ "$CLI" = am ] && [ -f "$APPMANCONFIG"/appman-mode ] && echo -e "$APPMAN_MSG" } function _use_appman() { _online_check - if [ "$CLI" = appman ]; then - echo " This function only works for AM" && exit - fi - if test -f "$APPMANCONFIG"/appman-mode; then - _appman; _appman_mode_enabled_message - else - mkdir -p "$APPMANCONFIG" && touch "$APPMANCONFIG"/appman-mode - _appman; _appman_mode_enabled_message - fi + [ "$CLI" = appman ] && echo " This function only works for AM" && exit + [ ! -f "$APPMANCONFIG"/appman-mode ] && mkdir -p "$APPMANCONFIG" && touch "$APPMANCONFIG"/appman-mode + _appman && echo -e "$APPMAN_MSG" } -function _back_to_am() { - if test -f "$APPMANCONFIG"/appman-mode; then - rm -f "$APPMANCONFIG"/appman-mode && echo -e "$DIVIDING_LINE\n \"AppMan Mode\" disabled! \n$DIVIDING_LINE" - fi +function _use_am_again() { + [ -f "$APPMANCONFIG"/appman-mode ] && rm -f "$APPMANCONFIG"/appman-mode && echo -e "$APPMAN_MSG_OFF" } if [ "$AMCLI" = am ]; then if test -f "$APPMANCONFIG"/appman-mode; then - case "$1" in - '--system') - _back_to_am - ;; - ''|*) - if ! test -f "$APPMANCONFIG"/appman-config; then - _appman_mode_enabled_message - fi - _appman - AMCLIPATH="/opt/am/APP-MANAGER" - ;; - esac + [ ! -f "$APPMANCONFIG"/appman-config ] && echo -e "$APPMAN_MSG" + _appman + AMCLIPATH="/opt/am/APP-MANAGER" elif [ ! -w /opt/am ]; then read -r -p " \"AM\" is read-only, want to use it in \"AppMan Mode\" (Y,n)? " yn if echo "$yn" | grep -i '^y' >/dev/null 2>&1; then @@ -532,12 +506,8 @@ fi # BETA TESTER function _use_beta_tester() { - if [ "$1" = "--devmode-disable" ]; then - rm -f "$AMDATADIR"/betatester - else - touch "$AMDATADIR"/betatester - _betatester_message_on - fi + [ "$1" = "--devmode-disable" ] && rm -f "$AMDATADIR"/betatester \ + || touch "$AMDATADIR"/betatester && _betatester_message_on } # CLEAN UNNEEDED FILES @@ -547,22 +517,22 @@ function _clean_amcachedir_message() { } function _clean_all_home_cache_directories_of_appimages() { - if test -d "$APPSPATH"/*/*.home/.cache 2> /dev/null; then + if test -d "$APPSPATH"/*/*.home/.cache 2>/dev/null; then rm -Rf "$APPSPATH"/*/*.home/.cache/* && echo " βœ” Clear the contents of all *.home/.cache AppImages directories" fi } function _clean_all_tmp_directories_from_appspath() { - if test -d "$APPSPATH"/*/tmp 2> /dev/null; then + if test -d "$APPSPATH"/*/tmp 2>/dev/null; then rm -Rf "$APPSPATH"/*/tmp && echo ' βœ” Removed all '"$APPSPATH"'/*/tmp directories' fi } function _clean_determine_removable_launchers() { - if ! test -f "$APPIMAGENAME" 2> /dev/null; then - if ! test -d "$MOUNTPOINTS" 2> /dev/null; then + if ! test -f "$APPIMAGENAME" 2>/dev/null; then + if ! test -d "$MOUNTPOINTS" 2>/dev/null; then if echo "$MOUNTPOINTS" | grep -q "/media/"; then unmounted_poin="/media" elif echo "$MOUNTPOINTS" | grep -q "/mnt/"; then @@ -579,7 +549,7 @@ function _clean_determine_removable_launchers() { } function _clean_launchers() { - if test -d "$DATADIR"/applications/AppImages 2> /dev/null; then + if test -d "$DATADIR"/applications/AppImages 2>/dev/null; then for var in "$DATADIR"/applications/AppImages/*.desktop; do APPIMAGENAME=$(grep "Exec=" 0<"$var" 2>/dev/null | head -1 | cut -c 6- | sed 's/\s.*$//') launcher2del=$(basename -- "$(echo "$APPIMAGENAME" | tr '[:upper:]' '[:lower:]')") @@ -621,7 +591,7 @@ function _use_clean() { _clean_amcachedir_message _clean_all_home_cache_directories_of_appimages _clean_all_tmp_directories_from_appspath - _clean_launchers 2> /dev/null + _clean_launchers 2>/dev/null _clean_old_modules _clean_and_remove_old_am_cache_directory } @@ -647,7 +617,8 @@ function _use_force_latest() { } #HELP -function _help_body() { +function _use_help() { + _if_appman_mode_enabled printf " NAME: ${Green}$AMCLIUPPER\033[0m \ VERSION: ${Green}$AMVERSION\033[0m @@ -900,12 +871,7 @@ $DIVIDING_LINE https://portable-linux-apps.github.io -\n" -} - -function _use_help() { - _if_appman_mode_enabled - _help_body | fold -sw 77 | sed 's/^/ /g' | less -Ir +\n" | fold -sw 77 | sed 's/^/ /g' | less -Ir } # SYNCHRONIZE @@ -920,7 +886,7 @@ function _sync_installation_scripts() { CURRENT=$(cat "$APPSPATH"/"$arg"/.am-installer/"$scriptname") SOURCE=$(curl -Ls "$APPSDB"/"$scriptname") if [ "$CURRENT" = "$SOURCE" ]; then - echo -ne "\r" 2> /dev/null + echo -ne "\r" 2>/dev/null else echo -e " β—† Changed https://github.com/ivan-hc/AM/blob/main/programs/$arch/$scriptname" fi @@ -941,16 +907,16 @@ function _sync_modules() { cd "$AMPATH"/modules || return if ! test -f ./"$module_name"; then echo " β—† Downloading $module_name (not previously installed)..." - curl -Os "$AMREPO/modules/$module_name" 2> /dev/null + curl -Os "$AMREPO/modules/$module_name" 2>/dev/null chmod a+x ./"$MODULENAME" fi CURRENT=$(cat ./"$module_name" 2>/dev/null) SOURCE=$(curl -Ls "$AMREPO/modules/$module_name") if [ "$CURRENT" = "$SOURCE" ]; then - echo -ne "\r" 2> /dev/null + echo -ne "\r" 2>/dev/null else echo " β—† Updating $module_name..." - curl -Ls "$AMREPO/modules/$module_name" > ./"$module_name" 2> /dev/null + curl -Ls "$AMREPO/modules/$module_name" > ./"$module_name" 2>/dev/null fi done _clean_old_modules @@ -1018,14 +984,14 @@ function _update_all_apps() { APPNAME=$(echo "$appname" | tr '[:lower:]' '[:upper:]') if [ -w ./AM-updater ]; then start=$(date +%s) && - sh -x ./AM-updater > /dev/null 2>&1 | echo -ne ' Updating "'"$APPNAME"'"...\r' && + sh -x ./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 else - echo "" > /dev/null 2>&1 + echo "" >/dev/null 2>&1 fi done wait @@ -1072,7 +1038,7 @@ function _use_update() { if test -f "$APPSPATH"/"$arg"/AM-updater; then if [ -w "$APPSPATH"/"$arg"/AM-updater ]; then start=$(date +%s) - "$APPSPATH"/"$arg"/AM-updater > /dev/null 2>&1 | echo -ne " UPDATING $arg_upper\r" + "$APPSPATH"/"$arg"/AM-updater >/dev/null 2>&1 | echo -ne " UPDATING $arg_upper\r" end=$(date +%s) echo " β—† $arg_upper is updated, $((end - start)) seconds elapsed!" _clean_amcachedir @@ -1158,7 +1124,7 @@ case "$1" in _use_force_latest "$@" ;; '--system') - _back_to_am + _use_am_again ;; 'apikey') _use_apikey "$@" From 92bdc04c15aa84b38ce5c71ec167b75b1491e517 Mon Sep 17 00:00:00 2001 From: Samuel <36420837+Samueru-sama@users.noreply.github.com> Date: Mon, 26 Aug 2024 20:15:26 -0400 Subject: [PATCH 02/36] migrate older appman config to new version APP-MANAGER --- APP-MANAGER | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index fb0a22311..494156eb1 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -57,7 +57,12 @@ function _clean_amcachedir() { # "APPMAN" CORE VARIABLES AND FUNCTIONS function _appman_check() { - if [ ! -f "$APPMANCONFIG"/appman-config ]; then + if [ -f "$APPMANCONFIG"/appman-config ]; then # Convert old config + OLDAPPSDIR=$(head -1 "$APPMANCONFIG"/appman-config 2>/dev/null) + echo "$HOME/$OLDAPPSDIR" > "$APPMANCONFIG"/apps-path || exit 1 + rm -f "$APPMANCONFIG"/appman-config + fi + if [ ! -f "$APPMANCONFIG"/apps-path ]; then echo "$DIVIDING_LINE" echo ">>> Thank you for choosing AppMan!" echo "$DIVIDING_LINE" @@ -88,7 +93,7 @@ function _appman_check() { exit 1 fi mkdir -p "$APPMANCONFIG" || exit 1 - echo "${location%/}" > "$APPMANCONFIG"/appman-config || exit 1 + echo "${location%/}" > "$APPMANCONFIG"/apps-path || exit 1 echo "$DIVIDING_LINE" echo " You are ready! Start installing your favorite apps locally!" echo " All apps will be installed in $location" @@ -98,8 +103,8 @@ function _appman_check() { } function _appman() { - APPSDIR="$(cat "$APPMANCONFIG"/appman-config | head -1)" - mkdir -p "$APPSDIR"/appman/modules || exit 1 + APPSDIR="$(head -1 "$APPMANCONFIG"/apps-path 2>/dev/null)" + [ -n "$APPSDIR" ] && mkdir -p "$APPSDIR"/appman/modules || exit 1 mkdir -p "$BINDIR" "$DATADIR"/applications "$DATADIR"/icons || exit 1 AMCLI="appman" AMCLIPATH="$DIR/$AMCLI" From 59ba169c4abc99f9fd1977972b56bf954fca4c80 Mon Sep 17 00:00:00 2001 From: Samuel <36420837+Samueru-sama@users.noreply.github.com> Date: Mon, 26 Aug 2024 20:39:59 -0400 Subject: [PATCH 03/36] relative paths turn into paths starting in `$HOME` APP-MANAGER --- APP-MANAGER | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index 494156eb1..5263e4366 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -76,19 +76,18 @@ function _appman_check() { echo " and then edit the "$APPMANCONFIG"/appman-config file." echo "$DIVIDING_LINE" read -r -ep " Write the path or just press enter to use default: " location - location="$(echo "$location" | sed 's/[ \t]/-/g' 2>/dev/null)" + location="$(echo "$location" | sed 's/[ \t]/-/g; s|^\./||' 2>/dev/null)" [ -z "$location" ] && location="$HOME/Applications" + if ! echo "$location" | grep "^/" >/dev/null 2>&1; then + location="$HOME/$location" + fi if [ "$location" = "$BINDIR" ]; then echo "$DIVIDING_LINE" echo " πŸ’€ ERROR, you can't install applications in \"$BINDIR\"" echo " $BINDIR is normally used for executables, Please choose a different path and retry!" echo "$DIVIDING_LINE" exit 1 - elif ! echo "$location" | grep "^/" >/dev/null 2>&1; then - echo " πŸ’€ ERROR: You need to specify a full path and not a relative path" - exit 1 - fi - if ! mkdir -p "$location" >/dev/null 2>&1; then + elif ! mkdir -p "$location" 2>/dev/null || [ ! -w "$location" ]; then echo " πŸ’€ ERROR: You don't have write access to $location or it is invalid" exit 1 fi From 1534a85593f5090922b0e099e471609acbee3917 Mon Sep 17 00:00:00 2001 From: Samuel <36420837+Samueru-sama@users.noreply.github.com> Date: Mon, 26 Aug 2024 21:13:10 -0400 Subject: [PATCH 04/36] improve detection of `$BINDIR` APP-MANAGER --- APP-MANAGER | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/APP-MANAGER b/APP-MANAGER index 5263e4366..14b5f291f 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -81,7 +81,7 @@ function _appman_check() { if ! echo "$location" | grep "^/" >/dev/null 2>&1; then location="$HOME/$location" fi - if [ "$location" = "$BINDIR" ]; then + if echo "$location" | grep "$BINDIR" >/dev/null 2>&1; then echo "$DIVIDING_LINE" echo " πŸ’€ ERROR, you can't install applications in \"$BINDIR\"" echo " $BINDIR is normally used for executables, Please choose a different path and retry!" From 49c2bc20a70cdd44b84cfa22b2417cc6f6caaeed Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Tue, 27 Aug 2024 03:19:28 +0200 Subject: [PATCH 05/36] Update APP-MANAGER --- APP-MANAGER | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index 5263e4366..cc0cf95df 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -59,10 +59,9 @@ function _clean_amcachedir() { function _appman_check() { if [ -f "$APPMANCONFIG"/appman-config ]; then # Convert old config OLDAPPSDIR=$(head -1 "$APPMANCONFIG"/appman-config 2>/dev/null) - echo "$HOME/$OLDAPPSDIR" > "$APPMANCONFIG"/apps-path || exit 1 - rm -f "$APPMANCONFIG"/appman-config + echo "$HOME/$OLDAPPSDIR" > "$APPMANCONFIG"/appman-config || exit 1 fi - if [ ! -f "$APPMANCONFIG"/apps-path ]; then + if [ ! -f "$APPMANCONFIG"/appman-config ]; then echo "$DIVIDING_LINE" echo ">>> Thank you for choosing AppMan!" echo "$DIVIDING_LINE" @@ -92,7 +91,7 @@ function _appman_check() { exit 1 fi mkdir -p "$APPMANCONFIG" || exit 1 - echo "${location%/}" > "$APPMANCONFIG"/apps-path || exit 1 + echo "${location%/}" > "$APPMANCONFIG"/appman-config || exit 1 echo "$DIVIDING_LINE" echo " You are ready! Start installing your favorite apps locally!" echo " All apps will be installed in $location" @@ -102,7 +101,7 @@ function _appman_check() { } function _appman() { - APPSDIR="$(head -1 "$APPMANCONFIG"/apps-path 2>/dev/null)" + APPSDIR="$(head -1 "$APPMANCONFIG"/appman-config 2>/dev/null)" [ -n "$APPSDIR" ] && mkdir -p "$APPSDIR"/appman/modules || exit 1 mkdir -p "$BINDIR" "$DATADIR"/applications "$DATADIR"/icons || exit 1 AMCLI="appman" From 2808fa7d6c0a696bef7b29479748c6f121494969 Mon Sep 17 00:00:00 2001 From: Samuel <36420837+Samueru-sama@users.noreply.github.com> Date: Mon, 26 Aug 2024 21:43:56 -0400 Subject: [PATCH 06/36] fix conversion of old appman config APP-MANAGER --- APP-MANAGER | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/APP-MANAGER b/APP-MANAGER index edc708ce0..8fe8c9756 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -57,7 +57,8 @@ function _clean_amcachedir() { # "APPMAN" CORE VARIABLES AND FUNCTIONS function _appman_check() { - if [ -f "$APPMANCONFIG"/appman-config ]; then # Convert old config + if [ -f "$APPMANCONFIG"/appman-config ] && ! grep "^/" "$APPMANCONFIG"/appman-config; then + echo " Converting old config" OLDAPPSDIR=$(head -1 "$APPMANCONFIG"/appman-config 2>/dev/null) echo "$HOME/$OLDAPPSDIR" > "$APPMANCONFIG"/appman-config || exit 1 fi From 27a88c9c1fb9ac775d3e01e8168b095aca97b8c3 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Tue, 27 Aug 2024 03:48:19 +0200 Subject: [PATCH 07/36] Update APP-MANAGER --- APP-MANAGER | 1 - 1 file changed, 1 deletion(-) diff --git a/APP-MANAGER b/APP-MANAGER index 8fe8c9756..f88e5d2ce 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -58,7 +58,6 @@ function _clean_amcachedir() { # "APPMAN" CORE VARIABLES AND FUNCTIONS function _appman_check() { if [ -f "$APPMANCONFIG"/appman-config ] && ! grep "^/" "$APPMANCONFIG"/appman-config; then - echo " Converting old config" OLDAPPSDIR=$(head -1 "$APPMANCONFIG"/appman-config 2>/dev/null) echo "$HOME/$OLDAPPSDIR" > "$APPMANCONFIG"/appman-config || exit 1 fi From d5d3d4341d068e5efa5c38f2bfd1a34aa11a9f8f Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Tue, 27 Aug 2024 03:49:19 +0200 Subject: [PATCH 08/36] Update APP-MANAGER --- APP-MANAGER | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/APP-MANAGER b/APP-MANAGER index f88e5d2ce..fe051d627 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -57,7 +57,7 @@ function _clean_amcachedir() { # "APPMAN" CORE VARIABLES AND FUNCTIONS function _appman_check() { - if [ -f "$APPMANCONFIG"/appman-config ] && ! grep "^/" "$APPMANCONFIG"/appman-config; then + if [ -f "$APPMANCONFIG"/appman-config ] && ! grep -q "^/" "$APPMANCONFIG"/appman-config; then OLDAPPSDIR=$(head -1 "$APPMANCONFIG"/appman-config 2>/dev/null) echo "$HOME/$OLDAPPSDIR" > "$APPMANCONFIG"/appman-config || exit 1 fi From ae08828b3668c63e1b732768393b51a3926afa64 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Tue, 27 Aug 2024 20:07:22 +0200 Subject: [PATCH 09/36] Test "realpath" in AMCLIPATH for AppMan mode --- APP-MANAGER | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index 958fa8511..a768ca649 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -495,8 +495,8 @@ if [ "$AMCLI" = am ]; then if test -f "$APPMANCONFIG"/appman-mode; then [ ! -f "$APPMANCONFIG"/appman-config ] && echo -e "$APPMAN_MSG" _appman - AMCLIPATH="/opt/am/APP-MANAGER" - elif [ ! -w /opt/am ]; then + AMCLIPATH="$(realpath "$0")" + elif [ ! -w "$AMPATH" ]; then read -r -p " \"AM\" is read-only, want to use it in \"AppMan Mode\" (Y,n)? " yn if echo "$yn" | grep -i '^n' >/dev/null 2>&1; then exit 0 From b715c23216f705f92b8e66f64c38ae8c5f847fc4 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Tue, 27 Aug 2024 20:14:41 +0200 Subject: [PATCH 10/36] Undo an half of the previous commit --- APP-MANAGER | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/APP-MANAGER b/APP-MANAGER index a768ca649..ddc06aafb 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -495,7 +495,7 @@ if [ "$AMCLI" = am ]; then if test -f "$APPMANCONFIG"/appman-mode; then [ ! -f "$APPMANCONFIG"/appman-config ] && echo -e "$APPMAN_MSG" _appman - AMCLIPATH="$(realpath "$0")" + AMCLIPATH="/opt/am/APP-MANAGER" elif [ ! -w "$AMPATH" ]; then read -r -p " \"AM\" is read-only, want to use it in \"AppMan Mode\" (Y,n)? " yn if echo "$yn" | grep -i '^n' >/dev/null 2>&1; then From 484b72ffa83bc80ef573124752fcaea7a649f836 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Tue, 27 Aug 2024 20:17:06 +0200 Subject: [PATCH 11/36] Update APP-MANAGER --- APP-MANAGER | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/APP-MANAGER b/APP-MANAGER index ddc06aafb..a768ca649 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -495,7 +495,7 @@ if [ "$AMCLI" = am ]; then if test -f "$APPMANCONFIG"/appman-mode; then [ ! -f "$APPMANCONFIG"/appman-config ] && echo -e "$APPMAN_MSG" _appman - AMCLIPATH="/opt/am/APP-MANAGER" + AMCLIPATH="$(realpath "$0")" elif [ ! -w "$AMPATH" ]; then read -r -p " \"AM\" is read-only, want to use it in \"AppMan Mode\" (Y,n)? " yn if echo "$yn" | grep -i '^n' >/dev/null 2>&1; then From ea3f3fa248d74a481f78471c8378c700d9c201e1 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Tue, 27 Aug 2024 20:25:02 +0200 Subject: [PATCH 12/36] Include _appman_check into the _appman function --- APP-MANAGER | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/APP-MANAGER b/APP-MANAGER index a768ca649..86e4596e2 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -101,6 +101,7 @@ function _appman_check() { } function _appman() { + _appman_check APPSDIR="$(head -1 "$APPMANCONFIG"/appman-config 2>/dev/null)" [ -n "$APPSDIR" ] && mkdir -p "$APPSDIR"/appman/modules || exit 1 mkdir -p "$BINDIR" "$DATADIR"/applications "$DATADIR"/icons || exit 1 @@ -144,7 +145,6 @@ if [ "$(realpath "$0")" = "/opt/am/APP-MANAGER" ]; then elif [ "$(realpath "$0")" = "/usr/bin/am" ]; then _am else - _appman_check _appman fi From 772bf64484edd2b1f9229e8d22a2843f660f6d64 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Tue, 27 Aug 2024 20:42:48 +0200 Subject: [PATCH 13/36] Test _appman_check at the end of "sync" --- APP-MANAGER | 1 + 1 file changed, 1 insertion(+) diff --git a/APP-MANAGER b/APP-MANAGER index 86e4596e2..4c4ec1aac 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -966,6 +966,7 @@ function _use_sync() { _sync_modules _sync_amcli fi + _appman_check } # UPDATE From c9ea4e6eee0e92d8e8d83094765cee97f4d81ae0 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Tue, 27 Aug 2024 21:17:07 +0200 Subject: [PATCH 14/36] Test temporary function to update cfg file in AppMan --- APP-MANAGER | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/APP-MANAGER b/APP-MANAGER index 4c4ec1aac..1f377b888 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -56,7 +56,14 @@ function _clean_amcachedir() { ################################################################################ # "APPMAN" CORE VARIABLES AND FUNCTIONS +function _appman_transitional_cfg() { + if -f "$APPMANCONFIG"/appman-config && ! grep -q "^/" "$APPMANCONFIG"/appman-config; then + echo "$HOME/$(<"$APPMANCONFIG"/appman-config)" > "$APPMANCONFIG"/appman-config-new + fi +} + function _appman_check() { + [ -f "$APPMANCONFIG"/appman-config-new ] && mv "$APPMANCONFIG"/appman-config-new "$APPMANCONFIG"/appman-config if [ -f "$APPMANCONFIG"/appman-config ] && ! grep -q "^/" "$APPMANCONFIG"/appman-config; then OLDAPPSDIR=$(head -1 "$APPMANCONFIG"/appman-config 2>/dev/null) echo "$HOME/$OLDAPPSDIR" > "$APPMANCONFIG"/appman-config || exit 1 @@ -967,6 +974,7 @@ function _use_sync() { _sync_amcli fi _appman_check + _appman_transitional_cfg } # UPDATE From ebf9e3f4fa3a7b4f703f3e8ad1d97ee84ac2dcab Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Tue, 27 Aug 2024 21:33:16 +0200 Subject: [PATCH 15/36] Test 2 --- APP-MANAGER | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index 1f377b888..c0d3aa91e 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -58,12 +58,16 @@ function _clean_amcachedir() { # "APPMAN" CORE VARIABLES AND FUNCTIONS function _appman_transitional_cfg() { if -f "$APPMANCONFIG"/appman-config && ! grep -q "^/" "$APPMANCONFIG"/appman-config; then - echo "$HOME/$(<"$APPMANCONFIG"/appman-config)" > "$APPMANCONFIG"/appman-config-new + sort "$APPMANCONFIG"/appman-config > "$APPMANCONFIG"/appman-config-backup fi } function _appman_check() { + if test -f "$APPMANCONFIG"/appman-config-backup; then + rm -f "$APPMANCONFIG"/appman-config && mv "$APPMANCONFIG"/appman-config-backup "$APPMANCONFIG"/appman-config || exit 1 + fi [ -f "$APPMANCONFIG"/appman-config-new ] && mv "$APPMANCONFIG"/appman-config-new "$APPMANCONFIG"/appman-config + if [ -f "$APPMANCONFIG"/appman-config ] && ! grep -q "^/" "$APPMANCONFIG"/appman-config; then OLDAPPSDIR=$(head -1 "$APPMANCONFIG"/appman-config 2>/dev/null) echo "$HOME/$OLDAPPSDIR" > "$APPMANCONFIG"/appman-config || exit 1 @@ -973,8 +977,8 @@ function _use_sync() { _sync_modules _sync_amcli fi - _appman_check _appman_transitional_cfg + _appman_check } # UPDATE From 765f40de7b807c7993f46573ede9d8e8841433ea Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Tue, 27 Aug 2024 21:44:08 +0200 Subject: [PATCH 16/36] Undo testing changes --- APP-MANAGER | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index c0d3aa91e..86e4596e2 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -56,18 +56,7 @@ function _clean_amcachedir() { ################################################################################ # "APPMAN" CORE VARIABLES AND FUNCTIONS -function _appman_transitional_cfg() { - if -f "$APPMANCONFIG"/appman-config && ! grep -q "^/" "$APPMANCONFIG"/appman-config; then - sort "$APPMANCONFIG"/appman-config > "$APPMANCONFIG"/appman-config-backup - fi -} - function _appman_check() { - if test -f "$APPMANCONFIG"/appman-config-backup; then - rm -f "$APPMANCONFIG"/appman-config && mv "$APPMANCONFIG"/appman-config-backup "$APPMANCONFIG"/appman-config || exit 1 - fi - [ -f "$APPMANCONFIG"/appman-config-new ] && mv "$APPMANCONFIG"/appman-config-new "$APPMANCONFIG"/appman-config - if [ -f "$APPMANCONFIG"/appman-config ] && ! grep -q "^/" "$APPMANCONFIG"/appman-config; then OLDAPPSDIR=$(head -1 "$APPMANCONFIG"/appman-config 2>/dev/null) echo "$HOME/$OLDAPPSDIR" > "$APPMANCONFIG"/appman-config || exit 1 @@ -977,8 +966,6 @@ function _use_sync() { _sync_modules _sync_amcli fi - _appman_transitional_cfg - _appman_check } # UPDATE From 476fa20a135bb546e752b06c560a7c03c60bb1bc Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Tue, 27 Aug 2024 22:05:52 +0200 Subject: [PATCH 17/36] AppMan, try to keep old configuration file --- APP-MANAGER | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index 86e4596e2..ade1b2b98 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -57,10 +57,6 @@ function _clean_amcachedir() { # "APPMAN" CORE VARIABLES AND FUNCTIONS function _appman_check() { - if [ -f "$APPMANCONFIG"/appman-config ] && ! grep -q "^/" "$APPMANCONFIG"/appman-config; then - OLDAPPSDIR=$(head -1 "$APPMANCONFIG"/appman-config 2>/dev/null) - echo "$HOME/$OLDAPPSDIR" > "$APPMANCONFIG"/appman-config || exit 1 - fi if [ ! -f "$APPMANCONFIG"/appman-config ]; then echo "$DIVIDING_LINE" echo ">>> Thank you for choosing AppMan!" @@ -102,7 +98,11 @@ function _appman_check() { function _appman() { _appman_check - APPSDIR="$(head -1 "$APPMANCONFIG"/appman-config 2>/dev/null)" + if ! grep -q "^/" "$APPMANCONFIG"/appman-config; then + APPSDIR="$HOME/$(head -1 "$APPMANCONFIG"/appman-config 2>/dev/null)" + else + APPSDIR="$(head -1 "$APPMANCONFIG"/appman-config 2>/dev/null)" + fi [ -n "$APPSDIR" ] && mkdir -p "$APPSDIR"/appman/modules || exit 1 mkdir -p "$BINDIR" "$DATADIR"/applications "$DATADIR"/icons || exit 1 AMCLI="appman" From 1f20838f1a7a226fb0d007cca108cc178c9079fb Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Tue, 27 Aug 2024 23:23:57 +0200 Subject: [PATCH 18/36] Use "realpath" to clean unneeded modules --- APP-MANAGER | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/APP-MANAGER b/APP-MANAGER index ade1b2b98..a5f9a62e6 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -566,7 +566,7 @@ function _clean_launchers() { function _clean_old_modules() { if [ "$AMCLI" = am ]; then - MODULES=$(sort /opt/am/APP-MANAGER | tr '"' '\n' | grep "[a-z]\.am$" | uniq) + MODULES=$(sort "$(realpath "$0")" | tr '"' '\n' | grep "[a-z]\.am$" | uniq) else MODULES=$(sort "$AMCLIPATH" 2>/dev/null | tr '"' '\n' | grep "[a-z]\.am$" | uniq) fi From a65e7f42e8f48d380cedbff5a701bb2247fec000 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Tue, 27 Aug 2024 23:30:12 +0200 Subject: [PATCH 19/36] Test "sync" AM --- APP-MANAGER | 5 ----- 1 file changed, 5 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index a5f9a62e6..90a0bfb64 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -929,11 +929,6 @@ function _sync_amcli() { echo "$DIVIDING_LINE" _completion_lists CURRENT_AM_VERSION="$AMVERSION" - if [ "$AMCLIPATH" = /opt/am/appman ]; then - rm -f /opt/am/appman - AMCLIPATH="/opt/am/APP-MANAGER" - CURRENT_AM_VERSION=$("$AMCLIPATH" -v) - fi echo -ne "\n β—† SYNCHRONIZING \"$AMCLIUPPER\" VERSION \"$CURRENT_AM_VERSION\"...\r" && sleep 0.25 _clean_amcachedir 1>/dev/null cd "$AMCACHEDIR" || return From 88c2ea4ad94c300355fffa947fe4f46ad5bd31a6 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Wed, 28 Aug 2024 01:33:51 +0200 Subject: [PATCH 20/36] Simplify "AMCLI" download --- APP-MANAGER | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index 90a0bfb64..7675b26c4 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -934,12 +934,10 @@ function _sync_amcli() { cd "$AMCACHEDIR" || return if [ "$AMCLI" = am ]; then curl -Ls "$AMREPO"/APP-MANAGER > ./APP-MANAGER && chmod a+x ./APP-MANAGER - cd .. - echo y | mv "$AMCACHEDIR"/APP-MANAGER /opt/am/APP-MANAGER + echo y | mv ./APP-MANAGER /opt/am/APP-MANAGER else curl -Ls "$AMREPO"/APP-MANAGER > ./appman && chmod a+x ./"$AMCLI" - cd .. - echo y | mv "$AMCACHEDIR"/"$AMCLI" "$AMCLIPATH" 2>/dev/null + echo y | mv ./"$AMCLI" "$AMCLIPATH" 2>/dev/null fi NEW_AM_VERSION=$("$AMCLIPATH" -v) if [ ! "$CURRENT_AM_VERSION" = "$NEW_AM_VERSION" ]; then From 210db2f73e7f44d0a44939c057b899ed0d39a3af Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Wed, 28 Aug 2024 01:39:38 +0200 Subject: [PATCH 21/36] Replace "realpath" with APP-MANAGER, while updating "AM" --- APP-MANAGER | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/APP-MANAGER b/APP-MANAGER index 7675b26c4..f325b67b8 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -934,7 +934,7 @@ function _sync_amcli() { cd "$AMCACHEDIR" || return if [ "$AMCLI" = am ]; then curl -Ls "$AMREPO"/APP-MANAGER > ./APP-MANAGER && chmod a+x ./APP-MANAGER - echo y | mv ./APP-MANAGER /opt/am/APP-MANAGER + echo y | mv ./APP-MANAGER "$(realpath "$0")" else curl -Ls "$AMREPO"/APP-MANAGER > ./appman && chmod a+x ./"$AMCLI" echo y | mv ./"$AMCLI" "$AMCLIPATH" 2>/dev/null From 17b296feb8b8dc4befa80d471cc0267322d58a96 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Wed, 28 Aug 2024 02:28:49 +0200 Subject: [PATCH 22/36] Introducing variables for modules --- APP-MANAGER | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index f325b67b8..52c56acad 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -103,7 +103,7 @@ function _appman() { else APPSDIR="$(head -1 "$APPMANCONFIG"/appman-config 2>/dev/null)" fi - [ -n "$APPSDIR" ] && mkdir -p "$APPSDIR"/appman/modules || exit 1 + [ -n "$APPSDIR" ] && mkdir -p "$APPSDIR"/appman || exit 1 mkdir -p "$BINDIR" "$DATADIR"/applications "$DATADIR"/icons || exit 1 AMCLI="appman" AMCLIPATH="$DIR/$AMCLI" @@ -136,7 +136,6 @@ function _am() { APPSPATH="/opt" AMPATH="$APPSPATH/$AMCLI" _create_cache_dir - mkdir -p "$AMPATH"/modules } # DETERMINE WHEN TO USE "AM" OR "APPMAN" @@ -154,6 +153,11 @@ fi AMCLIUPPER=$(echo "$AMCLI" | tr '[:lower:]' '[:upper:]') +# Define modules path and source +MODULES_PATH="$AMPATH/modules" +MODULES_SOURCE="$AMREPO/modules" +mkdir -p "$MODULES_PATH" || exit 1 + # Create new data directory and move important files there AMDATADIR="$DATADIR/AM" mkdir -p "$AMDATADIR" @@ -570,7 +574,8 @@ function _clean_old_modules() { else MODULES=$(sort "$AMCLIPATH" 2>/dev/null | tr '"' '\n' | grep "[a-z]\.am$" | uniq) fi - for m in "$APPSPATH"/"$AMCLI"/modules/*; do + [ -z "$MODULES_PATH" ] && exit 1 + for m in "$MODULES_PATH"/*; do if [[ "${MODULES}" != *"$(basename -- "$m")"* ]];then rm -f "$m" 2>/dev/null echo " βœ” Removed obsolete module named \"$(basename -- "$m")\"" @@ -907,19 +912,19 @@ function _sync_modules() { echo -e "$DIVIDING_LINE\n Check for updates in modules..." MODULES=$(curl -Ls "$AMREPO/APP-MANAGER" | tr '"' '\n' | grep "[a-z]\.am$") for module_name in $MODULES; do - cd "$AMPATH"/modules || return + cd "$MODULES_PATH" || return if ! test -f ./"$module_name"; then echo " β—† Downloading $module_name (not previously installed)..." - curl -Os "$AMREPO/modules/$module_name" 2>/dev/null + curl -Os "$MODULES_SOURCE/$module_name" 2>/dev/null chmod a+x ./"$MODULENAME" fi CURRENT=$(cat ./"$module_name" 2>/dev/null) - SOURCE=$(curl -Ls "$AMREPO/modules/$module_name") + SOURCE=$(curl -Ls "$MODULES_SOURCE/$module_name") if [ "$CURRENT" = "$SOURCE" ]; then echo -ne "\r" 2>/dev/null else echo " β—† Updating $module_name..." - curl -Ls "$AMREPO/modules/$module_name" > ./"$module_name" 2>/dev/null + curl -Ls "$MODULES_SOURCE/$module_name" > ./"$module_name" 2>/dev/null fi done _clean_old_modules @@ -1059,16 +1064,16 @@ function _use_update() { # HANDLE ALL THE EXTERNAL MODULES function _use_module() { # Test if module exists - if [ ! -f "$AMPATH/modules/$MODULE" ]; then + if [ ! -f "$MODULES_PATH/$MODULE" ]; then _online_check - if ! wget -q "$AMREPO/modules/$MODULE" -O "$AMPATH/modules/$MODULE"; then + if ! wget -q "$MODULES_SOURCE/$MODULE" -O "$MODULES_PATH/$MODULE"; then echo " Module not found, run \"$AMCLI -s\" to update \"$AMCLIUPPER\"" exit 1 fi - chmod a+x "$AMPATH/modules/$MODULE" + chmod a+x "$MODULES_PATH/$MODULE" fi # Source module - source "$AMPATH/modules/$MODULE" "$@" + source "$MODULES_PATH/$MODULE" "$@" } [ -z "$1" ] && echo " USAGE: $AMCLI [OPTION]" && echo " $AMCLI [OPTION] [ARGUMENT]" && From 0b9b45fd428f9c0e9cfd3242a2acd1c43e670e8a Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Wed, 28 Aug 2024 02:34:37 +0200 Subject: [PATCH 23/36] "" --- APP-MANAGER | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index 52c56acad..ddc35506a 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -68,7 +68,7 @@ function _appman_check() { echo " NOTE: If no input is given then \"~/Applications\" will be used as default" echo "" echo " if you wish to later change the location, first remove all the programs" - echo " and then edit the "$APPMANCONFIG"/appman-config file." + echo " and then edit the \"$APPMANCONFIG\"/appman-config file." echo "$DIVIDING_LINE" read -r -ep " Write the path or just press enter to use default: " location location="$(echo "$location" | sed 's/[ \t]/-/g; s|^\./||' 2>/dev/null)" @@ -960,7 +960,7 @@ function _use_sync() { _online_check _betatester_message_on _sync_installation_scripts - if [ "$(realpath $0)" != "/usr/bin/am" ]; then + if [ "$(realpath "$0")" != "/usr/bin/am" ]; then _sync_modules _sync_amcli fi From 6a963c213c632d599c2c2bdfb3fd75e5e05c16a1 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Wed, 28 Aug 2024 03:30:46 +0200 Subject: [PATCH 24/36] Fix modules updating in AppMan mode --- APP-MANAGER | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index ddc35506a..0b9caf073 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -5,6 +5,7 @@ AMVERSION="8" # Determine main repository and branch AMREPO="https://raw.githubusercontent.com/ivan-hc/AM/main" AMBRANCH=$(basename "$AMREPO") +MODULES_SOURCE="$AMREPO/modules" # Determine catalogue in use export AMCATALOGUEMARKDOWNS="https://portable-linux-apps.github.io/apps" @@ -119,6 +120,8 @@ function _appman() { echo " ⚠️ WARNING: \"$BINDIR\" is not in PATH, apps may not run." echo "$DIVIDING_LINE" fi + MODULES_PATH="$AMPATH/modules" + mkdir -p "$MODULES_PATH" || exit 1 } # "AM" CORE VARIABLES @@ -136,6 +139,8 @@ function _am() { APPSPATH="/opt" AMPATH="$APPSPATH/$AMCLI" _create_cache_dir + MODULES_PATH="$AMPATH/modules" + mkdir -p "$MODULES_PATH" || exit 1 } # DETERMINE WHEN TO USE "AM" OR "APPMAN" @@ -153,11 +158,6 @@ fi AMCLIUPPER=$(echo "$AMCLI" | tr '[:lower:]' '[:upper:]') -# Define modules path and source -MODULES_PATH="$AMPATH/modules" -MODULES_SOURCE="$AMREPO/modules" -mkdir -p "$MODULES_PATH" || exit 1 - # Create new data directory and move important files there AMDATADIR="$DATADIR/AM" mkdir -p "$AMDATADIR" From ea13223d38d057d2d931ea0e36e5bf6c614ed7bd Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Wed, 28 Aug 2024 20:46:33 +0200 Subject: [PATCH 25/36] Add support for distro packagers --- APP-MANAGER | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/APP-MANAGER b/APP-MANAGER index 0b9caf073..5b075e600 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -140,14 +140,16 @@ function _am() { AMPATH="$APPSPATH/$AMCLI" _create_cache_dir MODULES_PATH="$AMPATH/modules" - mkdir -p "$MODULES_PATH" || exit 1 } # DETERMINE WHEN TO USE "AM" OR "APPMAN" if [ "$(realpath "$0")" = "/opt/am/APP-MANAGER" ]; then _am + mkdir -p "$MODULES_PATH" || exit 1 elif [ "$(realpath "$0")" = "/usr/bin/am" ]; then _am + AMPATH="/usr/lib/am" + MODULES_PATH="$AMPATH/modules" else _appman fi From 7443f366d68e10e1f3ac456b6672ac4de85329a0 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Wed, 28 Aug 2024 22:45:49 +0200 Subject: [PATCH 26/36] Unify apps update behaviour --- APP-MANAGER | 70 ++++++++++++++++++++++++++--------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index 5b075e600..0ff89164d 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -969,7 +969,7 @@ function _use_sync() { } # UPDATE -function _list_updatable_apps() { +function _update_list_updatable_apps() { _check_version cd "$APPSPATH" && ARGS=$(find . -name 'AM-updater' -printf " %h\n" 2>/dev/null | sort -u | xargs -n 1 basename 2>/dev/null) @@ -979,29 +979,10 @@ function _list_updatable_apps() { done } -function _update_all_apps() { - for f in "$APPSPATH"/*/; do - cd "$f" 2>/dev/null && - if test -f ./AM-updater; then - appname=$(printf '%s\n' "${PWD##*/}") - APPNAME=$(echo "$appname" | tr '[:lower:]' '[:upper:]') - if [ -w ./AM-updater ]; then - start=$(date +%s) && - sh -x ./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 - else - echo "" >/dev/null 2>&1 - fi - done - wait - echo "$DIVIDING_LINE" +function _update_determine_apps_version_changes() { if test -f "$AMCACHEDIR"/updatable-args-list; then mv "$AMCACHEDIR"/updatable-args-list "$AMCACHEDIR"/updatable-args-list-old - _list_updatable_apps + _update_list_updatable_apps OLDVER="$AMCACHEDIR/updatable-args-list-old" NEWVER="$AMCACHEDIR/updatable-args-list" if cmp --silent -- "$NEWVER" "$OLDVER"; then @@ -1014,6 +995,31 @@ function _update_all_apps() { else echo ' No apps to update here!' fi +} + +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" } @@ -1023,7 +1029,7 @@ function _use_update() { case $2 in ''|'--apps') _clean_amcachedir - _list_updatable_apps + _update_list_updatable_apps echo -e "$DIVIDING_LINE\n \"$AMCLIUPPER\" CAN MANAGE UPDATES FOR THE FOLLOWING PROGRAMS:\n" [ -f "$AMCACHEDIR/updatable-args-list" ] && cat "$AMCACHEDIR/updatable-args-list" || echo " None" echo -e "\n All self-updatable programs are excluded" @@ -1037,24 +1043,18 @@ function _use_update() { *) ARGS="$(echo "$@" | cut -f2- -d ' ')" for arg in $ARGS; do - arg_upper=$(echo "$arg" | tr '[:lower:]' '[:upper:]') + APPNAME=$(echo "$arg" | tr '[:lower:]' '[:upper:]') if test -f "$APPSPATH"/"$arg"/AM-updater; then - if [ -w "$APPSPATH"/"$arg"/AM-updater ]; then - start=$(date +%s) - "$APPSPATH"/"$arg"/AM-updater >/dev/null 2>&1 | echo -ne " UPDATING $arg_upper\r" - end=$(date +%s) - echo " β—† $arg_upper is updated, $((end - start)) seconds elapsed!" - _clean_amcachedir - _list_updatable_apps - else - echo " - $arg_upper is read-only, cannot update it!" - fi + 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 \"$arg_upper\"$arg_autoupdatable" + echo " βœ– Cannot manage updates for \"$APPNAME\"$arg_autoupdatable" fi done + wait + exit ;; esac } From 27c00530c745e2eeb2efe4dfb6037a6b0287d3ae Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Wed, 28 Aug 2024 23:01:17 +0200 Subject: [PATCH 27/36] Update README.md --- README.md | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index af8dba296..60a56b6b4 100644 --- a/README.md +++ b/README.md @@ -122,18 +122,10 @@ All options cannot be executed with "`sudo`"/"`doas`". /usr/local/bin/$PROGRAM /usr/local/share/applications/$PROGRAM-AM.desktop ``` -NOTE, all installation scripts used before June 28, 2024 show launchers in /usr/share/applications with suffix "AM-" instead of the "AM.desktop" extension, like this: - -``` -/usr/share/applications/AM-$PROGRAM.desktop -``` -From 8 July 2024 this configuration is no longer available. Reinstall the application to get the new configuration. - -The change to the default location for .desktop files from /usr/share/applications to /usr/local/share/applications was made to bring "AM" in line with GNU/Linux standards for installing system-wide third-party applications, see [here](https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch04s09.html). ------------------------------------------------------------------------ -- "**AppMan**" is more flexible, since it asks you where to install the apps in your $HOME directory. For example, suppose you want install everything in "Applicazioni" (the italian of "applications"), this is the structure of what an installation scripts installs with "AppMan" instead: +- "**AppMan**" is more flexible, since it asks you where to install the apps. For example, suppose you want install everything in "Applicazioni" (the italian of "applications") and in your $HOME directory, this is the structure of what an installation scripts installs with "AppMan" instead: ``` ~/Applicazioni/$PROGRAM/ ~/Applicazioni/$PROGRAM/$PROGRAM @@ -143,15 +135,10 @@ The change to the default location for .desktop files from /usr/share/applicatio ~/.local/bin/$PROGRAM ~/.local/share/applications/$PROGRAM-AM.desktop ``` -NOTE, all installation scripts used before June 28, 2024 show the launchers with suffix "AM-" instead of the "AM.desktop" extension, like this: -``` -~/.local/share/applications/AM-$PROGRAM.desktop -``` -From 8 July 2024 this configuration is no longer available. Reinstall the application to get the new configuration. The configuration file for AppMan is in `~/.config/appman` and contains the path you indicated at first startup. Changing its contents will result in changing the paths for each subsequent operation carried out with "AppMan", the apps and modules stored in the old path will not be manageable. -At first startup you can indicate any directory or subdirectory you want, as long as it is in your $HOME. +At first startup you can indicate any directory or subdirectory you want. ------------------------------------------------------------------------ @@ -362,7 +349,7 @@ wget https://raw.githubusercontent.com/ivan-hc/AM/main/APP-MANAGER -O appman && ### Structure of the "AppMan" installation Unlike "AM" which needs to be placed in specific locations, "AppMan" is portable. The modules and directories will be placed in the directory you chose: - the script "appman" is wherever you want -- the directory "$HOME/path/to/your/custom/directory/modules" (containing the .am modules for the non-core options) +- the directory "/path/to/your/custom/directory/modules" (containing the .am modules for the non-core options) - the configuration file "$HOME/.config/appman/appman-config" (the only fixed directory) all processes will been executed in $HOME/.cache/appman, while application lists, keywords to use in bash/zsh completion and other files (for third party repos, betatesting, etcetera...) will be saved and updated in $HOME/.local/share/AM to be shared with "AM", if installed. From f7dc6f80c0e040b4476c01d805b1704da857af33 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Thu, 29 Aug 2024 03:25:19 +0200 Subject: [PATCH 28/36] Removed useless function... "$AMPATH" is already created for "modules", and AM may not exist without it, in "normal mode", same for AppMan --- APP-MANAGER | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index 0ff89164d..be7e37f81 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -210,13 +210,7 @@ function _am_dependences_check() { fi } -function _am_security_check() { - _am_dependences_check - # Check and create the $AMPATH directory if it does not exist - [ ! -d "$AMPATH" ] && $SUDOCMD mkdir -p "$AMPATH" -} - -_am_security_check +_am_dependences_check # Function to check online connections (uses github.com by default, as the database and CLI itself are stored/hosted there) function _online_check() { From 3835a5041f107316e054485256db50c85b3ff7c0 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Thu, 29 Aug 2024 03:46:20 +0200 Subject: [PATCH 29/36] Fix support for /usr/bin/am: mission complete! --- APP-MANAGER | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index be7e37f81..5c2f5d32c 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -148,8 +148,8 @@ if [ "$(realpath "$0")" = "/opt/am/APP-MANAGER" ]; then mkdir -p "$MODULES_PATH" || exit 1 elif [ "$(realpath "$0")" = "/usr/bin/am" ]; then _am - AMPATH="/usr/lib/am" - MODULES_PATH="$AMPATH/modules" + AMPATH="$AMCACHEDIR" + MODULES_PATH="/usr/lib/am/modules" else _appman fi From 3c206e514ac06dd7650c3d70386ef0885c5c2793 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Thu, 29 Aug 2024 06:54:27 +0200 Subject: [PATCH 30/36] Update APP-MANAGER --- APP-MANAGER | 1 + 1 file changed, 1 insertion(+) diff --git a/APP-MANAGER b/APP-MANAGER index 5c2f5d32c..b8ff7899f 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -960,6 +960,7 @@ function _use_sync() { _sync_modules _sync_amcli fi + echo "$DIVIDING_LINE" } # UPDATE From 36cf958fdef690b31accfcf2ae92393d4b3e634c Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Thu, 29 Aug 2024 07:02:27 +0200 Subject: [PATCH 31/36] =?UTF-8?q?=E2=9C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- APP-MANAGER | 6 +++--- modules/install.am | 22 +++++++++++----------- modules/management.am | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index b8ff7899f..67d66207e 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -79,12 +79,12 @@ function _appman_check() { fi if echo "$location" | grep "$BINDIR" >/dev/null 2>&1; then echo "$DIVIDING_LINE" - echo " πŸ’€ ERROR, you can't install applications in \"$BINDIR\"" + echo " βœ– ERROR, you can't install applications in \"$BINDIR\"" echo " $BINDIR is normally used for executables, Please choose a different path and retry!" echo "$DIVIDING_LINE" exit 1 elif ! mkdir -p "$location" 2>/dev/null || [ ! -w "$location" ]; then - echo " πŸ’€ ERROR: You don't have write access to $location or it is invalid" + echo " βœ– ERROR: You don't have write access to $location or it is invalid" exit 1 fi mkdir -p "$APPMANCONFIG" || exit 1 @@ -199,7 +199,7 @@ function _am_dependences_check() { # Exit if any essential command is missing if [ -n "$missing_deps" ]; then echo "$DIVIDING_LINE" - printf " ${RED}πŸ’€ ERROR! MISSING ESSENTIAL COMMANDS\033[0m: %s\n\n Install the above and try again! \n" "${missing_deps[*]}" + printf " ${RED}βœ– ERROR! MISSING ESSENTIAL COMMANDS\033[0m: %s\n\n Install the above and try again! \n" "${missing_deps[*]}" echo -e "$DIVIDING_LINE\n ${Green}List of the $AMCLIUPPER $AMVERSION core dependences\033[0m:\n" echo "$AMDEPENDENCES" | tr ' ' ',' | sed 's/,/, /g' | sed 's/^/ /g' echo -e "\n$DIVIDING_LINE" diff --git a/modules/install.am b/modules/install.am index 7c93fac17..840828117 100644 --- a/modules/install.am +++ b/modules/install.am @@ -28,7 +28,7 @@ _convert_to_appman_compatible_script() { printf " Converting $arg to an AppMan-compatible script.\r" && sleep 0.25 && printf " \r" else - echo ' πŸ’€ ERROR: "--convert" requires a configuration file in ~/.config/appman' + echo ' βœ– ERROR: "--convert" requires a configuration file in ~/.config/appman' fi } @@ -42,7 +42,7 @@ _download() { curl --no-clobber -Os "$AMREPO/testing/$ARCH/$arg" > ./"$arg" || return 1 echo " ⚠️ \"$arg\" downloaded from \"testing\", the unstable branch, BE AWARE!" else - echo " πŸ’€ ERROR: \"$arg\" is NOT a valid argument" + echo " βœ– ERROR: \"$arg\" is NOT a valid argument" fi } @@ -126,10 +126,10 @@ _ending_the_installation() { LASTDIR=$(ls -td "$APPSPATH"/* | head -1 | sed 's:.*/::') if [ -f "${LASTDIRPATH}"/remove ]; then if test -d "${LASTDIRPATH}"/tmp; then - echo " πŸ’€ ERROR DURING INSTALLATION, REMOVED $APPNAME!" + echo " βœ– ERROR DURING INSTALLATION, REMOVED $APPNAME!" $AMCLIPATH -R "$LASTDIR" 1>/dev/null elif test -f "$APPSPATH/$LASTDIR/version" && [ -z "$(cat "$APPSPATH/$LASTDIR/version")" ]; then - echo " πŸ’€ ERROR DURING INSTALLATION, REMOVED $APPNAME!" + echo " βœ– ERROR DURING INSTALLATION, REMOVED $APPNAME!" $AMCLIPATH -R "$LASTDIR" 1> /dev/null else APPSIZE=$(du -sm "${LASTDIRPATH}" | awk '{print $1}' ) @@ -151,7 +151,7 @@ _dependency_check_utils() { for name in $app_deps; do if grep "^$name" ./"$arg" 1>/dev/null && ! command -v "$name" >/dev/null 2>&1; then [ "$name" = "ar" ] && name="binutils" - echo " πŸ’€ ERROR: cannot install \"$arg\" without \"$name\"" + echo " βœ– ERROR: cannot install \"$arg\" without \"$name\"" return 1 fi done @@ -186,7 +186,7 @@ _install_arg() { if grep -q 'ffwa-' ./"$arg"; then ffbrowser=$(find ${PATH//:/ } -maxdepth 1 -name "firefox*" | sort | head -1) if [ -z "$ffbrowser" ]; then - echo " πŸ’€ ERROR: you cannot install \"$arg\" without installing \"firefox\""; return 0 + echo " βœ– ERROR: you cannot install \"$arg\" without installing \"firefox\""; return 0 else sed -i 's#firefox --class#'"$(echo "$ffbrowser" | xargs -L 1 basename)"' --class#g' ./"$arg" fi @@ -197,19 +197,19 @@ _install_arg() { if curl -Ls "$appimage_bulder_script" | grep "^$name" 1>/dev/null; then if ! command -v "$name" >/dev/null 2>&1; then [ "$name" = "ar" ] && name="binutils" - echo " πŸ’€ ERROR: cannot install \"$arg\" without \"$name\"" + echo " βœ– ERROR: cannot install \"$arg\" without \"$name\"" return 0 fi fi done if curl -Ls "$appimage_bulder_script" | grep -ie "appimagetool\|pkg2appimage" 1>/dev/null; then if ! command -v convert >/dev/null 2>&1; then - echo " πŸ’€ ERROR: cannot create \"$arg\" without \"convert\" (from \"imagemagick\")" + echo " βœ– ERROR: cannot create \"$arg\" without \"convert\" (from \"imagemagick\")" return 0 fi fi else - echo " πŸ’€ ERROR: cannot create \"$arg\", the builder does not exists" + echo " βœ– ERROR: cannot create \"$arg\", the builder does not exists" return 0 fi fi @@ -342,12 +342,12 @@ case "$1" in if test -f "$arg" 2> /dev/null; then _install_local_script else - echo " πŸ’€ ERROR: the file \"$arg\" does NOT exist" + echo " βœ– ERROR: the file \"$arg\" does NOT exist" fi elif curl --output /dev/null --silent --head --fail "$APPSDB"/"$arg" 1>/dev/null; then _install_normally else - echo " πŸ’€ ERROR: \"$arg\" does NOT exist in the database, see \"$AMCLI -l\"" + echo " βœ– ERROR: \"$arg\" does NOT exist in the database, see \"$AMCLI -l\"" fi fi echo "____________________________________________________________________________" diff --git a/modules/management.am b/modules/management.am index 7fece24a1..6d817b2a5 100644 --- a/modules/management.am +++ b/modules/management.am @@ -254,7 +254,7 @@ function _nolibfuse() { printf " ...trying to convert in new generation AppImage\r" PATH="$PATH:$PWD" ./appimagetool -n ./squashfs-root >/dev/null 2>&1 if [ ! -f ./*.AppImage ]; then - echo " πŸ’€Error when trying to convert $target. Operation Aborted." + echo " βœ– Error when trying to convert $target. Operation Aborted." rm -R -f ./appimagetool ./squashfs-root ./desktop-file-validate return 1 fi From 87ce5b15d1457d636703c32c9ed03249c69b6ee1 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Thu, 29 Aug 2024 07:21:44 +0200 Subject: [PATCH 32/36] Add files via upload --- modules/install.am | 22 +++++++++++----------- modules/management.am | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/install.am b/modules/install.am index 840828117..7c93fac17 100644 --- a/modules/install.am +++ b/modules/install.am @@ -28,7 +28,7 @@ _convert_to_appman_compatible_script() { printf " Converting $arg to an AppMan-compatible script.\r" && sleep 0.25 && printf " \r" else - echo ' βœ– ERROR: "--convert" requires a configuration file in ~/.config/appman' + echo ' πŸ’€ ERROR: "--convert" requires a configuration file in ~/.config/appman' fi } @@ -42,7 +42,7 @@ _download() { curl --no-clobber -Os "$AMREPO/testing/$ARCH/$arg" > ./"$arg" || return 1 echo " ⚠️ \"$arg\" downloaded from \"testing\", the unstable branch, BE AWARE!" else - echo " βœ– ERROR: \"$arg\" is NOT a valid argument" + echo " πŸ’€ ERROR: \"$arg\" is NOT a valid argument" fi } @@ -126,10 +126,10 @@ _ending_the_installation() { LASTDIR=$(ls -td "$APPSPATH"/* | head -1 | sed 's:.*/::') if [ -f "${LASTDIRPATH}"/remove ]; then if test -d "${LASTDIRPATH}"/tmp; then - echo " βœ– ERROR DURING INSTALLATION, REMOVED $APPNAME!" + echo " πŸ’€ ERROR DURING INSTALLATION, REMOVED $APPNAME!" $AMCLIPATH -R "$LASTDIR" 1>/dev/null elif test -f "$APPSPATH/$LASTDIR/version" && [ -z "$(cat "$APPSPATH/$LASTDIR/version")" ]; then - echo " βœ– ERROR DURING INSTALLATION, REMOVED $APPNAME!" + echo " πŸ’€ ERROR DURING INSTALLATION, REMOVED $APPNAME!" $AMCLIPATH -R "$LASTDIR" 1> /dev/null else APPSIZE=$(du -sm "${LASTDIRPATH}" | awk '{print $1}' ) @@ -151,7 +151,7 @@ _dependency_check_utils() { for name in $app_deps; do if grep "^$name" ./"$arg" 1>/dev/null && ! command -v "$name" >/dev/null 2>&1; then [ "$name" = "ar" ] && name="binutils" - echo " βœ– ERROR: cannot install \"$arg\" without \"$name\"" + echo " πŸ’€ ERROR: cannot install \"$arg\" without \"$name\"" return 1 fi done @@ -186,7 +186,7 @@ _install_arg() { if grep -q 'ffwa-' ./"$arg"; then ffbrowser=$(find ${PATH//:/ } -maxdepth 1 -name "firefox*" | sort | head -1) if [ -z "$ffbrowser" ]; then - echo " βœ– ERROR: you cannot install \"$arg\" without installing \"firefox\""; return 0 + echo " πŸ’€ ERROR: you cannot install \"$arg\" without installing \"firefox\""; return 0 else sed -i 's#firefox --class#'"$(echo "$ffbrowser" | xargs -L 1 basename)"' --class#g' ./"$arg" fi @@ -197,19 +197,19 @@ _install_arg() { if curl -Ls "$appimage_bulder_script" | grep "^$name" 1>/dev/null; then if ! command -v "$name" >/dev/null 2>&1; then [ "$name" = "ar" ] && name="binutils" - echo " βœ– ERROR: cannot install \"$arg\" without \"$name\"" + echo " πŸ’€ ERROR: cannot install \"$arg\" without \"$name\"" return 0 fi fi done if curl -Ls "$appimage_bulder_script" | grep -ie "appimagetool\|pkg2appimage" 1>/dev/null; then if ! command -v convert >/dev/null 2>&1; then - echo " βœ– ERROR: cannot create \"$arg\" without \"convert\" (from \"imagemagick\")" + echo " πŸ’€ ERROR: cannot create \"$arg\" without \"convert\" (from \"imagemagick\")" return 0 fi fi else - echo " βœ– ERROR: cannot create \"$arg\", the builder does not exists" + echo " πŸ’€ ERROR: cannot create \"$arg\", the builder does not exists" return 0 fi fi @@ -342,12 +342,12 @@ case "$1" in if test -f "$arg" 2> /dev/null; then _install_local_script else - echo " βœ– ERROR: the file \"$arg\" does NOT exist" + echo " πŸ’€ ERROR: the file \"$arg\" does NOT exist" fi elif curl --output /dev/null --silent --head --fail "$APPSDB"/"$arg" 1>/dev/null; then _install_normally else - echo " βœ– ERROR: \"$arg\" does NOT exist in the database, see \"$AMCLI -l\"" + echo " πŸ’€ ERROR: \"$arg\" does NOT exist in the database, see \"$AMCLI -l\"" fi fi echo "____________________________________________________________________________" diff --git a/modules/management.am b/modules/management.am index 6d817b2a5..7fece24a1 100644 --- a/modules/management.am +++ b/modules/management.am @@ -254,7 +254,7 @@ function _nolibfuse() { printf " ...trying to convert in new generation AppImage\r" PATH="$PATH:$PWD" ./appimagetool -n ./squashfs-root >/dev/null 2>&1 if [ ! -f ./*.AppImage ]; then - echo " βœ– Error when trying to convert $target. Operation Aborted." + echo " πŸ’€Error when trying to convert $target. Operation Aborted." rm -R -f ./appimagetool ./squashfs-root ./desktop-file-validate return 1 fi From 46030bd4192b390886b42658b25ac4244aaa017e Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Thu, 29 Aug 2024 07:24:50 +0200 Subject: [PATCH 33/36] Update APP-MANAGER --- APP-MANAGER | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index 67d66207e..b8ff7899f 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -79,12 +79,12 @@ function _appman_check() { fi if echo "$location" | grep "$BINDIR" >/dev/null 2>&1; then echo "$DIVIDING_LINE" - echo " βœ– ERROR, you can't install applications in \"$BINDIR\"" + echo " πŸ’€ ERROR, you can't install applications in \"$BINDIR\"" echo " $BINDIR is normally used for executables, Please choose a different path and retry!" echo "$DIVIDING_LINE" exit 1 elif ! mkdir -p "$location" 2>/dev/null || [ ! -w "$location" ]; then - echo " βœ– ERROR: You don't have write access to $location or it is invalid" + echo " πŸ’€ ERROR: You don't have write access to $location or it is invalid" exit 1 fi mkdir -p "$APPMANCONFIG" || exit 1 @@ -199,7 +199,7 @@ function _am_dependences_check() { # Exit if any essential command is missing if [ -n "$missing_deps" ]; then echo "$DIVIDING_LINE" - printf " ${RED}βœ– ERROR! MISSING ESSENTIAL COMMANDS\033[0m: %s\n\n Install the above and try again! \n" "${missing_deps[*]}" + printf " ${RED}πŸ’€ ERROR! MISSING ESSENTIAL COMMANDS\033[0m: %s\n\n Install the above and try again! \n" "${missing_deps[*]}" echo -e "$DIVIDING_LINE\n ${Green}List of the $AMCLIUPPER $AMVERSION core dependences\033[0m:\n" echo "$AMDEPENDENCES" | tr ' ' ',' | sed 's/,/, /g' | sed 's/^/ /g' echo -e "\n$DIVIDING_LINE" From b42a1aea1d3187c04151442c856b9de5f3333842 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Thu, 29 Aug 2024 07:25:16 +0200 Subject: [PATCH 34/36] Update APP-MANAGER --- APP-MANAGER | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/APP-MANAGER b/APP-MANAGER index b8ff7899f..b614f208f 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -1,6 +1,6 @@ #!/usr/bin/env bash -AMVERSION="8" +AMVERSION="8.1" # Determine main repository and branch AMREPO="https://raw.githubusercontent.com/ivan-hc/AM/main" From f86e11280465cba61cf4e70ae124fccf9cf9567f Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Thu, 29 Aug 2024 10:13:23 +0200 Subject: [PATCH 35/36] Add new option "-ia", for AppImages only... ...same as "-i"/"install", but to run only installation scripts for AppImages --- APP-MANAGER | 19 ++++++++++++++----- modules/install.am | 30 +++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/APP-MANAGER b/APP-MANAGER index b614f208f..cae1404f7 100755 --- a/APP-MANAGER +++ b/APP-MANAGER @@ -287,10 +287,10 @@ _am_newrepo_check "$@" # COMPLETION LIST available_options="about add apikey backup clean config disable downgrade download enable extra files \ - home info install launcher list lock neodb newrepo nolibfuse off on overwrite purge query \ - remove sandbox select sync template test unlock update --appimages --apps --byname --config \ - --convert --debug --devmode-disable --devmode-enable --force-latest --home --launcher --less \ - --pkg --rollback --disable-sandbox --sandbox --system --user" + home info install install-appimage launcher list lock neodb newrepo nolibfuse off on overwrite \ + purge query remove sandbox select sync template test unlock update --appimages --apps --byname \ + --config --convert --debug --devmode-disable --devmode-enable --force-latest --home --launcher \ + --less --pkg --rollback --disable-sandbox --sandbox --system --user" function _completion_lists() { # Remove existing lists and download new ones @@ -724,6 +724,14 @@ Description: Install one or more programs or libraries from the list. With the \ \"--debug\" option you can see log messages to debug the script. For more \ details on \"--force-latest\", see the dedicated option, below. +${Gold}install-appimage, -ia\033[0m + + ${LightBlue}$AMCLI -ia {PROGRAM} + ${LightBlue}$AMCLI -ia --debug {PROGRAM} + ${LightBlue}$AMCLI -ia --force-latest {PROGRAM}\033[0m + +Description: Same as \"install\" (see above) but for AppImages only. + ${Gold}lock\033[0m ${LightBlue}$AMCLI lock {PROGRAM}\033[0m @@ -1103,7 +1111,8 @@ case "$1" in ;; 'download'|'-d'|\ 'extra'|'-e'|\ - 'install'|'-i') + 'install'|'-i'|\ + 'install-appimage'|'-ia') MODULE="install.am" _online_check _if_appman_mode_enabled diff --git a/modules/install.am b/modules/install.am index 7c93fac17..055945901 100644 --- a/modules/install.am +++ b/modules/install.am @@ -172,7 +172,6 @@ for metapackage in $METAPACKAGES; do done } - ###################### # INSTALLATION PROCESS ###################### @@ -367,6 +366,35 @@ case "$1" in fi ;; + '-ia'|'install-appimage') + if [ "$2" = "--debug" ]; then + echo "--debug " > "$AMCACHEDIR"/install-args + ARGS="$(echo "$@" | cut -f3- -d ' ' | tr ' ' '\n' | grep -v -- "--")" + elif [ "$2" = "--force-latest" ]; then + echo "--force-latest " > "$AMCACHEDIR"/install-args + ARGS="$(echo "$@" | cut -f3- -d ' ' | tr ' ' '\n' | grep -v -- "--")" + else + rm -f "$AMCACHEDIR"/install-args + ARGS="$(echo "$@" | cut -f2- -d ' ' | tr ' ' '\n' | grep -v -- "--")" + fi + for arg in $ARGS; do + curl -Ls "$AMREPO/programs/$arch-appimages" > "$AMCACHEDIR/$arch-appimages" + if grep -q "^β—† $arg : " "$AMCACHEDIR/$arch-appimages"; then + echo "$arg" >> "$AMCACHEDIR"/install-args + else + arg="$arg-appimage" + if ! grep -q "^β—† $arg : " "$AMCACHEDIR/$arch-appimages"; then + echo " βœ– \"$(echo "$arg" | sed 's/-appimage//g')\" is not an Appimage" + else + echo "$arg" >> "$AMCACHEDIR"/install-args + fi + fi + done + APPIMAGES_ARGS=$(cat "$AMCACHEDIR"/install-args | sed 's/\n/ /g') + "$AMCLIPATH" -i "$APPIMAGES_ARGS" + exit 1 + ;; + '-e'|'extra') if [ -z "$2" ] || [ -z "$3" ]; then echo " USAGE: $AMCLI $1 user/project [ARGUMENT]" From 33be684988bba45435032ea67642e7efd1abda2d Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Thu, 29 Aug 2024 17:56:39 +0200 Subject: [PATCH 36/36] Update README.md --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 60a56b6b4..f3dfabf19 100644 --- a/README.md +++ b/README.md @@ -476,6 +476,15 @@ Description: Set a dedicated $HOME directory for one or more AppImages. Description: Install one or more programs or libraries from the list. With the "--debug" option you can see log messages to debug the script. For more details on "--force-latest", see the dedicated option, below. +### `install-appimage, -ia` + + -ia {PROGRAM} + -ia --debug {PROGRAM} + -ia --force-latest {PROGRAM} + + Description: Same as "install" (see above) but for AppImages only. + + ### `lock` lock {PROGRAM} @@ -685,6 +694,13 @@ let test again the installation of AnyDesk using the `--debug` flag: https://github.com/user-attachments/assets/9dd73186-37e2-4742-887e-4f98192bd764 +### Install, run only installation scripts for AppImages +All suboption above can be used to install AppImages only, it is enough to use the option `-ia`/`install-appimage` instead of `-i`/`install`. In this example, I'll run the script `brave-appimage` but running `brave`, that instead is the original upstream package: + +https://github.com/user-attachments/assets/b938430c-ec0b-4b90-850f-1332063d5e53 + +in the video above I first launch a "query" with the `-q` option to show you the difference between `brave` and `brave-appimage`, and then `-q --appimages` to show you only the appimages from the list. More details at "[List and query all the applications available on the database](#list-and-query-all-the-applications-available-on-the-database)". + ### Install the "latest" stable release instead of the latest "unstable" By default, many installation scripts for apps hosted on github will point to the more recent generic release instead of "latest", which is normally used to indicate that the build is "stable". This is because upstream developers do not always guarantee a certain packaging format in "latest", sometimes they may only publish packages for Windows or macOS, so pointing to "latest" would not guarantee that any package for Linux will be installed.