Move update check code from retrodeck.sh to global.sh for cleanliness

This commit is contained in:
icenine451 2025-04-04 11:24:33 -04:00
parent aaf1c77fde
commit 739248b24c
2 changed files with 67 additions and 70 deletions

View file

@ -232,10 +232,8 @@ if [[ ! -f "$rd_conf" ]]; then
chmod +rw "$rd_conf"
log i "RetroDECK config file initialized. Contents:\n\n$(cat "$rd_conf")\n"
conf_read # Load new variables into memory
#tmplog_merger # This function is tempry(?) removed
# If the config file is existing i just read the variables
else
else # If the config file is existing i just read the variables
log i "Loading RetroDECK config file in $rd_conf"
if grep -qF "cooker" <<< "$hard_version"; then # If newly-installed version is a "cooker" build
@ -248,11 +246,10 @@ else
# Verify rdhome is where it is supposed to be.
if [[ ! -d "$rdhome" ]]; then
configurator_generic_dialog "RetroDECK Setup" "The RetroDECK data folder was not found in the expected location.\nThis may happen when SteamOS is updated.\n\nPlease browse to the current location of the \"retrodeck\" folder."
configurator_generic_dialog "RetroDECK Setup" "The RetroDECK data folder was not found in the expected location.\nThis may happen when SteamOS is updated or if the folder was moved manually.\n\nPlease browse to the current location of the \"retrodeck\" folder."
new_home_path=$(directory_browse "RetroDECK folder location")
set_setting_value "$rd_conf" "rdhome" "$new_home_path" retrodeck "paths"
conf_read
#tmplog_merger # This function is tempry(?) removed
prepare_component "postmove" "retrodeck"
prepare_component "postmove" "all"
conf_write
@ -272,3 +269,68 @@ retrodeck_added_favorites="$steamsync_folder/retrodeck_added_favorites.json"
retrodeck_removed_favorites="$steamsync_folder/retrodeck_removed_favorites.json" # Temporary manifest of any games that were unfavorited in ES-DE and should be removed from Steam
export GLOBAL_SOURCED=true
# Check if an update has happened
if [ -f "$lockfile" ]; then
if [ "$hard_version" != "$version" ]; then
log d "Update triggered"
log d "Lockfile found but the version doesn't match with the config file"
log i "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
log d "Newly-installed version is a \"cooker\" build"
configurator_generic_dialog "RetroDECK Cooker Warning" "RUNNING COOKER VERSIONS OF RETRODECK CAN BE EXTREMELY DANGEROUS AND ALL OF YOUR RETRODECK DATA\n(INCLUDING BIOS FILES, BORDERS, DOWNLOADED MEDIA, GAMELISTS, MODS, ROMS, SAVES, STATES, SCREENSHOTS, TEXTURE PACKS AND THEMES)\nARE AT RISK BY CONTINUING!"
set_setting_value "$rd_conf" "update_repo" "$cooker_repository_name" retrodeck "options"
set_setting_value "$rd_conf" "update_check" "true" retrodeck "options"
set_setting_value "$rd_conf" "developer_options" "true" retrodeck "options"
set_setting_value "$rd_conf" "logging_level" "debug" retrodeck "options"
cooker_base_version=$(echo "$version" | cut -d'-' -f2)
choice=$(rd_zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap --ok-label="Upgrade" --extra-button="Don't Upgrade" --extra-button="Full Wipe and Fresh Install" \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--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 folders and data (including ROMs and saves) 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
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.
log i "Skipping upgrade process for cooker build, updating stored version in retrodeck.cfg"
set_setting_value "$rd_conf" "version" "$hard_version" retrodeck # Set version of currently running RetroDECK to updated retrodeck.cfg
elif [[ "$choice" == "Full Wipe and Fresh Install" ]]; then # Remove all RetroDECK data and start a fresh install
if [[ $(configurator_generic_question_dialog "RetroDECK Cooker Reset" "This is going to remove all of the data in all locations used by RetroDECK!\n\n(INCLUDING BIOS FILES, BORDERS, DOWNLOADED MEDIA, GAMELISTS, MODS, ROMS, SAVES, STATES, SCREENSHOTS, TEXTURE PACKS AND THEMES)\n\nAre you sure you want to contine?") == "true" ]]; then
if [[ $(configurator_generic_question_dialog "RetroDECK Cooker Reset" "Are you super sure?\n\nThere is no going back from this process, everything is gonzo.\nDust in the wind.\n\nYesterdays omelette.") == "true" ]]; then
if [[ $(configurator_generic_question_dialog "RetroDECK Cooker Reset" "But are you super DUPER sure? We REAAAALLLLLYY want to make sure you know what is happening here.\n\nThe ~/retrodeck and ~/.var/app/net.retrodeck.retrodeck folders and ALL of their contents\nare about to be PERMANENTLY removed.\n\nStill sure you want to proceed?") == "true" ]]; then
configurator_generic_dialog "RetroDECK Cooker Reset" "Ok, if you're that sure, here we go!"
if [[ $(configurator_generic_question_dialog "RetroDECK Cooker Reset" "(Are you actually being serious here? Because we are...\n\nNo backsies.)") == "true" ]]; then
log w "Removing RetroDECK data and starting fresh"
rm -rf /var
rm -rf "$HOME/retrodeck"
rm -rf "$rdhome"
source /app/libexec/global.sh
finit
fi
fi
fi
fi
fi
else
log i "Performing normal upgrade process for version $cooker_base_version"
version="$cooker_base_version" # Temporarily assign cooker base version to $version so update script can read it properly.
post_update
fi
else # If newly-installed version is a normal build.
if grep -qF "cooker" <<< "$version"; then # If previously installed version was a cooker build
cooker_base_version=$(echo "$version" | cut -d'-' -f2)
version="$cooker_base_version" # Temporarily assign cooker base version to $version so update script can read it properly.
set_setting_value "$rd_conf" "update_repo" "RetroDECK" retrodeck "options"
set_setting_value "$rd_conf" "update_check" "false" retrodeck "options"
set_setting_value "$rd_conf" "update_ignore" "" retrodeck "options"
set_setting_value "$rd_conf" "developer_options" "false" retrodeck "options"
set_setting_value "$rd_conf" "logging_level" "info" retrodeck "options"
fi
post_update # Executing post update script
fi
fi
# Else, LOCKFILE IS NOT EXISTING (WAS REMOVED)
# if the lock file doesn't exist at all means that it's a fresh install or a triggered reset
else
log w "Lockfile not found"
finit # Executing First/Force init
fi

View file

@ -95,71 +95,6 @@ esac
source /app/libexec/global.sh
# Check if this is a new install
if [ -f "$lockfile" ]; then
if [ "$hard_version" != "$version" ]; then
log d "Update triggered"
log d "Lockfile found but the version doesn't match with the config file"
log i "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
log d "Newly-installed version is a \"cooker\" build"
configurator_generic_dialog "RetroDECK Cooker Warning" "RUNNING COOKER VERSIONS OF RETRODECK CAN BE EXTREMELY DANGEROUS AND ALL OF YOUR RETRODECK DATA\n(INCLUDING BIOS FILES, BORDERS, DOWNLOADED MEDIA, GAMELISTS, MODS, ROMS, SAVES, STATES, SCREENSHOTS, TEXTURE PACKS AND THEMES)\nARE AT RISK BY CONTINUING!"
set_setting_value "$rd_conf" "update_repo" "$cooker_repository_name" retrodeck "options"
set_setting_value "$rd_conf" "update_check" "true" retrodeck "options"
set_setting_value "$rd_conf" "developer_options" "true" retrodeck "options"
set_setting_value "$rd_conf" "logging_level" "debug" retrodeck "options"
cooker_base_version=$(echo "$version" | cut -d'-' -f2)
choice=$(rd_zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap --ok-label="Upgrade" --extra-button="Don't Upgrade" --extra-button="Full Wipe and Fresh Install" \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--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 folders and data (including ROMs and saves) 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
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.
log i "Skipping upgrade process for cooker build, updating stored version in retrodeck.cfg"
set_setting_value "$rd_conf" "version" "$hard_version" retrodeck # Set version of currently running RetroDECK to updated retrodeck.cfg
elif [[ "$choice" == "Full Wipe and Fresh Install" ]]; then # Remove all RetroDECK data and start a fresh install
if [[ $(configurator_generic_question_dialog "RetroDECK Cooker Reset" "This is going to remove all of the data in all locations used by RetroDECK!\n\n(INCLUDING BIOS FILES, BORDERS, DOWNLOADED MEDIA, GAMELISTS, MODS, ROMS, SAVES, STATES, SCREENSHOTS, TEXTURE PACKS AND THEMES)\n\nAre you sure you want to contine?") == "true" ]]; then
if [[ $(configurator_generic_question_dialog "RetroDECK Cooker Reset" "Are you super sure?\n\nThere is no going back from this process, everything is gonzo.\nDust in the wind.\n\nYesterdays omelette.") == "true" ]]; then
if [[ $(configurator_generic_question_dialog "RetroDECK Cooker Reset" "But are you super DUPER sure? We REAAAALLLLLYY want to make sure you know what is happening here.\n\nThe ~/retrodeck and ~/.var/app/net.retrodeck.retrodeck folders and ALL of their contents\nare about to be PERMANENTLY removed.\n\nStill sure you want to proceed?") == "true" ]]; then
configurator_generic_dialog "RetroDECK Cooker Reset" "Ok, if you're that sure, here we go!"
if [[ $(configurator_generic_question_dialog "RetroDECK Cooker Reset" "(Are you actually being serious here? Because we are...\n\nNo backsies.)") == "true" ]]; then
log w "Removing RetroDECK data and starting fresh"
rm -rf /var
rm -rf "$HOME/retrodeck"
rm -rf "$rdhome"
source /app/libexec/global.sh
finit
fi
fi
fi
fi
fi
else
log i "Performing normal upgrade process for version $cooker_base_version"
version="$cooker_base_version" # Temporarily assign cooker base version to $version so update script can read it properly.
post_update
fi
else # If newly-installed version is a normal build.
if grep -qF "cooker" <<< "$version"; then # If previously installed version was a cooker build
cooker_base_version=$(echo "$version" | cut -d'-' -f2)
version="$cooker_base_version" # Temporarily assign cooker base version to $version so update script can read it properly.
set_setting_value "$rd_conf" "update_repo" "RetroDECK" retrodeck "options"
set_setting_value "$rd_conf" "update_check" "false" retrodeck "options"
set_setting_value "$rd_conf" "update_ignore" "" retrodeck "options"
set_setting_value "$rd_conf" "developer_options" "false" retrodeck "options"
set_setting_value "$rd_conf" "logging_level" "info" retrodeck "options"
fi
post_update # Executing post update script
fi
fi
# Else, LOCKFILE IS NOT EXISTING (WAS REMOVED)
# if the lock file doesn't exist at all means that it's a fresh install or a triggered reset
else
log w "Lockfile not found"
finit # Executing First/Force init
fi
# Process command-line arguments
while [[ $# -gt 0 ]]; do
# If the first argument is -e, -s, -m, or a valid file, attempt to launch the game