From ed9cf6f87d81a04389c405a384d67fb6570e9ac7 Mon Sep 17 00:00:00 2001 From: Samuel <36420837+Samueru-sama@users.noreply.github.com> Date: Fri, 16 Aug 2024 02:13:02 -0400 Subject: [PATCH 1/4] Remove zsync from template --- templates/AM-SAMPLE-AppImage | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/templates/AM-SAMPLE-AppImage b/templates/AM-SAMPLE-AppImage index e40c4c409..534823d55 100644 --- a/templates/AM-SAMPLE-AppImage +++ b/templates/AM-SAMPLE-AppImage @@ -14,11 +14,9 @@ chmod a+x ../remove || exit 1 # DOWNLOAD AND PREPARE THE APP, $version is also used for updates version=$(FUNCTION) wget "$version" || exit 1 -#wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. mv ./tmp/*mage ./"$APP" -mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null rm -R -f ./tmp || exit 1 echo "$version" > ./version chmod a+x ./"$APP" || exit 1 @@ -35,14 +33,13 @@ SITE="REPLACETHIS" version0=$(cat "/opt/$APP/version") version=$(FUNCTION) [ -n "$version" ] || { echo "Error getting link"; exit 1; } -if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then +if [ "$version" != "$version0" ]; then mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 - [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" - [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } + notify-send "A new version of $APP is available, please wait" + wget "$version" || exit 1 # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. - mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" - [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } + mv --backup=t ./tmp/*mage ./"$APP" chmod a+x ./"$APP" || exit 1 echo "$version" > ./version rm -R -f ./*zs-old ./*.part ./tmp ./*~ From e7ab26644a647baf990ba1f95ac6a529a28d586c Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Fri, 16 Aug 2024 15:36:13 +0200 Subject: [PATCH 2/4] Keep spaces in sync with other installation scripts --- templates/AM-SAMPLE-AppImage | 2 ++ 1 file changed, 2 insertions(+) diff --git a/templates/AM-SAMPLE-AppImage b/templates/AM-SAMPLE-AppImage index 534823d55..174c55960 100644 --- a/templates/AM-SAMPLE-AppImage +++ b/templates/AM-SAMPLE-AppImage @@ -14,9 +14,11 @@ chmod a+x ../remove || exit 1 # DOWNLOAD AND PREPARE THE APP, $version is also used for updates version=$(FUNCTION) wget "$version" || exit 1 +# Keep this space in sync with other installation scripts # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. cd .. mv ./tmp/*mage ./"$APP" +# Keep this space in sync with other installation scripts rm -R -f ./tmp || exit 1 echo "$version" > ./version chmod a+x ./"$APP" || exit 1 From 98e3013ae08c1bd4650800be2c72c6e6ab4d3224 Mon Sep 17 00:00:00 2001 From: iVAN <88724353+ivan-hc@users.noreply.github.com> Date: Sun, 18 Aug 2024 08:24:49 +0200 Subject: [PATCH 3/4] Update management.am: refactoring --- modules/management.am | 87 ++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/modules/management.am b/modules/management.am index 8c0390261..f85870891 100644 --- a/modules/management.am +++ b/modules/management.am @@ -18,9 +18,9 @@ function _remove_check_removals() { 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 "$AMCACHEDIR"/unavailable-args | sort)" + echo -e " ๐Ÿ’€ ERROR, the following programs you want to remove are NOT in $APPSPATH :\n\n$(sort "$AMCACHEDIR"/unavailable-args)" else - echo -e " ๐Ÿ’€ ERROR, the following programs you want to remove are NOT in\n $APPSPATH :\n\n$(cat "$AMCACHEDIR"/unavailable-args | sort)" + echo -e " ๐Ÿ’€ ERROR, the following programs you want to remove are NOT in\n $APPSPATH :\n\n$(sort "$AMCACHEDIR"/unavailable-args)" fi echo -e '\n INVALID "APPNAME"!' echo -e "\n-----------------------------------------------------------------------\n" @@ -34,23 +34,23 @@ function _remove_check_removals() { } function _REMOVE() { - if ls "$APPSPATH"/$arg > /dev/null 2>&1; then - $SUDOCMD "$APPSPATH"/$arg/remove && sleep 0.5 && echo ' โ—† "'"$(echo $arg | tr a-z A-Z)"'" HAS BEEN SUCCESSFULLY REMOVED!' + if ls "$APPSPATH"/"$arg" > /dev/null 2>&1; then + $SUDOCMD "$APPSPATH"/"$arg"/remove && sleep 0.5 && echo " โ—† \"$(echo "$arg" | tr '[:lower:]' '[:upper:]')\" HAS BEEN SUCCESSFULLY REMOVED!" else echo " - $arg" >> "$AMCACHEDIR"/unavailable-args fi } function _remove() { - if ls "$APPSPATH"/$arg > /dev/null 2>&1; then + if ls "$APPSPATH"/"$arg" > /dev/null 2>&1; then case $arg in *) - $SUDOCMD echo "" > /dev/null; read -p ' โ—† DO YOU WISH TO REMOVE "'"$(echo $arg | tr a-z A-Z)"'" (Y,n)?' yn + $SUDOCMD echo "" > /dev/null; read -r -p ' โ—† DO YOU WISH TO REMOVE "'"$(echo "$arg" | tr '[:lower:]' '[:upper:]')"'" (Y,n)?' yn case $yn in [Nn]* ) - echo ' - "'"$(echo $arg | tr a-z A-Z)"'" HAS NOT BEEN REMOVED!'; echo "";; + echo ' - "'"$(echo "$arg" | tr '[:lower:]' '[:upper:]')"'" HAS NOT BEEN REMOVED!'; echo "";; [Yy]*|* ) - $SUDOCMD "$APPSPATH"/$arg/remove && sleep 0.5 && echo ' โ—† "'"$(echo $arg | tr a-z A-Z)"'" HAS BEEN SUCCESSFULLY REMOVED!';; + $SUDOCMD "$APPSPATH"/"$arg"/remove && sleep 0.5 && echo " โ—† \"$(echo "$arg" | tr '[:lower:]' '[:upper:]')\" HAS BEEN SUCCESSFULLY REMOVED!";; esac esac else @@ -71,7 +71,7 @@ function _do_rollback() { elif grep -q "api.github.com" "$APPSPATH"/"$2"/AM-updater; then cd "$APPSPATH"/"$2" || return rm -f "$AMCACHEDIR/rollback-args"; - extension=$(cat ./version | tr '.' '\n' | tail -1) + extension=$(sort ./version | tr '.' '\n' | tail -1) if grep -q "^REPO=" ./AM-updater; then REPO=$(grep -i "REPO=" ./AM-updater | grep -o -P '(?<=").*(?=")') elif grep -q "^SITE=" ./AM-updater; then @@ -125,15 +125,14 @@ function _do_rollback() { function _do_lock() { while [ -n "$1" ]; do - if test -f "$APPSPATH"/$2/AM-updater; then + if test -f "$APPSPATH"/"$2"/AM-updater; then case $2 in *) - read -p " Do you wish to keep $2 at the current version (y,N)?" yn + read -r -p " Do you wish to keep $2 at the current version (y,N)?" yn case $yn in [Yy]* ) - mv "$APPSPATH"/$2/AM-updater "$APPSPATH"/$2/AM-LOCK 1>/dev/null && + mv "$APPSPATH"/"$2"/AM-updater "$APPSPATH"/"$2"/AM-LOCK 1>/dev/null && echo " $2 has been locked at current version!" - exit ;; [Nn]*|* ) echo " Operation aborted!" @@ -143,7 +142,7 @@ function _do_lock() { ;; esac else - echo -e '\n '"$(echo $AMCLI | tr a-z A-Z)"' cannot manage updates for '$2', "AM-updater" file not found!\n'; exit + echo -e "\n \"$(echo "$AMCLI" | tr '[:lower:]' '[:upper:]')\" cannot manage updates for $2, \"AM-updater\" file not found!\n" exit fi done @@ -151,25 +150,25 @@ function _do_lock() { function _do_unlock() { while [ -n "$1" ]; do - if test -f "$APPSPATH"/$2/AM-LOCK; then + if test -f "$APPSPATH"/"$2"/AM-LOCK; then case $2 in *) - read -p " Do you wish to unlock updates for $2 (Y,n)?" yn + read -r -p " Do you wish to unlock updates for $2 (Y,n)?" yn case $yn in [Nn]* ) echo " $2 is still locked at current version!" exit ;; [Yy]*|* ) - mv "$APPSPATH"/$2/AM-LOCK "$APPSPATH"/$2/AM-updater 1>/dev/null - echo ' '$2' can now receive updates!' + mv "$APPSPATH"/"$2"/AM-LOCK "$APPSPATH"/"$2"/AM-updater 1>/dev/null + echo " \"$2\" can now receive updates!" exit ;; esac ;; esac else - echo ' '$2' cannot be unlocked, "AM-LOCK" file not found!'; exit + echo " \"$2\" cannot be unlocked, \"AM-LOCK\" file not found!"; exit fi done } @@ -183,18 +182,18 @@ function _backup() { '') echo " Specify the name of a program to back up"; echo ""; exit;; *) - if test -f "$APPSPATH"/$arg/remove; then - echo ""; read -p " Do you wish to backup the current version of $arg (y,N)?" yn + if test -f "$APPSPATH"/"$arg"/remove; then + echo ""; read -r -p " Do you wish to backup the current version of $arg (y,N)?" yn case $yn in [Yy]* ) mkdir -p "$HOME/.am-snapshots/$arg" - cp -r "$APPSPATH"/$arg "$HOME/.am-snapshots/$arg/$(date +%F-%X | sed 's/://g' | sed 's/-//g')" + cp -r "$APPSPATH"/"$arg" "$HOME/.am-snapshots/$arg/$(date +%F-%X | sed 's/://g' | sed 's/-//g')" echo -e "\n SAVED in $HOME/.am-snapshots/$arg\n";; [Nn]*|* ) echo ""; echo " OPERATION ABORTED!"; echo "";; esac else - echo -e "\n '$arg' is not a valid argument or is not installed.\n" + echo -e "\n \"$arg\" is not a valid argument or is not installed.\n" fi esac } @@ -205,7 +204,7 @@ function _do_backup() { 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 + if [ "$arg" = STOP ]; then exit else _backup @@ -219,14 +218,14 @@ function _overwrite() { '') echo " Specify the name of a program to overwrite"; echo "";; *) - if test -f "$APPSPATH"/$arg/remove; then - echo ""; read -p " Do you wish to overwrite this version of $arg with an old one (y,N)?" yn + if test -f "$APPSPATH"/"$arg"/remove; then + echo ""; read -r -p " Do you wish to overwrite this version of $arg with an old one (y,N)?" yn case $yn in [Yy]* ) printf "\n Please, select a snapshot or press CTRL+C to abort:\n\n"; sleep 1; select d in $HOME/.am-snapshots/$arg/*; do test -n "$d" && break; echo ">>> Invalid Selection"; done - cp -r --backup=t $d/* "$APPSPATH"/$arg/ - rm -R -f ./tmp "$APPSPATH"/$arg/*~ + cp -r --backup=t "$d"/* "$APPSPATH"/"$arg"/ + rm -R -f ./tmp "$APPSPATH"/"$arg"/*~ echo -e "\n RESTORE COMPLETED SUCCESSFULLY!\n";; [Nn]*|* ) echo ""; echo " OPERATION ABORTED!"; echo "";; @@ -243,7 +242,7 @@ function _do_overwrite() { 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 + if [ "$arg" = STOP ]; then exit else _overwrite @@ -262,7 +261,7 @@ function _nolibfuse_if_zsync_file_exists() { echo "-----------------------------------------------------------------------" echo -e " Warning! Your AppImage uses \"zsync\" to update. The .zsync file will\n no longer work and will be removed.\n" echo -e " If your \"AM-updater\" script can compare versions, the update method\n will be changed, by downloading the new AppImage version in full,\n from the source.\n" - read -p " Do you want to proceede anyway (N,y)?" yn + read -r -p " Do you want to proceede anyway (N,y)?" yn case "$yn" in 'y'|'Y') echo "-----------------------------------------------------------------------";; 'n'|'N'|*) echo "-----------------------------------------------------------------------"; exit;; @@ -289,12 +288,12 @@ function _nolibfuse_if_appimage_has_been_converted() { rm -f ./*.zsync fi if ! grep -q 'nolibfuse' ./AM-updater; then - echo -e '\necho y | '$AMCLIPATH' nolibfuse $APP' >> ./AM-updater + echo -e "\necho y | $AMCLIPATH nolibfuse \$APP" >> ./AM-updater echo -e "\n The next update may replace this AppImage with a Type2 one\n so I added this command to the bottom of the \"AM-updater\" script!" fi fi echo -e "\n Contact the upstream developers to make them officially upgrade! \n" - read -p " Do you wish to remove the old Type2 AppImage (Y,n)?" yn + read -r -p " Do you wish to remove the old Type2 AppImage (Y,n)?" yn case $yn in [Nn]* ) exit @@ -313,12 +312,14 @@ function _do_nolibfuse() { cd "$APPSPATH" || exit 1 if test -f "./$2/$2" 2>/dev/null; then cd ./"$2" || return - if [ -z "$(strings -d "./$2" 2>/dev/null | grep -F 'if you run it with the --appimage-extract option')" ] 2>/dev/null; then - echo " โš ๏ธ Error: $(echo "${2}" | tr a-z A-Z) is NOT an AppImage." + appimage_new_message=$(strings -d "./$2" 2>/dev/null | grep -F 'if you run it with the --appimage-extract option') + appimage_old_message=$(strings -d "./$2" 2>/dev/null | grep -F 'AppImages require FUSE to run') + if [ -z "$appimage_new_message" ]; then + echo " โš ๏ธ Error: $(echo "${2}" | tr '[:lower:]' '[:upper:]') is NOT an AppImage." exit else - if [ -z "$(strings -d "./$2" 2>/dev/null | grep -F 'AppImages require FUSE to run')" ] 2>/dev/null; then - echo " โ—† $(echo "${2}" | tr a-z A-Z) is already a new generation AppImage." + if [ -z "$appimage_old_message" ]; then + echo " โ—† $(echo "${2}" | tr '[:lower:]' '[:upper:]') is already a new generation AppImage." exit else _nolibfuse_if_zsync_file_exists @@ -331,12 +332,12 @@ function _do_nolibfuse() { _remove_info_files mv ./"$2" ./"$2".old mv ./*.AppImage ./"$2" - echo " โ—† $(echo "$2" | tr a-z A-Z) has been converted to a new generation AppImage." + echo " โ—† $(echo "$2" | tr '[:lower:]' '[:upper:]') has been converted to a new generation AppImage." _nolibfuse_if_appimage_has_been_converted else metainfodir=$(find ./squashfs-root -type d -name metainfo | grep "share/metainfo" | head -1) if [ -z "$metainfodir" ]; then - echo " ๐Ÿ’€Errors while trying to export $(echo "${2}" | tr a-z A-Z) from Type2 AppImage. Aborted." + echo " ๐Ÿ’€Errors while trying to export $(echo "${2}" | tr '[:lower:]' '[:upper:]') from Type2 AppImage. Aborted." rm -R -f ./appimagetool ./squashfs-root exit else @@ -350,17 +351,17 @@ function _do_nolibfuse() { _remove_info_files mv ./"$2" ./"$2".old mv ./*.AppImage ./"$2" - echo " โ—† $(echo "$2" | tr a-z A-Z) has been converted to a new generation AppImage." + echo " โ—† $(echo "$2" | tr '[:lower:]' '[:upper:]') has been converted to a new generation AppImage." _nolibfuse_if_appimage_has_been_converted else - echo " ๐Ÿ’€Errors while trying to export $(echo "$2" | tr a-z A-Z) from Type2 AppImage. Aborted." + echo " ๐Ÿ’€Errors while trying to export $(echo "$2" | tr '[:lower:]' '[:upper:]') from Type2 AppImage. Aborted." rm -R -f ./appimagetool ./squashfs-root; exit fi fi fi fi else - echo " โš ๏ธ Error: \"$(echo "${2}" | tr a-z A-Z)\" is NOT installed." + echo " โš ๏ธ Error: \"$(echo "${2}" | tr '[:lower:]' '[:upper:]')\" is NOT installed." exit fi } @@ -386,7 +387,7 @@ case "$1" in 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 + if [ "$arg" = STOP ]; then _remove_check_removals else _REMOVE @@ -403,7 +404,7 @@ case "$1" in 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 + if [ "$arg" = STOP ]; then _remove_check_removals else _remove From e0fd7b8c11eb01a0f49d0507726c928b59c33ad9 Mon Sep 17 00:00:00 2001 From: Samuel <36420837+Samueru-sama@users.noreply.github.com> Date: Sun, 18 Aug 2024 07:34:11 -0400 Subject: [PATCH 4/4] install.am don't insert `""` on paths --- modules/install.am | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/install.am b/modules/install.am index a60b4eef0..7e3d582da 100644 --- a/modules/install.am +++ b/modules/install.am @@ -32,9 +32,9 @@ _spooky_check() { _apply_patches() { if [ "$AMCLI" = "appman" ]; then # Patches /usr/local for $HOME equivalent for AppMan - sed -i -e "s#/usr/local/bin#\"$BINDIR\"#g" \ - -e "s#/usr/local/share#\"$DATADIR\"#g" \ - -e "s#/opt/#\"$APPSPATH\"/#g" ./"$arg" + sed -i -e "s#/usr/local/bin#$BINDIR#g" \ + -e "s#/usr/local/share#$DATADIR#g" \ + -e "s#/opt/#$APPSPATH/#g" ./"$arg" else "$SUDOCMD" mkdir -p /usr/local/{share/applications,bin} fi