Skip to content

Commit

Permalink
api: add remove_deprecated_app and userinput_func functions
Browse files Browse the repository at this point in the history
also remove deprecated apps:
Email Checker
Pi-Apps Terminal Plugin (python)
Sysmon
  • Loading branch information
theofficialgman committed Aug 4, 2023
1 parent a9a3669 commit e8d855a
Show file tree
Hide file tree
Showing 22 changed files with 97 additions and 156 deletions.
75 changes: 75 additions & 0 deletions api
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,33 @@ pipx_uninstall() {
sudo PIPX_HOME=/usr/local/pipx PIPX_BIN_DIR=/usr/local/bin pipx uninstall "$@" || error "Failed to uninstall $* with pipx"
}

remove_deprecated_app() { # prompts a user to uninstall a deprecated pi-apps application and then removes the application folder if it exists
local app="$1" # on app name
local removal_arch="$2" # 32 or 64 to only remove one architecture if specified
[ -z "$app" ] && error "remove_deprecated_app(): requires an pi-apps app name"
local app_status="$(app_status "${app}")"
if [ ! -z "$removal_arch" ] && [ "$arch" == "$removal_arch" ] && [ -d "${DIRECTORY}/apps/$app" ] && [ "$app_status" == "installed" ]; then
local text="Pi-Apps has deprecated $app for ${removal_arch}-bit OSs which you currently have installed.
Would you like to uninstall it now or leave it installed? You will NOT be able to uninstall $app with pi-apps later."
userinput_func "$text" "Uninstall now" "Leave installed"
elif [ ! -z "$removal_arch" ] && [ "$arch" != "$removal_arch" ]; then
rm -f "${DIRECTORY}/apps/$app/install-$removal_arch"
return 0
elif [ -z "$removal_arch" ] && [ -d "${DIRECTORY}/apps/$app" ] && [ "$app_status" == "installed" ]; then
local text="Pi-Apps has deprecated $app which you currently have installed.
Would you like to uninstall it now or leave it installed? You will NOT be able to uninstall $app with pi-apps later."
userinput_func "$text" "Uninstall now" "Leave installed"
else
rm -rf "${DIRECTORY}/apps/$app"
return 0
fi
if [ "$output" == "Uninstall now" ]; then
"${DIRECTORY}/manage" uninstall "$app"
fi
rm -rf "${DIRECTORY}/apps/$app"
return 0
}

terminal_manage() { # wrapper for the original terminal_manage function to terminal_mange_multi
action="$1"
app="$2" #one app name
Expand Down Expand Up @@ -1377,6 +1404,54 @@ ${category}"
fi
}

