mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2024-11-25 07:25:38 +00:00
Refactor post_update
This commit is contained in:
parent
f823b80eca
commit
ab8ef28cae
188
functions.sh
188
functions.sh
|
@ -741,194 +741,6 @@ create_lock() {
|
|||
conf_write
|
||||
}
|
||||
|
||||
post_update() {
|
||||
# post update script
|
||||
echo "Executing post-update script"
|
||||
|
||||
# Finding existing ROMs folder
|
||||
if [ -d "$default_sd/retrodeck" ]
|
||||
then
|
||||
# ROMs on SD card
|
||||
roms_folder="$default_sd/retrodeck/roms"
|
||||
if [[ ! -L $rdhome && ! -L $rdhome/roms ]]; then # Add a roms folder symlink back to ~/retrodeck if missing, to fix things like PS2 autosaves until user migrates whole ~retrodeck directory
|
||||
ln -s $roms_folder $rdhome/roms
|
||||
fi
|
||||
else
|
||||
# ROMs on Internal
|
||||
roms_folder="$HOME/retrodeck/roms"
|
||||
fi
|
||||
echo "ROMs folder found at $roms_folder"
|
||||
|
||||
# Unhiding downloaded media from the previous versions
|
||||
if [ -d "$rdhome/.downloaded_media" ]
|
||||
then
|
||||
mv -fv "$rdhome/.downloaded_media" "$media_folder"
|
||||
fi
|
||||
|
||||
# Unhiding themes folder from the previous versions
|
||||
if [ -d "$rdhome/.themes" ]
|
||||
then
|
||||
mv -fv "$rdhome/.themes" "$themes_folder"
|
||||
fi
|
||||
|
||||
# Doing the dir prep as we don't know from which version we came
|
||||
dir_prep "$media_folder" "/var/config/emulationstation/.emulationstation/downloaded_media"
|
||||
dir_prep "$themes_folder" "/var/config/emulationstation/.emulationstation/themes"
|
||||
mkdir -pv $rdhome/.logs #this was added later, maybe safe to remove in a few versions
|
||||
|
||||
|
||||
# Resetting es_settings, now we need it but in the future I should think a better solution, maybe with sed
|
||||
cp -fv /app/retrodeck/es_settings.xml /var/config/emulationstation/.emulationstation/es_settings.xml
|
||||
|
||||
|
||||
# 0.4 -> 0.5
|
||||
# Perform save and state migration if needed
|
||||
|
||||
# Moving PCSX2 Saves
|
||||
mv -fv /var/config/PCSX2/sstates/* $rdhome/states/ps2/pcsx2
|
||||
mv -fv /var/config/PCSX2/memcards/* $rdhome/saves/ps2/memcards
|
||||
|
||||
# Moving Citra saves from legacy location to 0.5.0b structure
|
||||
|
||||
mv -fv $rdhome/saves/Citra/* $rdhome/saves/n3ds/citra
|
||||
rmdir $rdhome/saves/Citra # Old folder cleanup
|
||||
|
||||
versionwheresaveschanged="0.4.5b" # Hardcoded break point between unsorted and sorted saves
|
||||
|
||||
if [[ $(sed -e "s/\.//g" <<< $hard_version) > $(sed -e "s/\.//g" <<< $versionwheresaveschanged) ]] && [[ ! $(sed -e "s/\.//g" <<< $version) > $(sed -e "s/\.//g" <<< $versionwheresaveschanged) ]]; then # Check if user is upgrading from the version where save organization was changed. Try not to reuse this, it things 0.4.5b is newer than 0.4.5
|
||||
migration_logfile=$rdhome/.logs/savemove_"$(date +"%Y_%m_%d_%I_%M_%p").log"
|
||||
save_backup_file=$rdhome/savebackup_"$(date +"%Y_%m_%d_%I_%M_%p").zip"
|
||||
state_backup_file=$rdhome/statesbackup_"$(date +"%Y_%m_%d_%I_%M_%p").zip"
|
||||
|
||||
zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap \
|
||||
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
||||
--title "RetroDECK" \
|
||||
--text="You are updating to a version of RetroDECK where save file locations have changed!\n\nYour existing files will be backed up for safety and then sorted automatically.\n\nIf a file cannot be sorted automatically it will remain where it is for manual sorting.\n\nPLEASE BE PATIENT! This process can take several minutes if you have a large ROM library."
|
||||
|
||||
allgames=($(find "$roms_folder" -maxdepth 2 -mindepth 2 ! -name "systeminfo.txt" ! -name "systems.txt" ! -name "gc" ! -name "n3ds" ! -name "nds" ! -name "wii" ! -name "xbox" ! -name "*^*" | sed -e "s/ /\^/g")) # Build an array of all games and multi-disc-game-containing folders, adding whitespace placeholder
|
||||
|
||||
allsaves=($(find "$saves_folder" -mindepth 1 -maxdepth 1 -name "*.*" ! -name "gc" ! -name "n3ds" ! -name "nds" ! -name "wii" ! -name "xbox" | sed -e "s/ /\^/g")) # Build an array of all save files, ignoring standalone emulator sub-folders, adding whitespace placeholder
|
||||
|
||||
allstates=($(find "$states_folder" -mindepth 1 -maxdepth 1 -name "*.*" ! -name "gc" ! -name "n3ds" ! -name "nds" ! -name "wii" ! -name "xbox" | sed -e "s/ /\^/g")) # Build an array of all state files, ignoring standalone emulator sub-folders, adding whitespace placeholder
|
||||
|
||||
totalsaves=${#allsaves[@]}
|
||||
totalstates=${#allstates[@]}
|
||||
filesleft=
|
||||
current_dest_folder=
|
||||
gamestoskip=
|
||||
|
||||
tar -C $rdhome -czf $save_backup_file saves # Backup save directory for safety
|
||||
echo "Saves backed up to" $save_backup_file >> $migration_logfile
|
||||
tar -C $rdhome -czf $state_backup_file states # Backup state directory for safety
|
||||
echo "States backed up to" $state_backup_file >> $migration_logfile
|
||||
|
||||
(
|
||||
movefile() { # Take matching save and rom files and sort save into appropriate system folder
|
||||
echo "# $filesleft $currentlybeingmoved remaining..." # These lines update the Zenity progress bar
|
||||
progress=$(( 100 - (( 100 / "$totalfiles" ) * "$filesleft" )))
|
||||
echo $progress
|
||||
filesleft=$((filesleft-1))
|
||||
if [[ ! " ${gamestoskip[*]} " =~ " ${1} " ]]; then # If the current game name exists multiple times in array ie. /roms/snes/Mortal Kombat 3.zip and /roms/genesis/Mortal Kombat 3.zip, skip and alert user to sort manually
|
||||
game=$(sed -e "s/\^/ /g" <<< "$1") # Remove whitespace placeholder
|
||||
gamebasename=$(basename "$game" | sed -e 's/\..*//') # Extract pure file name ie. /roms/snes/game1.zip becomes game1
|
||||
systemdir="$(basename "$(dirname "$1")")" # Extract parent directory identifying system ROM belongs to
|
||||
matches=($(find "$roms_folder" -maxdepth 2 -mindepth 2 -name "$gamebasename"".*" | sed -e 's/ /^/g' | sed -e 's/\..*//')) # Search for multiple instances of pure game name, adding to skip list if found
|
||||
if [[ ${#matches[@]} -gt 1 ]]; then
|
||||
echo "ERROR: Multiple ROMS found with name:" $gamebasename "Please sort saves and states for these ROMS manually" >> $migration_logfile
|
||||
gamestoskip+=("$1")
|
||||
return
|
||||
fi
|
||||
echo "INFO: Examining ROM file:" "$game" >> $migration_logfile
|
||||
echo "INFO: System detected as" $systemdir >> $migration_logfile
|
||||
sosfile=$(sed -e "s/\^/ /g" <<< "$2") # Remove whitespace placeholder from s-ave o-r s-tate file
|
||||
sospurebasename="$(basename "$sosfile")" # Extract pure file name ie. /saves/game1.sav becomes game1
|
||||
echo "INFO: Current save or state being examined for match:" $sosfile >> $migration_logfile
|
||||
echo "INFO: Matching save or state" $sosfile "and game" $game "found." >> $migration_logfile
|
||||
echo "INFO: Moving save or state to" $current_dest_folder"/"$systemdir"/"$sosbasename >> $migration_logfile
|
||||
if [[ ! -d $current_dest_folder"/"$systemdir ]]; then # If system directory doesn't exist for save yet, create it
|
||||
echo "WARNING: Creating missing system directory" $current_dest_folder"/"$systemdir
|
||||
mkdir $current_dest_folder/$systemdir
|
||||
fi
|
||||
mv "$sosfile" -t $current_dest_folder/$systemdir # Move save to appropriate system directory
|
||||
return
|
||||
else
|
||||
echo "WARNING: Game with name" "$(basename "$1" | sed -e "s/\^/ /g")" "already found. Skipping to next game..." >> $migration_logfile # Inform user of game being skipped due to duplicate ROM names
|
||||
fi
|
||||
}
|
||||
|
||||
find "$roms_folder" -mindepth 2 -maxdepth 2 -name "*\^*" -exec echo "ERROR: Game named" {} "found, please move save manually" \; >> $migration_logfile # Warn user if any of their files have the whitespace replacement character used by the script
|
||||
|
||||
totalfiles=$totalsaves #set variables for save file migration
|
||||
filesleft=$totalsaves
|
||||
currentlybeingmoved="saves"
|
||||
current_dest_folder=$saves_folder
|
||||
|
||||
for i in "${allsaves[@]}"; do # For each save file, compare to every ROM file name looking for a match
|
||||
found=
|
||||
currentsave=($(basename "$i" | sed -e 's/\..*//')) # Extract pure file name ie. /saves/game1.sav becomes game1
|
||||
for j in "${allgames[@]}"; do
|
||||
currentgame=($(basename "$j" | sed -e 's/\..*//')) # Extract pure file name ie. /roms/snes/game1.zip becomes game1
|
||||
[[ $currentgame == $currentsave ]] && { found=1; break; } # If names match move to next stage, otherwise skip
|
||||
done
|
||||
[[ -n $found ]] && movefile $j $i || echo "ERROR: No ROM match found for save file" $i | sed -e 's/\^/ /g' >> $migration_logfile # If a match is found, run movefile() otherwise warn user of stranded save file
|
||||
done
|
||||
|
||||
totalfiles=$totalstates #set variables for state file migration
|
||||
filesleft=$totalstates
|
||||
currentlybeingmoved="states"
|
||||
current_dest_folder=$states_folder
|
||||
|
||||
for i in "${allstates[@]}"; do # For each state file, compare to every ROM file name looking for a match
|
||||
found=
|
||||
currentstate=($(basename "$i" | sed -e 's/\..*//')) # Extract pure file name ie. /states/game1.sav becomes game1
|
||||
for j in "${allgames[@]}"; do
|
||||
currentgame=($(basename "$j" | sed -e 's/\..*//')) # Extract pure file name ie. /roms/snes/game1.zip becomes game1
|
||||
[[ $currentgame == $currentstate ]] && { found=1; break; } # If names match move to next stage, otherwise skip
|
||||
done
|
||||
[[ -n $found ]] && movefile $j $i || echo "ERROR: No ROM match found for state file" $i | sed -e 's/\^/ /g' >> $migration_logfile # If a match is found, run movefile() otherwise warn user of stranded state file
|
||||
done
|
||||
|
||||
) |
|
||||
zenity --progress \
|
||||
--icon-name=net.retrodeck.retrodeck \
|
||||
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
||||
--title="Processing Files" \
|
||||
--text="# files remaining..." \
|
||||
--percentage=0 \
|
||||
--no-cancel \
|
||||
--auto-close
|
||||
|
||||
if [[ $(cat $migration_logfile | grep "ERROR" | wc -l) -eq 0 ]]; then
|
||||
zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap \
|
||||
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
||||
--title "RetroDECK" \
|
||||
--text="The migration process has sorted all of your files automatically.\n\nEverything should be working normally, if you experience any issues please check the RetroDECK wiki or contact us directly on the Discord."
|
||||
|
||||
else
|
||||
cat $migration_logfile | grep "ERROR" > "$rdhome/manual_sort_needed.log"
|
||||
zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap \
|
||||
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
||||
--title "RetroDECK" \
|
||||
--text="The migration process was unable to sort $(cat $migration_logfile | grep "ERROR" | wc -l) files automatically.\n\nThese files will need to be moved manually to their new locations, find more detail on the RetroDECK wiki.\n\nA log of the files that need manual sorting can be found at $rdhome/manual_sort_needed.log"
|
||||
fi
|
||||
|
||||
else
|
||||
echo "Version" $version "is after the save and state organization was changed, no need to sort again"
|
||||
fi
|
||||
|
||||
(
|
||||
ra_init
|
||||
standalones_init
|
||||
tools_init
|
||||
) |
|
||||
zenity --icon-name=net.retrodeck.retrodeck --progress --no-cancel --pulsate --auto-close \
|
||||
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
||||
--title "RetroDECK Finishing Upgrade" \
|
||||
--text="RetroDECK is finishing the upgrade process, please wait."
|
||||
|
||||
create_lock
|
||||
}
|
||||
|
||||
start_retrodeck() {
|
||||
# normal startup
|
||||
echo "Starting RetroDECK v$version"
|
||||
|
|
12
global.sh
12
global.sh
|
@ -41,6 +41,16 @@ pcsx2conf="/var/config/PCSX2/inis/GS.ini"
|
|||
pcsx2uiconf="/var/config/PCSX2/inis/PCSX2_ui.ini"
|
||||
pcsx2vmconf="/var/config/PCSX2/inis/PCSX2_vm.ini"
|
||||
|
||||
# PCSX2-QT config file
|
||||
|
||||
pcsx2qtconf="/var/config/PCSX2/inis/PCSX2.ini"
|
||||
|
||||
# We moved the lockfile in /var/config/retrodeck in order to solve issue #53 - Remove in a few versions
|
||||
if [ -f "$HOME/retrodeck/.lock" ]
|
||||
then
|
||||
mv "$HOME/retrodeck/.lock" $lockfile
|
||||
fi
|
||||
|
||||
# If there is no config file I initalize the file with the the default values
|
||||
if [ ! -f "$rd_conf" ]
|
||||
then
|
||||
|
@ -51,7 +61,7 @@ then
|
|||
# if we are here means that the we are in a new installation, so the version is valorized with the hardcoded one
|
||||
# Initializing the variables
|
||||
if [ -z $version]; then
|
||||
if [[ $(cat $lockfile) == *"0.4."* ]] || [[ $(cat $lockfile) == *"0.3."* ]] || [[ $(cat $lockfile) == *"0.2."* ]] || [[ $(cat $lockfile) == *"0.1."* ]]; then
|
||||
if [[ $(cat $lockfile) == *"0.4."* ]] || [[ $(cat $lockfile) == *"0.3."* ]] || [[ $(cat $lockfile) == *"0.2."* ]] || [[ $(cat $lockfile) == *"0.1."* ]]; then # If the previous version is very out of date, pre-rd_conf
|
||||
echo "Running version workaround"
|
||||
version=$(cat $lockfile)
|
||||
else
|
||||
|
|
|
@ -985,6 +985,8 @@ modules:
|
|||
|
||||
- cp functions.sh /app/libexec/functions.sh
|
||||
|
||||
- cp post_update.sh /app/libexec/post_update.sh
|
||||
|
||||
# Desktop entry
|
||||
- cp net.retrodeck.retrodeck.desktop /app/share/applications/net.retrodeck.retrodeck.desktop
|
||||
|
||||
|
|
197
post_update.sh
Normal file
197
post_update.sh
Normal file
|
@ -0,0 +1,197 @@
|
|||
#!/bin/bash
|
||||
|
||||
post_update() {
|
||||
|
||||
# post update script
|
||||
echo "Executing post-update script"
|
||||
|
||||
case $version in # Only run updates as needed
|
||||
|
||||
"0.5.4b" )
|
||||
|
||||
# Finding existing ROMs folder
|
||||
if [ -d "$default_sd/retrodeck" ]
|
||||
then
|
||||
# ROMs on SD card
|
||||
roms_folder="$default_sd/retrodeck/roms"
|
||||
if [[ ! -L $rdhome && ! -L $rdhome/roms ]]; then # Add a roms folder symlink back to ~/retrodeck if missing, to fix things like PS2 autosaves until user migrates whole ~retrodeck directory
|
||||
ln -s $roms_folder $rdhome/roms
|
||||
fi
|
||||
else
|
||||
# ROMs on Internal
|
||||
roms_folder="$HOME/retrodeck/roms"
|
||||
fi
|
||||
echo "ROMs folder found at $roms_folder"
|
||||
|
||||
# Unhiding downloaded media from the previous versions
|
||||
if [ -d "$rdhome/.downloaded_media" ]
|
||||
then
|
||||
mv -fv "$rdhome/.downloaded_media" "$media_folder"
|
||||
fi
|
||||
|
||||
# Unhiding themes folder from the previous versions
|
||||
if [ -d "$rdhome/.themes" ]
|
||||
then
|
||||
mv -fv "$rdhome/.themes" "$themes_folder"
|
||||
fi
|
||||
|
||||
# Doing the dir prep as we don't know from which version we came
|
||||
dir_prep "$media_folder" "/var/config/emulationstation/.emulationstation/downloaded_media"
|
||||
dir_prep "$themes_folder" "/var/config/emulationstation/.emulationstation/themes"
|
||||
mkdir -pv $rdhome/.logs #this was added later, maybe safe to remove in a few versions
|
||||
|
||||
# Resetting es_settings, now we need it but in the future I should think a better solution, maybe with sed
|
||||
cp -fv /app/retrodeck/es_settings.xml /var/config/emulationstation/.emulationstation/es_settings.xml
|
||||
|
||||
# 0.4 -> 0.5
|
||||
# Perform save and state migration if needed
|
||||
|
||||
# Moving PCSX2 Saves
|
||||
mv -fv /var/config/PCSX2/sstates/* $rdhome/states/ps2/pcsx2
|
||||
mv -fv /var/config/PCSX2/memcards/* $rdhome/saves/ps2/memcards
|
||||
|
||||
# Moving Citra saves from legacy location to 0.5.0b structure
|
||||
|
||||
mv -fv $rdhome/saves/Citra/* $rdhome/saves/n3ds/citra
|
||||
rmdir $rdhome/saves/Citra # Old folder cleanup
|
||||
|
||||
versionwheresaveschanged="0.4.5b" # Hardcoded break point between unsorted and sorted saves
|
||||
|
||||
if [[ $(sed -e "s/\.//g" <<< $hard_version) > $(sed -e "s/\.//g" <<< $versionwheresaveschanged) ]] && [[ ! $(sed -e "s/\.//g" <<< $version) > $(sed -e "s/\.//g" <<< $versionwheresaveschanged) ]]; then # Check if user is upgrading from the version where save organization was changed. Try not to reuse this, it things 0.4.5b is newer than 0.4.5
|
||||
migration_logfile=$rdhome/.logs/savemove_"$(date +"%Y_%m_%d_%I_%M_%p").log"
|
||||
save_backup_file=$rdhome/savebackup_"$(date +"%Y_%m_%d_%I_%M_%p").zip"
|
||||
state_backup_file=$rdhome/statesbackup_"$(date +"%Y_%m_%d_%I_%M_%p").zip"
|
||||
|
||||
zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap \
|
||||
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
||||
--title "RetroDECK" \
|
||||
--text="You are updating to a version of RetroDECK where save file locations have changed!\n\nYour existing files will be backed up for safety and then sorted automatically.\n\nIf a file cannot be sorted automatically it will remain where it is for manual sorting.\n\nPLEASE BE PATIENT! This process can take several minutes if you have a large ROM library."
|
||||
|
||||
allgames=($(find "$roms_folder" -maxdepth 2 -mindepth 2 ! -name "systeminfo.txt" ! -name "systems.txt" ! -name "gc" ! -name "n3ds" ! -name "nds" ! -name "wii" ! -name "xbox" ! -name "*^*" | sed -e "s/ /\^/g")) # Build an array of all games and multi-disc-game-containing folders, adding whitespace placeholder
|
||||
|
||||
allsaves=($(find "$saves_folder" -mindepth 1 -maxdepth 1 -name "*.*" ! -name "gc" ! -name "n3ds" ! -name "nds" ! -name "wii" ! -name "xbox" | sed -e "s/ /\^/g")) # Build an array of all save files, ignoring standalone emulator sub-folders, adding whitespace placeholder
|
||||
|
||||
allstates=($(find "$states_folder" -mindepth 1 -maxdepth 1 -name "*.*" ! -name "gc" ! -name "n3ds" ! -name "nds" ! -name "wii" ! -name "xbox" | sed -e "s/ /\^/g")) # Build an array of all state files, ignoring standalone emulator sub-folders, adding whitespace placeholder
|
||||
|
||||
totalsaves=${#allsaves[@]}
|
||||
totalstates=${#allstates[@]}
|
||||
filesleft=
|
||||
current_dest_folder=
|
||||
gamestoskip=
|
||||
|
||||
tar -C $rdhome -czf $save_backup_file saves # Backup save directory for safety
|
||||
echo "Saves backed up to" $save_backup_file >> $migration_logfile
|
||||
tar -C $rdhome -czf $state_backup_file states # Backup state directory for safety
|
||||
echo "States backed up to" $state_backup_file >> $migration_logfile
|
||||
|
||||
(
|
||||
movefile() { # Take matching save and rom files and sort save into appropriate system folder
|
||||
echo "# $filesleft $currentlybeingmoved remaining..." # These lines update the Zenity progress bar
|
||||
progress=$(( 100 - (( 100 / "$totalfiles" ) * "$filesleft" )))
|
||||
echo $progress
|
||||
filesleft=$((filesleft-1))
|
||||
if [[ ! " ${gamestoskip[*]} " =~ " ${1} " ]]; then # If the current game name exists multiple times in array ie. /roms/snes/Mortal Kombat 3.zip and /roms/genesis/Mortal Kombat 3.zip, skip and alert user to sort manually
|
||||
game=$(sed -e "s/\^/ /g" <<< "$1") # Remove whitespace placeholder
|
||||
gamebasename=$(basename "$game" | sed -e 's/\..*//') # Extract pure file name ie. /roms/snes/game1.zip becomes game1
|
||||
systemdir="$(basename "$(dirname "$1")")" # Extract parent directory identifying system ROM belongs to
|
||||
matches=($(find "$roms_folder" -maxdepth 2 -mindepth 2 -name "$gamebasename"".*" | sed -e 's/ /^/g' | sed -e 's/\..*//')) # Search for multiple instances of pure game name, adding to skip list if found
|
||||
if [[ ${#matches[@]} -gt 1 ]]; then
|
||||
echo "ERROR: Multiple ROMS found with name:" $gamebasename "Please sort saves and states for these ROMS manually" >> $migration_logfile
|
||||
gamestoskip+=("$1")
|
||||
return
|
||||
fi
|
||||
echo "INFO: Examining ROM file:" "$game" >> $migration_logfile
|
||||
echo "INFO: System detected as" $systemdir >> $migration_logfile
|
||||
sosfile=$(sed -e "s/\^/ /g" <<< "$2") # Remove whitespace placeholder from s-ave o-r s-tate file
|
||||
sospurebasename="$(basename "$sosfile")" # Extract pure file name ie. /saves/game1.sav becomes game1
|
||||
echo "INFO: Current save or state being examined for match:" $sosfile >> $migration_logfile
|
||||
echo "INFO: Matching save or state" $sosfile "and game" $game "found." >> $migration_logfile
|
||||
echo "INFO: Moving save or state to" $current_dest_folder"/"$systemdir"/"$sosbasename >> $migration_logfile
|
||||
if [[ ! -d $current_dest_folder"/"$systemdir ]]; then # If system directory doesn't exist for save yet, create it
|
||||
echo "WARNING: Creating missing system directory" $current_dest_folder"/"$systemdir
|
||||
mkdir $current_dest_folder/$systemdir
|
||||
fi
|
||||
mv "$sosfile" -t $current_dest_folder/$systemdir # Move save to appropriate system directory
|
||||
return
|
||||
else
|
||||
echo "WARNING: Game with name" "$(basename "$1" | sed -e "s/\^/ /g")" "already found. Skipping to next game..." >> $migration_logfile # Inform user of game being skipped due to duplicate ROM names
|
||||
fi
|
||||
}
|
||||
|
||||
find "$roms_folder" -mindepth 2 -maxdepth 2 -name "*\^*" -exec echo "ERROR: Game named" {} "found, please move save manually" \; >> $migration_logfile # Warn user if any of their files have the whitespace replacement character used by the script
|
||||
|
||||
totalfiles=$totalsaves #set variables for save file migration
|
||||
filesleft=$totalsaves
|
||||
currentlybeingmoved="saves"
|
||||
current_dest_folder=$saves_folder
|
||||
|
||||
for i in "${allsaves[@]}"; do # For each save file, compare to every ROM file name looking for a match
|
||||
found=
|
||||
currentsave=($(basename "$i" | sed -e 's/\..*//')) # Extract pure file name ie. /saves/game1.sav becomes game1
|
||||
for j in "${allgames[@]}"; do
|
||||
currentgame=($(basename "$j" | sed -e 's/\..*//')) # Extract pure file name ie. /roms/snes/game1.zip becomes game1
|
||||
[[ $currentgame == $currentsave ]] && { found=1; break; } # If names match move to next stage, otherwise skip
|
||||
done
|
||||
[[ -n $found ]] && movefile $j $i || echo "ERROR: No ROM match found for save file" $i | sed -e 's/\^/ /g' >> $migration_logfile # If a match is found, run movefile() otherwise warn user of stranded save file
|
||||
done
|
||||
|
||||
totalfiles=$totalstates #set variables for state file migration
|
||||
filesleft=$totalstates
|
||||
currentlybeingmoved="states"
|
||||
current_dest_folder=$states_folder
|
||||
|
||||
for i in "${allstates[@]}"; do # For each state file, compare to every ROM file name looking for a match
|
||||
found=
|
||||
currentstate=($(basename "$i" | sed -e 's/\..*//')) # Extract pure file name ie. /states/game1.sav becomes game1
|
||||
for j in "${allgames[@]}"; do
|
||||
currentgame=($(basename "$j" | sed -e 's/\..*//')) # Extract pure file name ie. /roms/snes/game1.zip becomes game1
|
||||
[[ $currentgame == $currentstate ]] && { found=1; break; } # If names match move to next stage, otherwise skip
|
||||
done
|
||||
[[ -n $found ]] && movefile $j $i || echo "ERROR: No ROM match found for state file" $i | sed -e 's/\^/ /g' >> $migration_logfile # If a match is found, run movefile() otherwise warn user of stranded state file
|
||||
done
|
||||
|
||||
) |
|
||||
zenity --progress \
|
||||
--icon-name=net.retrodeck.retrodeck \
|
||||
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
||||
--title="Processing Files" \
|
||||
--text="# files remaining..." \
|
||||
--percentage=0 \
|
||||
--no-cancel \
|
||||
--auto-close
|
||||
|
||||
if [[ $(cat $migration_logfile | grep "ERROR" | wc -l) -eq 0 ]]; then
|
||||
zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap \
|
||||
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
||||
--title "RetroDECK" \
|
||||
--text="The migration process has sorted all of your files automatically.\n\nEverything should be working normally, if you experience any issues please check the RetroDECK wiki or contact us directly on the Discord."
|
||||
|
||||
else
|
||||
cat $migration_logfile | grep "ERROR" > "$rdhome/manual_sort_needed.log"
|
||||
zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap \
|
||||
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
||||
--title "RetroDECK" \
|
||||
--text="The migration process was unable to sort $(cat $migration_logfile | grep "ERROR" | wc -l) files automatically.\n\nThese files will need to be moved manually to their new locations, find more detail on the RetroDECK wiki.\n\nA log of the files that need manual sorting can be found at $rdhome/manual_sort_needed.log"
|
||||
fi
|
||||
|
||||
else
|
||||
echo "Version" $version "is after the save and state organization was changed, no need to sort again"
|
||||
fi
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
# These commands are run every time, for now
|
||||
|
||||
(
|
||||
ra_init
|
||||
standalones_init
|
||||
tools_init
|
||||
) |
|
||||
zenity --icon-name=net.retrodeck.retrodeck --progress --no-cancel --pulsate --auto-close \
|
||||
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
|
||||
--title "RetroDECK Finishing Upgrade" \
|
||||
--text="RetroDECK is finishing the upgrade process, please wait."
|
||||
|
||||
create_lock
|
||||
}
|
11
retrodeck.sh
11
retrodeck.sh
|
@ -1,12 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
source /app/libexec/global.sh
|
||||
|
||||
# We moved the lockfile in /var/config/retrodeck in order to solve issue #53 - Remove in a few versions
|
||||
if [ -f "$HOME/retrodeck/.lock" ]
|
||||
then
|
||||
mv "$HOME/retrodeck/.lock" $lockfile
|
||||
fi
|
||||
source /app/libexec/post_update.sh
|
||||
|
||||
# Arguments section
|
||||
|
||||
|
@ -22,7 +17,7 @@ Arguments:
|
|||
-h, --help Print this help
|
||||
-v, --version Print RetroDECK version
|
||||
--info-msg Print paths and config informations
|
||||
--reset Starts the initial RetroDECK installer (backup your data first!)
|
||||
--reset-all Starts the initial RetroDECK installer (backup your data first!)
|
||||
--reset-ra Resets RetroArch's config to the default values
|
||||
--reset-sa Reset standalone emulator configs to the default values
|
||||
--reset-tools Recreate the tools section
|
||||
|
@ -58,7 +53,7 @@ https://retrodeck.net
|
|||
tools_init
|
||||
shift # past argument with no value
|
||||
;;
|
||||
--reset*)
|
||||
--reset-all*)
|
||||
rm -f "$lockfile"
|
||||
shift # past argument with no value
|
||||
;;
|
||||
|
|
|
@ -355,7 +355,6 @@ configurator_options_dialog() {
|
|||
}
|
||||
|
||||
configurator_move_dialog() {
|
||||
"Move Everything" )
|
||||
if [[ -d $rdhome ]]; then
|
||||
configurator_generic_dialog "This option will move the RetroDECK data folder (ROMs, saves, BIOS etc.) to a new location.\n\nPlease choose where to move the RetroDECK data folder."
|
||||
destination=$(configurator_destination_choice_dialog "RetroDECK Data" "Please choose a destination for the RetroDECK data folder.")
|
||||
|
|
Loading…
Reference in a new issue