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

api: add remove_deprecated_app and userinput_func functions #2419

Merged
merged 2 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
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
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 text_lines=$(echo -e "$1" | wc -l)
# there is no good universal way to calculate the required height of the window
# the users theme, default text size, and window scaling all affect it
# the idea is the height should be a function of the number of lines of input text and the number of list options
local height_list=$(echo $(( text_lines * 17 + $(( ${#@} - 1 )) * 29 + 65 )))
local commonflags=(--fixed --no-escape --undecorated --center --borders=20)
if [ "${#@}" == "2" ];then
yad "${yadflags[@]}" "${commonflags[@]}" \
--image "dialog-information" \
--text="$1" \
--button="$2":0
output="$2"
elif [ "${#@}" == "3" ];then
yad "${yadflags[@]}" "${commonflags[@]}" \
--image "dialog-question" \
--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_list\
--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
1 change: 0 additions & 1 deletion apps/BlockPi/credits

This file was deleted.

5 changes: 0 additions & 5 deletions apps/BlockPi/description

This file was deleted.

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

This file was deleted.

11 changes: 0 additions & 11 deletions apps/BlockPi/install-64

This file was deleted.

3 changes: 0 additions & 3 deletions apps/BlockPi/uninstall

This file was deleted.

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

This file was deleted.

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.

4 changes: 0 additions & 4 deletions etc/categories
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ BalenaEtcher|Tools
Better Chromium|Internet/Browsers
BleachBit|System Management
BlockBench|Creative Arts
BlockPi|Programming
BlueJ Java IDE|Programming
Bongo Cam|Multimedia
Box64|Tools/Emulation
Expand Down Expand Up @@ -55,7 +54,6 @@ Ducopanel|Tools
Eagle CAD|Engineering
eDEX-UI|Terminals
Electron Fiddle|Programming
Email Checker|Internet/Communication
Epiphany|Internet/Browsers
ExaGear|Tools/Emulation
Falkon|Internet/Browsers
Expand Down Expand Up @@ -137,7 +135,6 @@ Pale Moon|Internet/Browsers
PeaZip|Tools
Persepolis Download Manager|Internet
Pi-Apps Terminal Plugin (bash)|Tools
Pi-Apps Terminal Plugin (python)|Tools
PiGro|Tools
Pika Backup|System Management
PiKISS GUI|Tools
Expand Down Expand Up @@ -181,7 +178,6 @@ Stunt Rally|hidden
Sublime Text|Programming
Synaptic|System Management
Syncthing|System Management
Sysmon|System Management
SysMonTask|System Management
System Monitoring Center|System Management
Tabby|Terminals
Expand Down
1 change: 0 additions & 1 deletion etc/category-overrides-jetson-18.04
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ AntiMicroX|hidden
Autostar|hidden
Better Chromium|hidden
BlockBench|hidden
BlockPi|hidden
Box86|hidden
Boxy SVG|hidden
Chiaki|hidden
Expand Down
1 change: 0 additions & 1 deletion etc/category-overrides-non-raspberry
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
BlockPi|hidden
Chiaki|hidden
CommanderPi|hidden
Downgrade Chromium|hidden
Expand Down
41 changes: 24 additions & 17 deletions etc/runonce-entries
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,30 @@ runonce <<"EOF"
refresh_all_pkgapp_status
EOF

# remove deprecated apps (only when running in a visible terminal)
Botspot marked this conversation as resolved.
Show resolved Hide resolved
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"
remove_deprecated_app "BlockPi"
remove_deprecated_app "TBOPlayer"
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,23 +95,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"
fi

#rename 'Turbo Scratch' app to 'Turbowarp'
rm -rf "${DIRECTORY}/apps/Turbo Scratch"
mv -f "${DIRECTORY}/data/status/Turbo Scratch" "${DIRECTORY}/data/status/Turbowarp" 2>/dev/null
Expand Down