userinput_func() { # userinput function to display yad/cli prompts to the user
[ -z "$1" ] && error "userinput_func(): requires a description"
[ -z "$2" ] && error "userinput_func(): requires at least one output selection option"
local height=$(($(echo "$1" | grep -o '\\n' | wc -l) + 8))
local height_gui=$(echo $(( height * 15 + ${#@} * 20 + 100 )))
local height_gui_buttons=$(echo $(( height * 15 )))
local commonflags=(--fixed --no-escape --undecorated --center --borders=20)
if [ "${#@}" == "2" ];then
echo -e "$1" | yad "${yadflags[@]}" "${commonflags[@]}" \
--image "dialog-information" \
--text-info --fontname="@font@ 11" --wrap --show-uri \
--width=800 --height=$height_gui \
--button="$2":0
output="$2"
elif [ "${#@}" == "3" ];then
yad "${yadflags[@]}" "${commonflags[@]}" \
--image "dialog-question" \
--height=$height_gui_buttons \
--text="$1" \
--button="$2":0 \
--button="$3":1
if [ $? -ne 0 ]; then
output="$3"
else
output="$2"
fi
else
unset uniq_selection
for string in "${@:2}"; do
local uniq_selection+=(FALSE "$string")
done
local uniq_selection[0]=TRUE
output=$(yad "${yadflags[@]}" "${commonflags[@]}" \
--height=$height_gui\
--text "$1" \
--list \
--no-headers \
--radiolist \
--center \
--column "" \
--column "Selection" \
--print-column=2 \
--separator='' \
--button="OK":0 \
"${uniq_selection[@]}")
fi
}

generate_app_icons() { #This converts the given $1 image into icon-24.png and icon-64.png files for the $2 app
icon="$1"
app="$2"
Expand Down
4 changes: 0 additions & 4 deletions apps/Email Checker/description

This file was deleted.

Binary file removed apps/Email Checker/icon-24.png
Binary file not shown.
Binary file removed apps/Email Checker/icon-64.png
Binary file not shown.
50 changes: 0 additions & 50 deletions apps/Email Checker/install

This file was deleted.

10 changes: 0 additions & 10 deletions apps/Email Checker/uninstall

This file was deleted.

1 change: 0 additions & 1 deletion apps/Email Checker/website

This file was deleted.

1 change: 0 additions & 1 deletion apps/Pi-Apps Terminal Plugin (python)/credits

This file was deleted.

17 changes: 0 additions & 17 deletions apps/Pi-Apps Terminal Plugin (python)/description

This file was deleted.

Binary file removed apps/Pi-Apps Terminal Plugin (python)/icon-24.png
Binary file not shown.
Binary file removed apps/Pi-Apps Terminal Plugin (python)/icon-64.png
Binary file not shown.
11 changes: 0 additions & 11 deletions apps/Pi-Apps Terminal Plugin (python)/install-32

This file was deleted.

8 changes: 0 additions & 8 deletions apps/Pi-Apps Terminal Plugin (python)/uninstall

This file was deleted.

1 change: 0 additions & 1 deletion apps/Pi-Apps Terminal Plugin (python)/website

This file was deleted.

2 changes: 0 additions & 2 deletions apps/Sysmon/credits

This file was deleted.

6 changes: 0 additions & 6 deletions apps/Sysmon/description

This file was deleted.

Binary file removed apps/Sysmon/icon-24.png
Binary file not shown.
Binary file removed apps/Sysmon/icon-64.png
Binary file not shown.
25 changes: 0 additions & 25 deletions apps/Sysmon/install

This file was deleted.

7 changes: 0 additions & 7 deletions apps/Sysmon/uninstall

This file was deleted.

1 change: 0 additions & 1 deletion apps/Sysmon/website

This file was deleted.

34 changes: 22 additions & 12 deletions etc/runonce-entries
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,28 @@ runonce <<"EOF"
refresh_all_pkgapp_status
EOF

# remove deprecated apps (only when running in a visible terminal)
case $(ps -o stat= -p $$) in
*+*) # Running in foreground
runonce <<"EOF"
#remove deprecated apps
remove_deprecated_app "FreeCAD (precompiled)"
remove_deprecated_app "Chromium Media Edition"
remove_deprecated_app "Cordless"
remove_deprecated_app "Retropie"
remove_deprecated_app "Raspi2png"
remove_deprecated_app "Falkon"
remove_deprecated_app "FreeCAD"
remove_deprecated_app "LinuxCNC"
remove_deprecated_app "Steam" "32"
remove_deprecated_app "Cawbird"
remove_deprecated_app "Email Checker"
remove_deprecated_app "Pi-Apps Terminal Plugin (python)"
remove_deprecated_app "Sysmon"
EOF
;;
esac

#remove old apps and migrate chromium downgrading apps to the new "Downgrade Chromium" app
runonce <<"EOF"
#rework chromium downgrading apps to one single new app: 'Downgrade Chromium'
Expand All @@ -71,18 +93,6 @@ runonce <<"EOF"
echo "installed" > "${DIRECTORY}/data/status/Downgrade Chromium"
fi
#remove deprecated apps
rm -rf "${DIRECTORY}/apps/FreeCAD (precompiled)"
rm -rf "${DIRECTORY}/apps/Chromium Media Edition"
rm -rf "${DIRECTORY}/apps/Cordless"
rm -rf "${DIRECTORY}/apps/Retropie"
rm -rf "${DIRECTORY}/apps/Raspi2png"
rm -rf "${DIRECTORY}/apps/Falkon"
rm -rf "${DIRECTORY}/apps/FreeCAD"
rm -rf "${DIRECTORY}/apps/LinuxCNC"
rm -f "${DIRECTORY}/apps/Steam/install-32"
rm -rf "${DIRECTORY}/apps/Cawbird"
#remove TBOPlayer if it's not already successfully installed
if [ "$(app_status TBOPlayer)" != 'installed' ];then
rm -rf "${DIRECTORY}/apps/TBOPlayer"
Expand Down

0 comments on commit e8d855a

Please sign in to comment.