test.sh 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. #!/bin/bash
  2. SELF_PATH="$(dirname $(realpath "$0"))"
  3. CACHE_PATH="${SELF_PATH}/cache"
  4. DL_PATH="${CACHE_PATH}/dl"
  5. EXTRACT_PATH="${CACHE_PATH}/extract"
  6. TMP_PATH="${CACHE_PATH}/tmp"
  7. FILES=( \
  8. "Jazz2swc.exe::http://discmaster.textfiles.com/file/23917/PC%20Gamer%20IT%20CD%2031%202-2.iso/jazz2/Jazz2swc.exe" \
  9. "jazz2swf.exe::http://discmaster.textfiles.com/file/24033/1998-07_Disc_4.1.iso/jazz2/jazz2swf.exe" \
  10. "Battery_Check_SETUP.EXE::https://archive.org/download/BATTERYCHECK/SETUP.EXE" \
  11. #"Jazz2swf.exe::http://discmaster.textfiles.com/file/10572/TOP100WIN98.iso/100win98/Install/jazzjack/Jazz2swf.exe" \
  12. "JAZZ2SWF.EXE::http://discmaster.textfiles.com/file/22548/GAMBLERCD19.BIN/DEMOS/JAZZJAC2/JAZZ2SWF.EXE" \
  13. "J2swc123.exe::http://discmaster.textfiles.com/file/24044/1998-12_Disc_4.6.bin/JAZZ2/J2swc123.exe" \
  14. "JazzJackrabbit2.exe::http://discmaster.textfiles.com/file/21986/PowerPlay0599.bin/Demos/JazzJackrabbit2.exe" \
  15. "Jumbo_Puzzel_Setup.exe::http://discmaster.textfiles.com/file/13787/Jumbo%20Cartoon.bin/Setup/Setup.exe" \
  16. "Jumbo_Puzzel_Setup2000.exe::http://discmaster.textfiles.com/file/13787/Jumbo%20Cartoon.bin/Setup/Setup2000.exe" \
  17. "Melk_gamefull.exe::https://archive.org/download/melk-the-game/gamefull.exe" \
  18. "Melk_patch.exe::https://archive.org/download/melk-the-game/patch.exe" \
  19. "Melk_upgrade.exe::https://archive.org/download/melk-the-game/upgrade.exe" \
  20. "Melk_gamelight.exe::https://archive.org/download/melk-the-game/gamelight.exe"
  21. )
  22. SHA256_SUMS=( \
  23. "f05c9f0ddc6a9fafa96140e1bb7707e38124babf79f94cf9df2f49baae9fca11" \
  24. "ce1bfbc7727a6ff03ba461ad5fdc7c292d3b90924baaf6111d7bbfecf7a55231" \
  25. "ed748389be06131ed9df2f28294707ea3926f408c40733e95c34656b86be34b3" \
  26. #"cd3beccbfd03dab477ca648418b23d3d337fa5a03aaacd25ca9b7f2fdabe05c9" \ # Corrupt
  27. "3d2c2cf6f9d44811ebceab4a3757e078ceff22f45cade97b362c414fb5a1360d" \
  28. "ad06659d6057b7c696889fc194d2c651320b8a2ed8d989d4a602df4b0df551f7" \
  29. "8cb81307d4121718e488f8dbc513eae9126dee5a4a77932e1d7c25de61479f4a" \
  30. "e04235bc0447b26580febcf69926b91a2e68f47c27166aefcf881af45861d93a" \
  31. "4d577083e1c37070ce71ee846bb1f483abc21d145851aaa226a5d3cde60c7d2c" \
  32. "3655e8f5460cf339423be888bd9d2709f0c7b20822fd84571d49c13afedf0b9b" \
  33. "92c3c1ae25bcbd718dd6b9917714d769e72ca986df9c371f4011e9a72dc4f5eb" \
  34. "0fa9a6dfc2a951bbcd61f0f16cc700c9c0922f7cbdf6f2617dbf7fd6d54f56a8" \
  35. "dba618ba99c1a0ee692f040a13944677207973acbbfd57c8fd68a4d202e92059"
  36. )
  37. dl_installer() {
  38. FILEPATH="$1"
  39. URL="$2"
  40. wget --quiet -O "${FILEPATH}" "${URL}"
  41. if [[ "$?" -ne "0" ]]; then
  42. echo "Failed"
  43. exit 1
  44. fi
  45. }
  46. verify_installer() {
  47. SHASUM="$1"
  48. FILEPATH="$2"
  49. sha256sum --quiet -c - <<< "${SHASUM} ${FILEPATH}"
  50. if [[ "$?" -ne "0" ]]; then
  51. echo "Mismatch"
  52. exit 1
  53. fi
  54. }
  55. clear_extract_dir() {
  56. rm -rf "${EXTRACT_PATH}" && mkdir "${EXTRACT_PATH}"
  57. }
  58. # Create cache dirs
  59. if [[ ! -d "${DL_PATH}" ]]; then
  60. mkdir -p "${DL_PATH}"
  61. fi
  62. if [[ ! -d "${EXTRACT_PATH}" ]]; then
  63. mkdir "${EXTRACT_PATH}"
  64. fi
  65. if [[ ! -d "${TMP_PATH}" ]]; then
  66. mkdir "${TMP_PATH}"
  67. fi
  68. # cd into SELF_PATH so didiextract can be found by ../didiextract
  69. cd "${SELF_PATH}"
  70. # Make sure didiextract is present.
  71. if [[ ! -f "../didiextract" ]]; then
  72. echo "DiDi Extract (${SELF_PATH}/../didiextract) not found."
  73. exit 1
  74. fi
  75. for i in ${!FILES[@]}; do
  76. FILE="${FILES[i]}"
  77. FILENAME="${FILE%%::*}"
  78. FILEURL="${FILE#*::}"
  79. FILEPATH="${DL_PATH}/${FILENAME}"
  80. echo "TEST ${FILENAME}"
  81. echo "-------------------------------------------------------------"
  82. # Make sure the installer file is present, else download it.
  83. if [[ ! -f "${FILEPATH}" ]]; then
  84. echo -n "DOWNLOAD file : "
  85. dl_installer "${FILEPATH}" "${FILEURL}"
  86. echo "OK"
  87. fi
  88. # Verify installer file its sha256.
  89. echo -n "CHECK file integrity : "
  90. verify_installer "${SHA256_SUMS[i]}" "${FILEPATH}"
  91. echo "OK"
  92. # Test --verify
  93. # This assumes DiDi Extract will exit accordingly.
  94. echo -n "CHECK didiextract verify : "
  95. ../didiextract --verify --silent "${FILEPATH}"
  96. if [[ $? -ne 0 ]]; then
  97. echo "Failed"
  98. exit 2
  99. fi
  100. echo "OK"
  101. # Test --extract
  102. echo -n "CHECK didiextract extract : "
  103. ../didiextract --extract "${EXTRACT_PATH}" --silent "${FILEPATH}"
  104. if [[ $? -ne 0 ]]; then
  105. echo "Failed"
  106. clear_extract_dir
  107. exit 2
  108. fi
  109. # Match sha256 sums of extracted files.
  110. (
  111. cd "${EXTRACT_PATH}"
  112. sha256sum --quiet -c "${SELF_PATH}/sums/${FILENAME}.sha256"
  113. if [[ $? -ne 0 ]]; then
  114. echo "Mismatch"
  115. #clear_extract_dir
  116. exit 1
  117. fi
  118. )
  119. echo "OK"
  120. clear_extract_dir
  121. echo "-------------------------------------------------------------"
  122. echo ""
  123. done
  124. echo "All seems OK! :-D"
  125. exit 0