2024-01-18 13:31:47 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-01-26 18:47:19 +00:00
|
|
|
hacks_db_setup() {
|
2024-01-18 13:31:47 +00:00
|
|
|
crc32_cmd="python3 /app/libexec/crc32.py"
|
|
|
|
|
|
|
|
# "hacks" is the general name which includes ROM Hacks, Homebrew and Ports
|
2024-01-26 18:47:19 +00:00
|
|
|
hacks_repo_url="https://raw.githubusercontent.com/Libretto7/best-romhacks/main"
|
2024-01-18 13:31:47 +00:00
|
|
|
hacks_db_path="$HOME/.var/app/net.retrodeck.retrodeck/data/hacks_metadata.db"
|
|
|
|
|
|
|
|
# set up hacks database
|
2024-01-26 18:47:19 +00:00
|
|
|
rm $hacks_db_path
|
2024-01-18 13:31:47 +00:00
|
|
|
sqlite3 $hacks_db_path < <(curl -sL "$hacks_repo_url"/db_setup.sql)
|
2024-01-26 18:47:19 +00:00
|
|
|
sqlite3 $hacks_db_path < <(echo "ALTER TABLE bases ADD COLUMN local_path;")
|
2024-01-18 13:31:47 +00:00
|
|
|
|
|
|
|
declare -g hacks_db_cmd="sqlite3 $hacks_db_path"
|
|
|
|
}
|
|
|
|
|
2024-01-26 18:47:19 +00:00
|
|
|
check_romhacks_compatibility() {
|
2024-01-18 13:31:47 +00:00
|
|
|
# Register all crc32 checksums of potential base ROMs and their paths into the dictionary "base_roms"
|
|
|
|
|
2024-01-26 18:47:19 +00:00
|
|
|
for rom_path in ${roms_folder}/*/*; do
|
|
|
|
if [[ "$(basename "$rom_path")" != "systeminfo.txt" ]]; then
|
2024-01-18 13:31:47 +00:00
|
|
|
|
2024-01-26 18:47:19 +00:00
|
|
|
crc32="$($crc32_cmd "$rom_path")"
|
|
|
|
sanitized_path="$(echo "$rom_path" | sed -e "s/'/''/g")"
|
2024-01-18 13:31:47 +00:00
|
|
|
|
2024-01-26 18:47:19 +00:00
|
|
|
$hacks_db_cmd < <(echo "UPDATE bases SET local_path = '""$sanitized_path""' WHERE crc32 = '""$crc32""'")
|
2024-01-18 13:31:47 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|