Patches can now get downloaded

This commit is contained in:
Libretto 2024-01-27 00:37:01 +01:00
parent 60fa87c16b
commit 9377502a9f
2 changed files with 29 additions and 3 deletions

View file

@ -15,17 +15,40 @@ hacks_db_setup() {
declare -g hacks_db_cmd="sqlite3 $hacks_db_path"
}
db_sanitize() {
echo "$(echo "$1" | sed -e "s/'/''/g")"
}
check_romhacks_compatibility() {
# Register all crc32 checksums of potential base ROMs and their paths into the dictionary "base_roms"
# Add paths of locally available base roms to db
for rom_path in ${roms_folder}/*/*; do
if [[ "$(basename "$rom_path")" != "systeminfo.txt" ]]; then
crc32="$($crc32_cmd "$rom_path")"
sanitized_path="$(echo "$rom_path" | sed -e "s/'/''/g")"
$hacks_db_cmd < <(echo "UPDATE bases SET local_path = '""$sanitized_path""' WHERE crc32 = '""$crc32""'")
$hacks_db_cmd < <(echo "UPDATE bases SET local_path = '""$(db_sanitize "$rom_path")""' WHERE crc32 = '""$crc32""'")
fi
done
}
install_romhack() {
# $1: name of romhack
set -exo pipefail
hack_name="$1"
infos=$($hacks_db_cmd "SELECT bases.system,bases.name,bases.local_path \
FROM bases JOIN rhacks ON bases.crc32 = rhacks.base_crc32 \
WHERE rhacks.name = '""$(db_sanitize "$1")""'")
IFS='|' read -r system base_name base_local_path <<< $infos
# download patchfile
wget -q "https://github.com/Libretto7/best-romhacks/raw/main/rhacks/$system/$base_name/$hack_name/patch.tar.xz" -O "/tmp/patch.tar.xz"
patchfile_name=$(tar -xvf "/tmp/patch.tar.xz" --directory="$roms_folder/$system")
echo "$patchfile_name"
flips="flatpak-spawn --host flatpak run com.github.Alcaro.Flips"
}

View file

@ -103,6 +103,8 @@ source /app/libexec/global.sh
# DIALOG TREE FUNCTIONS
configurator_welcome_dialog() {
configurator_romhack_downloader_dialog
if [[ $developer_options == "true" ]]; then
welcome_menu_options=("Presets & Settings" "Here you find various presets, tweaks and settings to customize your RetroDECK experience" \
"Open Emulator" "Launch and configure each emulators settings (for advanced users)" \
@ -1430,6 +1432,7 @@ configurator_romhack_downloader_dialog() {
"${zenity_columns[@]}" )
echo "$choice"
install_romhack "$choice" && echo "success"
configurator_welcome_dialog
}