mingw-caverns.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. # Script to add caverns to all applicable release zips.
  2. #!/bin/bash
  3. URL="https://vault.digitalmzx.net/download.php?rid=182&f=26f59999fc55953e81a66cf01d0207fe3b124387a4a4c9288a155f6a44134641"
  4. PREFIX="/mzx-build-workingdir/caverns"
  5. CAVERNS_PATH="caverns"
  6. _3DS_PATH="3ds"
  7. NDS_PATH="nds"
  8. WII_PATH="wii"
  9. SWITCH_PATH="switch"
  10. _3DS_DIR="3ds/megazeux"
  11. NDS_DIR="games/megazeux"
  12. WII_DIR="apps/megazeux"
  13. SWITCH_DIR="switch/megazeux"
  14. mkdir -p $PREFIX/caverns
  15. if [ ! -f "$PREFIX/caverns.zip" ]; then
  16. wget $URL -O $PREFIX/caverns.zip
  17. 7z e $PREFIX/caverns.zip -o$PREFIX/$CAVERNS_PATH
  18. fi
  19. function setup_arch
  20. {
  21. # A pretty convoluted directory structure is required to get 7za to
  22. # put anything where we want it to go.
  23. # $1 Arch folder
  24. # $2 Directory to put caverns in
  25. if [ ! -d "$PREFIX/$1" ]; then
  26. mkdir -p $PREFIX/$1/$2
  27. cp -r $PREFIX/$CAVERNS_PATH/* $PREFIX/$1/$2
  28. fi
  29. }
  30. setup_arch $_3DS_PATH $_3DS_DIR
  31. setup_arch $NDS_PATH $NDS_DIR
  32. setup_arch $WII_PATH $WII_DIR
  33. setup_arch $SWITCH_PATH $SWITCH_DIR
  34. function locate_mzx
  35. {
  36. # $1 - archive to search
  37. # $2 - filename to check for
  38. return $(7za l $1 $2 -r | grep -q "$2")
  39. }
  40. function add_caverns
  41. {
  42. # 7za actually requires changing to the directory for the copy to not
  43. # include the containing directory. No, really.
  44. # $1 - Archive
  45. # $2 - Arch folder
  46. pushd $PREFIX/$2 > /dev/null
  47. 7za a $1 * -y -bsp0 -bso0
  48. popd > /dev/null
  49. }
  50. function check_file
  51. {
  52. # $1 the file to check for different MegaZeux releases.
  53. if $(locate_mzx $1 "mzxrun.exe"); then
  54. echo "Found mzxrun.exe in $1; adding caverns to Windows at /"
  55. add_caverns $1 $CAVERNS_PATH
  56. elif $(locate_mzx $1 "mzxrun.cia"); then
  57. echo "Found mzxrun.cia in $1; adding caverns to 3DS at $_3DS_DIR"
  58. add_caverns $1 $_3DS_PATH
  59. elif $(locate_mzx $1 "mzxrun.nds"); then
  60. echo "Found mzxrun.nds in $1; adding caverns to NDS at $NDS_DIR"
  61. add_caverns $1 $NDS_PATH
  62. elif $(locate_mzx $1 "megazeux.dol"); then
  63. echo "Found megazeux.dol in $1; adding caverns to Wii at $WII_DIR"
  64. add_caverns $1 $WII_PATH
  65. # FIXME: Switch not yet merged.
  66. #elif $(locate_mzx $1 "megazeux.nro"); then
  67. #echo "Found megazeux.nro in $1; adding caverns to Switch at $SWITCH_DIR"
  68. #add_caverns $1 $SWITCH_PATH
  69. elif $(locate_mzx $1 "EBOOT.PBP"); then
  70. echo "Found EBOOT.PBP in $1; adding caverns to PSP at /"
  71. add_caverns $1 $CAVERNS_PATH
  72. fi
  73. }
  74. for f in $(find /mzx-build-workingdir/zips -name "*.zip"); do
  75. check_file $f &
  76. done
  77. wait