Skip to content

Commit beb2fca

Browse files
Add Roms sha testing
1 parent da0a628 commit beb2fca

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

scripts/download_unpack_roms.sh

+22-4
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,31 @@ base_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)/.."
55
unpack_dir="${base_dir}/unpack_dir"
66
target_dir="${base_dir}/src/ale/python/roms"
77

8+
file_url="https://gist.githubusercontent.com/jjshoots/61b22aefce4456920ba99f2c36906eda/raw/00046ac3403768bfe45857610a3d333b8e35e026/Roms.tar.gz.b64"
9+
expected_checksum="02ca777c16476a72fa36680a2ba78f24c3ac31b2155033549a5f37a0653117de"
10+
temp_file="Roms.tar.gz.b64"
11+
812
# make the directory where we will do the unpacking
913
mkdir $unpack_dir
1014

11-
# download the ROMs from the git gist, decode it, then unpack it
12-
curl "https://gist.githubusercontent.com/jjshoots/61b22aefce4456920ba99f2c36906eda/raw/00046ac3403768bfe45857610a3d333b8e35e026/Roms.tar.gz.b64" \
13-
| base64 --decode \
14-
| tar -xzf - -C $unpack_dir
15+
# Download the ROMs
16+
curl -o "$temp_file" "$file_url"
17+
18+
# Compute the SHA256 checksum of the ROMs file and compare with the expected checksum
19+
computed_checksum=$(sha256sum "$temp_file" | awk '{ print $1 }') # use `shasum -a 256` for macos
20+
21+
if [ "$computed_checksum" == "$expected_checksum" ]; then
22+
# Decode the base64 file and extract the tar.gz content
23+
cat "$temp_file" \
24+
| base64 --decode \
25+
| tar -xzf - -C "$unpack_dir"
26+
27+
# Clean up the temporary file
28+
rm -f "$temp_file"
29+
else
30+
echo "Checksum verification failed! Exiting."
31+
exit 1 # Stop the script on checksum failure
32+
fi
1533

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

0 commit comments

Comments
 (0)