Merge branch 'cooker-0.8.0b' of https://github.com/XargonWan/RetroDECK into cooker-0.8.0b

This commit is contained in:
XargonWan 2024-04-12 08:55:34 +09:00
commit 508ea16e22
4 changed files with 45 additions and 31 deletions

View file

@ -55,36 +55,35 @@ validate_for_chd() {
local file="$1"
local normalized_filename=$(echo "$file" | tr '[:upper:]' '[:lower:]')
local file_validated="false"
chd_validation_log_file="compression_$(basename "$file").log"
echo "Validating file:" "$file" > "$logs_folder/$chd_validation_log_file"
log i "Validating file: $file"
if echo "$normalized_filename" | grep -qE '\.iso|\.cue|\.gdi'; then
echo ".cue/.iso/.gdi file detected" >> "$logs_folder/$chd_validation_log_file"
log i ".cue/.iso/.gdi file detected"
local file_path=$(dirname "$(realpath "$file")")
local file_base_name=$(basename "$file")
local file_name=${file_base_name%.*}
if [[ "$normalized_filename" == *".cue" ]]; then # Validate .cue file
if [[ ! "$file_path" == *"dreamcast"* ]]; then # .bin/.cue compression may not work for Dreamcast, only GDI or ISO # TODO: verify
echo "Validating .cue associated .bin files" >> "$logs_folder/$chd_validation_log_file"
log i "Validating .cue associated .bin files"
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
echo "Associated bin files read:" >> "$logs_folder/$chd_validation_log_file"
printf '%s\n' "$cue_bin_files" >> "$logs_folder/$chd_validation_log_file"
log i "Associated bin files read:"
log i $(printf '%s\n' "$cue_bin_files")
if [[ ! -z "$cue_bin_files" ]]; then
while IFS= read -r line
do
echo "looking for $file_path/$line" >> "$logs_folder/$chd_validation_log_file"
log i "Looking for $file_path/$line"
if [[ -f "$file_path/$line" ]]; then
echo ".bin file found at $file_path/$line" >> "$logs_folder/$chd_validation_log_file"
log i ".bin file found at $file_path/$line"
file_validated="true"
else
echo ".bin file NOT found at $file_path/$line" >> "$logs_folder/$chd_validation_log_file"
echo ".cue file could not be validated. Please verify your .cue file contains the correct corresponding .bin file information and retry." >> "$logs_folder/$chd_validation_log_file"
log e ".bin file NOT found at $file_path/$line"
log e ".cue file could not be validated. Please verify your .cue file contains the correct corresponding .bin file information and retry."
file_validated="false"
break
fi
done < <(printf '%s\n' "$cue_bin_files")
fi
else
echo ".cue files not compatible with Dreamcast CHD compression" >> "$logs_folder/$chd_validation_log_file"
log w ".cue files not compatible with CHD compression"
fi
echo $file_validated
else # If file is a .iso or .gdi
@ -92,7 +91,7 @@ validate_for_chd() {
echo $file_validated
fi
else
echo "File type not recognized. Supported file types are .cue, .gdi and .iso" >> "$logs_folder/$chd_validation_log_file"
log w "File type not recognized. Supported file types are .cue, .gdi and .iso"
echo $file_validated
fi
}
@ -108,7 +107,7 @@ cli_compress_single_game() {
local system=$(echo "$file" | grep -oE "$roms_folder/[^/]+" | grep -oE "[^/]+$")
local compatible_compression_format=$(find_compatible_compression_format "$file")
if [[ ! $compatible_compression_format == "none" ]]; then
echo "$(basename "$file") can be compressed to $compatible_compression_format"
log i "$(basename "$file") can be compressed to $compatible_compression_format"
compress_game "$compatible_compression_format" "$file" "$system"
if [[ $post_compression_cleanup == [yY] ]]; then # Remove file(s) if requested
if [[ -f "${file%.*}.$compatible_compression_format" ]]; then
@ -117,27 +116,27 @@ cli_compress_single_game() {
local file_path=$(dirname "$(realpath "$file")")
while IFS= read -r line
do # Remove associated .bin files
echo "Removing original file "$file_path/$line""
log i "Removing original file "$file_path/$line""
rm -f "$file_path/$line"
done < <(printf '%s\n' "$cue_bin_files") # Remove original .cue file
echo "Removing original file $(basename "$file")"
log i "Removing original file $(basename "$file")"
rm -f "$file"
else
echo "Removing original file $(basename "$file")"
log i "Removing original file $(basename "$file")"
rm -f "$file"
fi
else
echo "Compressed version of $(basename "$file") not found, skipping deletion."
log w "Compressed version of $(basename "$file") not found, skipping deletion."
fi
fi
else
echo "$(basename "$file") does not have any compatible compression formats."
log w "$(basename "$file") does not have any compatible compression formats."
fi
else
echo "File not found, please specify the full path to the file to be compressed."
log w "File not found, please specify the full path to the file to be compressed."
fi
else
echo "Please use this command format \"--compress-one <path to file to compress>\""
log i "Please use this command format \"--compress-one <path to file to compress>\""
fi
}
@ -165,12 +164,12 @@ cli_compress_all_games() {
do
local compression_candidates=$(find "$roms_folder/$system" -type f -not -iname "*.txt")
if [[ ! -z "$compression_candidates" ]]; then
echo "Checking files for $system"
log i "Checking files for $system"
while IFS= read -r file
do
local compatible_compression_format=$(find_compatible_compression_format "$file")
if [[ ! "$compatible_compression_format" == "none" ]]; then
echo "$(basename "$file") can be compressed to $compatible_compression_format"
log i "$(basename "$file") can be compressed to $compatible_compression_format"
compress_game "$compatible_compression_format" "$file" "$system"
if [[ $post_compression_cleanup == [yY] ]]; then # Remove file(s) if requested
if [[ -f "${file%.*}.$compatible_compression_format" ]]; then
@ -179,25 +178,25 @@ cli_compress_all_games() {
local file_path=$(dirname "$(realpath "$file")")
while IFS= read -r line
do # Remove associated .bin files
echo "Removing original file "$file_path/$line""
log i "Removing original file "$file_path/$line""
rm -f "$file_path/$line"
done < <(printf '%s\n' "$cue_bin_files") # Remove original .cue file
echo "Removing original file "$file""
log i "Removing original file "$file""
rm -f $(realpath "$file")
else
echo "Removing original file "$file""
log i "Removing original file "$file""
rm -f $(realpath "$file")
fi
else
echo "Compressed version of $(basename "$file") not found, skipping deletion."
log w "Compressed version of $(basename "$file") not found, skipping deletion."
fi
fi
else
echo "No compatible compression format found for $(basename "$file")"
log w "No compatible compression format found for $(basename "$file")"
fi
done < <(printf '%s\n' "$compression_candidates")
else
echo "No compatible files found for compression in $system"
log w "No compatible files found for compression in $system"
fi
done < <(printf '%s\n' "$compressable_systems_list")
}

View file

@ -828,7 +828,10 @@ prepare_component() {
create_dir "/var/config/boilr"
cp -fvr "/app/libexec/steam-sync/config.toml" "/var/config/boilr"
fi
if [[ ! "$component" =~ ^(retrodeck|es-de|ES-DE|retroarch|RetroArch|citra|citra-emu|Citra|cemu|Cemu|dolphin|dolphin-emu|Dolphin|duckstation|Duckstation|melonds|melonDS|MelonDS|pcsx2|PCSX2|pico8|pico-8|ppsspp|PPSSPP|primehack|Primehack|rpcs3|RPCS3|ryujinx|Ryujinx|yuzu|Yuzu|xemu|XEMU|vita3k|Vita3K|mame|MAME|gzdoom|GZDOOM|boilr|BOILR|)$ ]]; then
log e "Supplied component $component not found, not resetting"
fi
# Update presets for all components after any reset or move

View file

@ -56,7 +56,7 @@ https://retrodeck.net
;;
--reset-component*)
echo "You are about to reset one or more RetroDECK components or emulators."
echo "Available options are: es-de, retroarch, cemu, dolphin, duckstation, gzdoom, melonds, pcsx3, pico8, ppsspp, primehack, ryujinx, rpcs3, xemu, vita3k, mame, boilr, all"
echo "Available options are: es-de, retroarch, cemu, dolphin, duckstation, gzdoom, melonds, pcsx3, pico8, ppsspp, primehack, rpcs3, ryujinx, xemu, vita3k, mame, boilr, all"
read -p "Please enter the component you would like to reset: " component
if [[ "$component" =~ ^(es-de|retroarch|cemu|dolphin|duckstation|gzdoom|mame|melonds|pcsx2|ppsspp|primehack|ryujinx|rpcs3|xemu|all)$ ]]; then
read -p "You are about to reset $component to default settings. Enter 'y' to continue, 'n' to stop: " response

View file

@ -790,22 +790,28 @@ configurator_compress_single_game_dialog() {
if [[ ! $compatible_compression_format == "none" ]]; then
local post_compression_cleanup=$(configurator_compression_cleanup_dialog)
(
echo "# Compressing $(basename "$file") to $compatible_compression_format format"
echo "# Compressing $(basename "$file") to $compatible_compression_format format" # This updates the Zenity dialog
log i "Compressing $(basename "$file") to $compatible_compression_format format"
compress_game "$compatible_compression_format" "$file" "$system"
if [[ $post_compression_cleanup == "true" ]]; then # Remove file(s) if requested
if [[ -f "${file%.*}.$compatible_compression_format" ]]; then
log i "Performing post-compression file cleanup"
if [[ "$file" == *".cue" ]]; then
local cue_bin_files=$(grep -o -P "(?<=FILE \").*(?=\".*$)" "$file")
local file_path=$(dirname "$(realpath "$file")")
while IFS= read -r line
do
log i "Removing file $file_path/$line"
rm -f "$file_path/$line"
done < <(printf '%s\n' "$cue_bin_files")
log i "Removing file $(realpath $file)"
rm -f $(realpath "$file")
else
log i "Removing file $(realpath $file)"
rm -f "$(realpath "$file")"
fi
else
log i "Compressed file ${file%.*}.$compatible_compression_format not found, skipping original file deletion"
configurator_generic_dialog "RetroDECK Configurator - RetroDECK: Compression Tool" "A compressed version of the file was not found, skipping deletion."
fi
fi
@ -909,9 +915,11 @@ configurator_compress_multiple_games_dialog() {
local system=$(echo "$file" | grep -oE "$roms_folder/[^/]+" | grep -oE "[^/]+$")
local compression_format=$(find_compatible_compression_format "$file")
echo "# Compressing $(basename "$file") into $compression_format format" # Update Zenity dialog text
log i "Compressing $(basename "$file") into $compression_format format"
progress=$(( 100 - (( 100 / "$total_games_to_compress" ) * "$games_left_to_compress" )))
echo $progress
games_left_to_compress=$((games_left_to_compress-1))
log i "Games left to compress: $games_left_to_compress"
compress_game "$compression_format" "$file" "$system"
if [[ $post_compression_cleanup == "true" ]]; then # Remove file(s) if requested
if [[ -f "${file%.*}.$compatible_compression_format" ]]; then
@ -920,13 +928,17 @@ configurator_compress_multiple_games_dialog() {
local file_path=$(dirname "$(realpath "$file")")
while IFS= read -r line
do
log i "Removing file $file_path/$line"
rm -f "$file_path/$line"
done < <(printf '%s\n' "$cue_bin_files")
log i "Removing file $(realpath $file)"
rm -f $(realpath "$file")
else
log i "Removing file $(realpath $file)"
rm -f "$(realpath "$file")"
fi
else
log i "Compressed file ${file%.*}.$compatible_compression_format not found, skipping original file deletion"
configurator_generic_dialog "RetroDECK Configurator - RetroDECK: Compression Tool" "Compression of $(basename $file) failed, skipping deletion."
fi
fi