dfhack/ci/download-df.sh

51 lines
1.2 KiB
Bash

2018-02-03 21:01:15 -07:00
#!/bin/sh
2023-08-03 04:59:50 -06:00
DF_FOLDER=$1
OS_TARGET=$2
DF_VERSION=$3
2020-06-29 20:04:33 -06:00
set -e
2023-08-03 04:59:50 -06:00
minor=$(echo "$DF_VERSION" | cut -d. -f1)
patch=$(echo "$DF_VERSION" | cut -d. -f2)
df_url="https://www.bay12games.com/dwarves/df_${minor}_${patch}"
if test "$OS_TARGET" = "windows"; then
2023-08-03 05:37:13 -06:00
WGET="C:/msys64/usr/bin/wget.exe"
2023-08-03 04:59:50 -06:00
df_url="${df_url}_win_s.zip"
df_archive_name="df.zip"
df_extract_cmd="unzip -d ${DF_FOLDER}"
2023-08-03 22:49:26 -06:00
elif test "$OS_TARGET" = "ubuntu"; then
2023-08-03 05:37:13 -06:00
WGET=wget
2023-08-03 04:59:50 -06:00
df_url="${df_url}_linux.tar.bz2"
df_archive_name="df.tar.bz2"
df_extract_cmd="tar -x -j --strip-components=1 -f"
else
echo "Unhandled OS target: ${OS_TARGET}"
exit 1
fi
2023-08-03 05:37:13 -06:00
if ! $WGET -v "$df_url" -O "$df_archive_name"; then
2023-08-03 04:59:50 -06:00
echo "Failed to download DF from $df_url"
exit 1
2018-12-30 15:47:10 -07:00
fi
2018-02-03 21:01:15 -07:00
2023-08-03 04:59:50 -06:00
save_url="https://dffd.bay12games.com/download.php?id=15434&f=dreamfort.7z"
save_archive_name="test_save.7z"
save_extract_cmd="7z x -oDF/save"
2023-08-03 05:37:13 -06:00
if ! $WGET -v "$save_url" -O "$save_archive_name"; then
2023-08-03 04:59:50 -06:00
echo "Failed to download test save from $save_url"
exit 1
fi
2018-02-03 21:01:15 -07:00
echo Extracting
2023-08-03 04:59:50 -06:00
$df_extract_cmd "$df_archive_name"
$save_extract_cmd "$save_archive_name"
mv DF/save/* DF/save/region1
2018-02-03 21:01:15 -07:00
echo Done
ls -l
2023-08-03 04:59:50 -06:00
md5sum "$df_archive_name" "$save_archive_name"