mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2024-11-29 00:55:42 +00:00
Add universal function wrapper
Upgrade cooker update flow Upgrade update_rd_conf, no more patch file since they are all bash vars
This commit is contained in:
parent
67e7271614
commit
6619191a15
17
functions.sh
17
functions.sh
|
@ -99,7 +99,7 @@ move() {
|
||||||
zenity --icon-name=net.retrodeck.retrodeck --progress --no-cancel --pulsate --auto-close \
|
zenity --icon-name=net.retrodeck.retrodeck --progress --no-cancel --pulsate --auto-close \
|
||||||
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
||||||
--title "RetroDECK Configurator Utility - Move in Progress" \
|
--title "RetroDECK Configurator Utility - Move in Progress" \
|
||||||
--text="Moving directory $1 to new location of $2, please wait."
|
--text="Moving directory $(basename "$1") to new location of $2, please wait."
|
||||||
else
|
else
|
||||||
zenity --icon-name=net.retrodeck.retrodeck --error --no-wrap \
|
zenity --icon-name=net.retrodeck.retrodeck --error --no-wrap \
|
||||||
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
||||||
|
@ -779,14 +779,11 @@ update_rd_conf() {
|
||||||
# This function will import a default retrodeck.cfg file and update it with any current settings. This will allow us to expand the file over time while retaining current user settings.
|
# This function will import a default retrodeck.cfg file and update it with any current settings. This will allow us to expand the file over time while retaining current user settings.
|
||||||
# USAGE: update_rd_conf
|
# USAGE: update_rd_conf
|
||||||
|
|
||||||
|
conf_read # Read current settings into memory
|
||||||
mv -f $rd_conf $rd_conf_backup # Backup config file before update
|
mv -f $rd_conf $rd_conf_backup # Backup config file before update
|
||||||
|
cp $rd_defaults $rd_conf # Copy defaults file into place
|
||||||
generate_single_patch $rd_defaults $rd_conf_backup $rd_update_patch retrodeck
|
conf_write # Write old values into new default file
|
||||||
sed -i '/change^^version/d' $rd_update_patch # Remove version line from temporary patch file, so old value isn't kept
|
conf_read # Read all settings into memory
|
||||||
deploy_single_patch $rd_defaults $rd_update_patch $rd_conf
|
|
||||||
set_setting_value $rd_conf "version" "$hard_version" retrodeck # Set version of currently running RetroDECK to updated retrodeck.cfg
|
|
||||||
rm -f $rd_update_patch # Cleanup temporary patch file
|
|
||||||
conf_read
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve_preset_conflicts() {
|
resolve_preset_conflicts() {
|
||||||
|
@ -1172,6 +1169,8 @@ update_splashscreens() {
|
||||||
}
|
}
|
||||||
|
|
||||||
deploy_helper_files() {
|
deploy_helper_files() {
|
||||||
|
# This script will distribute helper documentation files throughout the filesystem according to the $helper_files_list
|
||||||
|
# USAGE: deploy_helper_files
|
||||||
|
|
||||||
while IFS='^' read -r file dest
|
while IFS='^' read -r file dest
|
||||||
do
|
do
|
||||||
|
@ -1966,7 +1965,7 @@ finit() {
|
||||||
mkdir -p "/var/config/emulationstation/.emulationstation/gamelists/doom"
|
mkdir -p "/var/config/emulationstation/.emulationstation/gamelists/doom"
|
||||||
cp "/app/retrodeck/rd_prepacks/doom/gamelist.xml" "/var/config/emulationstation/.emulationstation/gamelists/doom/gamelist.xml"
|
cp "/app/retrodeck/rd_prepacks/doom/gamelist.xml" "/var/config/emulationstation/.emulationstation/gamelists/doom/gamelist.xml"
|
||||||
mkdir -p "$media_folder/doom"
|
mkdir -p "$media_folder/doom"
|
||||||
unzip -q "/app/retrodeck/rd_prepacks/doom/doom.zip" -d "$media_folder/doom/"
|
unzip -oq "/app/retrodeck/rd_prepacks/doom/doom.zip" -d "$media_folder/doom/"
|
||||||
|
|
||||||
tools_init
|
tools_init
|
||||||
prepare_emulator "reset" "all"
|
prepare_emulator "reset" "all"
|
||||||
|
|
11
global.sh
11
global.sh
|
@ -116,6 +116,11 @@ then
|
||||||
set_setting_value $rd_conf "version" "$version" retrodeck # Set current version for new installs
|
set_setting_value $rd_conf "version" "$version" retrodeck # Set current version for new installs
|
||||||
set_setting_value $rd_conf "sdcard" "$default_sd" retrodeck "paths" # Set SD card location if default path has changed
|
set_setting_value $rd_conf "sdcard" "$default_sd" retrodeck "paths" # Set SD card location if default path has changed
|
||||||
|
|
||||||
|
if grep -qF "cooker" <<< $hard_version; then # If newly-installed version is a "cooker" build
|
||||||
|
set_setting_value $rd_conf "update_repo" "RetroDECK-cooker" retrodeck "options"
|
||||||
|
set_setting_value $rd_conf "update_check" "true" retrodeck "options"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Setting config file permissions"
|
echo "Setting config file permissions"
|
||||||
chmod +rw $rd_conf
|
chmod +rw $rd_conf
|
||||||
echo "RetroDECK config file initialized. Contents:"
|
echo "RetroDECK config file initialized. Contents:"
|
||||||
|
@ -127,6 +132,12 @@ then
|
||||||
else
|
else
|
||||||
echo "Found RetroDECK config file in $rd_conf"
|
echo "Found RetroDECK config file in $rd_conf"
|
||||||
echo "Loading it"
|
echo "Loading it"
|
||||||
|
|
||||||
|
if grep -qF "cooker" <<< $hard_version; then # If newly-installed version is a "cooker" build
|
||||||
|
set_setting_value $rd_conf "update_repo" "RetroDECK-cooker" retrodeck "options"
|
||||||
|
set_setting_value $rd_conf "update_check" "true" retrodeck "options"
|
||||||
|
fi
|
||||||
|
|
||||||
conf_read
|
conf_read
|
||||||
|
|
||||||
# Verify rdhome is where it is supposed to be.
|
# Verify rdhome is where it is supposed to be.
|
||||||
|
|
|
@ -1220,6 +1220,8 @@ modules:
|
||||||
- cp tools/configurator.sh /app/tools/configurator.sh
|
- cp tools/configurator.sh /app/tools/configurator.sh
|
||||||
- chmod +x /app/tools/configurator.sh
|
- chmod +x /app/tools/configurator.sh
|
||||||
- cp es-configs/tools-gamelist.xml /app/retrodeck/tools-gamelist.xml
|
- cp es-configs/tools-gamelist.xml /app/retrodeck/tools-gamelist.xml
|
||||||
|
- cp tools/retrodeck_function_wrapper.sh /app/tools/retrodeck_function_wrapper.sh
|
||||||
|
- chmod +x /app/tools/retrodeck_function_wrapper.sh
|
||||||
|
|
||||||
# Function libraries
|
# Function libraries
|
||||||
- mkdir -p /app/libexec
|
- mkdir -p /app/libexec
|
||||||
|
|
|
@ -86,15 +86,11 @@ post_update() {
|
||||||
|
|
||||||
dir_prep "$rdhome/gamelists" "/var/config/emulationstation/.emulationstation/gamelists"
|
dir_prep "$rdhome/gamelists" "/var/config/emulationstation/.emulationstation/gamelists"
|
||||||
|
|
||||||
sed -i '/version=.*/G' $rd_conf
|
|
||||||
sed -i '3i [paths]' $rd_conf
|
|
||||||
sed -i '/^power_user_warning=.*/i [options]' $rd_conf
|
|
||||||
|
|
||||||
cp /app/retrodeck/extras/doom1.wad "$roms_folder/doom/doom1.wad" # No -f in case the user already has it
|
cp /app/retrodeck/extras/doom1.wad "$roms_folder/doom/doom1.wad" # No -f in case the user already has it
|
||||||
mkdir -p "/var/config/emulationstation/.emulationstation/gamelists/doom"
|
mkdir -p "/var/config/emulationstation/.emulationstation/gamelists/doom"
|
||||||
cp "/app/retrodeck/rd_prepacks/doom/gamelist.xml" "/var/config/emulationstation/.emulationstation/gamelists/doom/gamelist.xml"
|
cp -f "/app/retrodeck/rd_prepacks/doom/gamelist.xml" "/var/config/emulationstation/.emulationstation/gamelists/doom/gamelist.xml"
|
||||||
mkdir -p "$media_folder/doom"
|
mkdir -p "$media_folder/doom"
|
||||||
unzip -q "/app/retrodeck/rd_prepacks/doom/doom.zip" -d "$media_folder/doom/"
|
unzip -oq "/app/retrodeck/rd_prepacks/doom/doom.zip" -d "$media_folder/doom/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# The following commands are run every time.
|
# The following commands are run every time.
|
||||||
|
|
|
@ -104,15 +104,12 @@ then
|
||||||
if [ "$hard_version" != "$version" ];
|
if [ "$hard_version" != "$version" ];
|
||||||
then
|
then
|
||||||
echo "Config file's version is $version but the actual version is $hard_version"
|
echo "Config file's version is $version but the actual version is $hard_version"
|
||||||
|
|
||||||
if grep -qF "cooker" <<< $hard_version; then # If newly-installed version is a "cooker" build
|
if grep -qF "cooker" <<< $hard_version; then # If newly-installed version is a "cooker" build
|
||||||
set_setting_value $rd_conf "update_repo" "RetroDECK-cooker" retrodeck "options"
|
cooker_base_version=$(echo $hard_version | cut -d'-' -f2)
|
||||||
set_setting_value $rd_conf "update_check" "true" retrodeck "options"
|
|
||||||
cooker_base_version=$(echo $hard_version | cut -d'-' -f2 | sed 's/\([0-9]\.[0-9][a-z]\).*/\1/')
|
|
||||||
choice=$(zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap --ok-label="Upgrade" --extra-button="Don't Upgrade" --extra-button="Fresh Install" \
|
choice=$(zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap --ok-label="Upgrade" --extra-button="Don't Upgrade" --extra-button="Fresh Install" \
|
||||||
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
||||||
--title "RetroDECK Cooker Upgrade" \
|
--title "RetroDECK Cooker Upgrade" \
|
||||||
--text="You appear to be upgrading to a \"cooker\" build of RetroDECK.\n\nWould you like to perform the standard post-update process, skip the post-update process or remove ALL existing RetroDECK data to start from a fresh install?")
|
--text="You appear to be upgrading to a \"cooker\" build of RetroDECK.\n\nWould you like to perform the standard post-update process, skip the post-update process or remove ALL existing RetroDECK data to start from a fresh install?\n\nPerforming the normal post-update process multiple times may lead to unexpected results.")
|
||||||
rc=$? # Capture return code, as "Yes" button has no text value
|
rc=$? # Capture return code, as "Yes" button has no text value
|
||||||
if [[ $rc == "1" ]]; then # If any button other than "Yes" was clicked
|
if [[ $rc == "1" ]]; then # If any button other than "Yes" was clicked
|
||||||
if [[ $choice == "Don't Upgrade" ]]; then # If user wants to bypass the post_update.sh process this time.
|
if [[ $choice == "Don't Upgrade" ]]; then # If user wants to bypass the post_update.sh process this time.
|
||||||
|
@ -122,6 +119,7 @@ then
|
||||||
echo "Removing RetroDECK data and starting fresh"
|
echo "Removing RetroDECK data and starting fresh"
|
||||||
rm -rf /var
|
rm -rf /var
|
||||||
rm -rf "$HOME/retrodeck"
|
rm -rf "$HOME/retrodeck"
|
||||||
|
source /app/libexec/global.sh
|
||||||
finit
|
finit
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
|
25
tools/retrodeck_function_wrapper.sh
Normal file
25
tools/retrodeck_function_wrapper.sh
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This wrapper will run a single RetroDECK function with any number of arguments
|
||||||
|
# USAGE: /bin/bash retrodeck_function_wrapper.sh <function_name> <arg1> <arg2> ...
|
||||||
|
|
||||||
|
source /app/libexec/global.sh
|
||||||
|
|
||||||
|
# Check if a function was specified
|
||||||
|
if [[ $# -lt 1 ]]; then
|
||||||
|
echo "Usage: $0 function_name [args...]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get the function name and remove it from the list of arguments
|
||||||
|
function_name="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
# Check if the function exists
|
||||||
|
if ! declare -f "$function_name" >/dev/null 2>&1; then
|
||||||
|
echo "Function '$function_name' not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Call the function with any remaining arguments
|
||||||
|
"$function_name" "$@"
|
Loading…
Reference in a new issue