Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update management.am: refactoring #917

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions modules/management.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
# BACKUP
function _backup() {
if [ ! -f "$APPSPATH"/"$2"/remove ]; then
printf "\n \"$2\" is not a valid argument or is not installed.\n\n"
echo " \"$2\" is not a valid argument or is not installed."
else
read -p " Do you wish to backup the current version of $2? (y/N) " yn
read -r -p " Do you wish to backup the current version of $2? (y/N) " yn
if ! echo "$yn" | grep -i '^y' >/dev/null 2>&1; then
printf "\n OPERATION ABORTED!\n\n"
else
Expand All @@ -26,11 +26,11 @@ function _backup() {
# RESTORE
function _overwrite() {
if [ ! -d "$HOME/.am-snapshots/$2" ]; then
printf "\n ERROR: No snapshot for \"$2\" found.\n\n"
echo " ERROR: No snapshot for \"$2\" found."
elif [ ! -f "$APPSPATH"/"$arg"/remove ]; then
printf "\n \"$2\" is not a valid argument or is not installed.\n\n"
echo " \"$2\" is not a valid argument or is not installed."
else
read -p " Do you wish to overwrite $2 with an older version? (y,N) " yn
read -r -p " Do you wish to overwrite $2 with an older version? (y,N) " yn
if ! echo "$yn" | grep -i '^y' >/dev/null 2>&1; then
printf "\n OPERATION ABORTED!\n\n"
else
Expand Down Expand Up @@ -187,8 +187,7 @@ function _launcher(){
# LOCK/UNLOCK
function _lock() {
if [ ! -f "$APPSPATH"/"$2"/AM-updater ]; then
printf " \"$(echo "$AMCLI" | tr '[:lower:]' '[:upper:]')\""
printf " cannot manage updates for $2, \"AM-updater\" file not found!\n"
echo " \"$AMCLIUPPER\" cannot manage updates for $2, \"AM-updater\" file not found!"
return 1
fi
read -r -p " Do you wish to keep $2 at its current version? (y/N) " yn
Expand Down Expand Up @@ -231,19 +230,18 @@ function _nolibfuse() {
elif ! echo "$string" | grep -q -- 'AppImages require FUSE to run'; then
echo " ◆ $target is already a new generation AppImage."
return 1
elif [ -f ./*.zsync ]; then
elif test -f ./*.zsync; then
echo "-----------------------------------------------------------------------"
echo " Warning! Your AppImage uses \"zsync\" to update."
echo " The .zsync file will be removed and will no longer work"
echo " your \"AM-updater\" will likely still be able to update the AppImage"
echo " by comparing the old vs new version url, but it is not guaranteed"
read -p " Do you want to proceede anyway? (N/y) " yn
read -r -p " Do you want to proceede anyway? (N/y) " yn
if ! echo "$yn" | grep -i '^y' >/dev/null 2>&1; then
return 1
fi
fi

export ARCH="$(uname -m)"
appimagetool="https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-$ARCH.AppImage"
printf " ...downloading appimagetool\r"
wget -q "$appimagetool" -O ./appimagetool || return 1
Expand All @@ -252,8 +250,8 @@ function _nolibfuse() {
printf " ...extracting the AppImage\r"
./"$2" --appimage-extract >/dev/null 2>&1 && chmod 0755 ./squashfs-root
printf " ...trying to convert in new generation AppImage\r"
PATH="$PATH:$PWD" ./appimagetool -n ./squashfs-root >/dev/null 2>&1
if [ ! -f ./*.AppImage ]; then
PATH="$PATH:$PWD" ARCH="$(uname -m)" ./appimagetool -n ./squashfs-root >/dev/null 2>&1
if ! test -f ./*.AppImage; then
echo " 💀Error when trying to convert $target. Operation Aborted."
rm -R -f ./appimagetool ./squashfs-root ./desktop-file-validate
return 1
Expand All @@ -268,7 +266,7 @@ function _nolibfuse() {
echo " so I added this command to the bottom of the \"AM-updater\" script!"
fi
echo " Contact the upstream developers to make them officially upgrade!"
read -p " Do you wish to remove the old libfuse2 AppImage? (Y/n) " yn
read -r -p " Do you wish to remove the old libfuse2 AppImage? (Y/n) " yn
if echo "$yn" | grep -i '^n' >/dev/null 2>&1; then
return 1
else
Expand All @@ -284,7 +282,7 @@ function _remove() {
echo -e " \"${RED}$arg\033[0m\" is not a valid \"APPNAME\", see \"$AMCLI -f\" for more."
return 1
fi
read -p " ◆ Do you wish to remove \"$2\"? (Y/n) " yn
read -r -p " ◆ Do you wish to remove \"$2\"? (Y/n) " yn
if echo "$yn" | grep -i '^n' >/dev/null 2>&1; then
echo -e " \"${LightBlue}$2\033[0m\" has not been removed!"
else
Expand Down