Skip to content

Commit

Permalink
Add Roms sha testing
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudo-rnd-thoughts committed Oct 11, 2024
1 parent da0a628 commit beb2fca
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions scripts/download_unpack_roms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,31 @@ base_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)/.."
unpack_dir="${base_dir}/unpack_dir"
target_dir="${base_dir}/src/ale/python/roms"

file_url="https://gist.githubusercontent.com/jjshoots/61b22aefce4456920ba99f2c36906eda/raw/00046ac3403768bfe45857610a3d333b8e35e026/Roms.tar.gz.b64"
expected_checksum="02ca777c16476a72fa36680a2ba78f24c3ac31b2155033549a5f37a0653117de"
temp_file="Roms.tar.gz.b64"

# make the directory where we will do the unpacking
mkdir $unpack_dir

# download the ROMs from the git gist, decode it, then unpack it
curl "https://gist.githubusercontent.com/jjshoots/61b22aefce4456920ba99f2c36906eda/raw/00046ac3403768bfe45857610a3d333b8e35e026/Roms.tar.gz.b64" \
| base64 --decode \
| tar -xzf - -C $unpack_dir
# Download the ROMs
curl -o "$temp_file" "$file_url"

# Compute the SHA256 checksum of the ROMs file and compare with the expected checksum
computed_checksum=$(sha256sum "$temp_file" | awk '{ print $1 }') # use `shasum -a 256` for macos

if [ "$computed_checksum" == "$expected_checksum" ]; then
# Decode the base64 file and extract the tar.gz content
cat "$temp_file" \
| base64 --decode \
| tar -xzf - -C "$unpack_dir"

# Clean up the temporary file
rm -f "$temp_file"
else
echo "Checksum verification failed! Exiting."
exit 1 # Stop the script on checksum failure
fi

# move the ROMs out into a roms folder
mv ${unpack_dir}/ROM/*/*.bin $target_dir
Expand Down

0 comments on commit beb2fca

Please sign in to comment.