package_assaultcube.sh 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. #!/bin/bash
  2. # Before creating compressed package complete this checklist (main points):
  3. # * Patch the source code/package with any relevant materials.
  4. # * Set the makefile to strip symbols.
  5. # * Compile new 32/64-bit binaries and put them in their appropriate ./bin_unix location.
  6. # * Delete all unnecessary files/folders.
  7. # ** CHANGE THE BELOW VARIABLES BEFORE EXECUTING THE SCRIPT ** #
  8. #PATHTOACDEV=$(dirname $(cd ../ && pwd))
  9. # Please ensure this path is NOT inside your "ACDIR" folder, as
  10. # this will be the place the tarball package gets saved.
  11. SAVETARBALLPATH=~/AssaultCube
  12. # This will be the directory that gets packaged:
  13. ACDIR=$SAVETARBALLPATH/AC
  14. ACDIRTESTING=$SAVETARBALLPATH/AC_testing
  15. ACDOCSDIR=$ACDIR/docs
  16. NEWACTAG=$(git describe --tags --abbrev=0)
  17. NEWACVERSION=$(echo $NEWACTAG |awk '{ print substr($0,2)}')
  18. # KSH won't work, as this script uses echo throughout it, echo's options are shell-specific:
  19. if [ -z "$BASH" ]; then
  20. echo "FAILURE: Please run this script with BASH (bash $0), not SH/KSH/ZSH, etc."
  21. exit
  22. fi
  23. # Set auto-aliases:
  24. ACDIRFOLDERNAME=`basename $ACDIR`
  25. # Create folder for new AC release:
  26. if [ ! -d "$ACDIR" ]; then
  27. mkdir -p "$ACDIR"
  28. else
  29. rm -r "$ACDIR"
  30. mkdir -p "$ACDIR"
  31. fi
  32. # Create folder for compiling binaries for new AC release:
  33. if [ ! -d "$ACDIRTESTING" ]; then
  34. mkdir "$ACDIRTESTING"
  35. else
  36. rm -r "$ACDIRTESTING"
  37. mkdir "$ACDIRTESTING"
  38. fi
  39. # Get AC files from latest local release tag:
  40. cd ../../
  41. git archive --format=tar.gz --output "$ACDIR/$NEWACTAG.tar.gz" $NEWACTAG
  42. cd "$ACDIR"
  43. tar -zxf "$ACDIR/$NEWACTAG.tar.gz"
  44. tar -zxf "$ACDIR/$NEWACTAG.tar.gz" -C "$ACDIRTESTING"
  45. rm -r "$ACDIR/$NEWACTAG.tar.gz"
  46. # Use new, "portable" profile in "$ACDIRTESTING":
  47. sed -i 's/--home=.*\s/--home=profile /' $ACDIRTESTING/assaultcube.sh
  48. # Get documentation files from latest remote release tag:
  49. svn export --force https://github.com/assaultcube/assaultcube.github.io/tags/$NEWACTAG/htdocs/docs/ $ACDOCSDIR
  50. # Start of the script, so remind the user of things we can't check:
  51. echo -e "\033[1mIf required, did you patch the source with any relevant materials?\033[0m"
  52. echo " * Press ENTER to continue, otherwise press ctrl+c to exit."
  53. read DUMMY
  54. echo -e "\033[1mDid you compile 32- and 64-bit binaries in $ACDIRTESTING and strip symbols when compiling?\033[0m"
  55. echo " * If so, press ENTER to continue, otherwise press ctrl+c to exit."
  56. read DUMMY
  57. echo -e "\033[1mDid you renamed filenames of created binaries to linux_* and linux_64_*?\033[0m"
  58. echo " * If so, press ENTER to continue, otherwise press ctrl+c to exit."
  59. read DUMMY
  60. echo -e "\033[1mDid you generate fresh config/mapmodelattributes.cfg (/loadallmapmodels)?\033[0m"
  61. echo " * If so, press ENTER to continue, otherwise press ctrl+c to exit."
  62. read DUMMY
  63. echo -e "\033[1mIs the save-path in assaultcube.sh correct?\033[0m"
  64. echo " * If so, press ENTER to continue, otherwise press ctrl+c to exit."
  65. read DUMMY
  66. echo -e "\033[1mHave you checked all following variables in this script are set correctly?\033[0m"
  67. echo -e " * The packages created by this script will be saved to this folder:\n $SAVETARBALLPATH"
  68. echo -e " * The absolute-path to your AssaultCube directory is set as:\n $ACDIR"
  69. echo -e " * The absolute-path to your AssaultCube \"docs\" directory is set as:\n $ACDOCSDIR"
  70. echo -e " * Your new AssaultCube version will become:\n $NEWACVERSION\n"
  71. echo -e "\033[1mIf these are correct, press ENTER to continue, otherwise press ctrl+c to exit.\033[0m"
  72. read DUMMY
  73. # Still at the start of the script, so find user-errors that we can check:
  74. # Checking "$ACDIR" is set correctly:
  75. if [ -e $ACDIR/source/src/main.cpp ]; then
  76. echo "Stated path to AssaultCube contains \"source/src/main.cpp\""
  77. echo "Hopefully this means the path is correct and contained files are good."
  78. echo -e "Proceeding to the next step...\n"
  79. else
  80. echo -e "\033[1;31mERROR:\033[0m \"source/src/main.cpp\" did NOT exist at the ACDIR alias."
  81. echo "Open this shell file and modify that alias to fix it."
  82. exit
  83. fi
  84. # Checking "$ACDOCSDIR" is set correctly:
  85. if [ -e $ACDOCSDIR/reference.xml ]; then
  86. echo "Stated path to AssaultCube's documentation contains \"reference.xml\""
  87. echo "Hopefully this means the path is correct and contained files are good."
  88. echo -e "Proceeding to the next step...\n"
  89. else
  90. echo -e "\033[1;31mERROR:\033[0m \"reference.xml\" does NOT exist in %ACDOCSDIR."
  91. echo "Copy documentation to that folder to fix it."
  92. exit
  93. fi
  94. # Check that linux binaries have been created today:
  95. cp -v -i $ACDIRTESTING/bin_unix/linux* $ACDIR/bin_unix
  96. checkbinaries() {
  97. BINARYFILES=`cd $ACDIR/bin_unix && find ./linux_* -mtime 0 | sort | xargs`
  98. }
  99. checkbinaries
  100. until [ "$BINARYFILES" = "./linux_64_client ./linux_64_server ./linux_client ./linux_server" ]; do
  101. echo -e "\033[1;31mERROR:\033[0m Timestamps on binary files are older than 24 hours or they're missing."
  102. echo "Please add new 32/64-bit binaries."
  103. read DUMMY
  104. checkbinaries
  105. done
  106. echo "All binaries have been compiled in the last 24 hours. Hopefully this means they're up to date!"
  107. echo -e "Proceeding to the next step...\n"
  108. # Check that config/mapmodelattributes.cfg has been created today:
  109. cp -v -i $ACDIRTESTING/profile/config/mapmodelattributes.cfg $ACDIR/config
  110. checkmapmodelsattr() {
  111. MAPMODELATTRFILE=`cd $ACDIR/config && find ./mapmodelattributes.cfg -mtime 0 | xargs`
  112. }
  113. checkmapmodelsattr
  114. until [ "$MAPMODELATTRFILE" = "./mapmodelattributes.cfg" ]; do
  115. echo -e "\033[1;31mERROR:\033[0m Timestamp on config/mapmodelattributes.cfg is older than 24 hours or it's missing."
  116. echo "Please add fresh config/mapmodelattributes.cfg file."
  117. read DUMMY
  118. checkmapmodelsattr
  119. done
  120. echo "config/mapmodelattributes.cfg has been generated in the last 24 hours. Hopefully this means it's up to date!"
  121. echo -e "Proceeding to the next step...\n"
  122. # Check that shadows.dat files exist. To grab a list of shadows.dat files:
  123. # cd ./packages/models && find . -name "shadows.dat" | sort
  124. echo -e "\033[1mDid you copy shadow files (*.dat) from another working AC installation into $ACDIR?\033[0m"
  125. echo -e " * If not, they will be automatically copied from $ACDIRTESTING"
  126. echo " * Press ENTER to continue, otherwise press ctrl+c to exit."
  127. read DUMMY
  128. cd $ACDIR/packages/models/
  129. ACDIRMODELS_SHADOWS=$ACDIRTESTING/profile/packages/models
  130. if [ ! -e ./misc/gib01/shadows.dat ]; then cp -v $ACDIRMODELS_SHADOWS/misc/gib01/shadows.dat $(pwd)/misc/gib01/shadows.dat; fi
  131. if [ ! -e ./misc/gib02/shadows.dat ]; then cp -v $ACDIRMODELS_SHADOWS/misc/gib02/shadows.dat $(pwd)/misc/gib02/shadows.dat; fi
  132. if [ ! -e ./misc/gib03/shadows.dat ]; then cp -v $ACDIRMODELS_SHADOWS/misc/gib03/shadows.dat $(pwd)/misc/gib03/shadows.dat; fi
  133. if [ ! -e ./pickups/akimbo/shadows.dat ]; then cp -v $ACDIRMODELS_SHADOWS/pickups/akimbo/shadows.dat $(pwd)/pickups/akimbo/shadows.dat; fi
  134. if [ ! -e ./pickups/ammobox/shadows.dat ]; then cp -v $ACDIRMODELS_SHADOWS/pickups/ammobox/shadows.dat $(pwd)/pickups/ammobox/shadows.dat; fi
  135. if [ ! -e ./pickups/health/shadows.dat ]; then cp -v $ACDIRMODELS_SHADOWS/pickups/health/shadows.dat $(pwd)/pickups/health/shadows.dat; fi
  136. if [ ! -e ./pickups/helmet/shadows.dat ]; then cp -v $ACDIRMODELS_SHADOWS/pickups/helmet/shadows.dat $(pwd)/pickups/helmet/shadows.dat; fi
  137. if [ ! -e ./pickups/kevlar/shadows.dat ]; then cp -v $ACDIRMODELS_SHADOWS/pickups/kevlar/shadows.dat $(pwd)/pickups/kevlar/shadows.dat; fi
  138. if [ ! -e ./pickups/nade/shadows.dat ]; then cp -v $ACDIRMODELS_SHADOWS/pickups/nade/shadows.dat $(pwd)/pickups/nade/shadows.dat; fi
  139. if [ ! -e ./pickups/pistolclips/shadows.dat ]; then cp -v $ACDIRMODELS_SHADOWS/pickups/pistolclips/shadows.dat $(pwd)/pickups/pistolclips/shadows.dat; fi
  140. if [ ! -e ./playermodels/shadows.dat ]; then cp -v $ACDIRMODELS_SHADOWS/playermodels/shadows.dat $(pwd)/playermodels/shadows.dat; fi
  141. if [ ! -e ./weapons/assault/world/shadows.dat ]; then cp -v $ACDIRMODELS_SHADOWS/weapons/assault/world/shadows.dat $(pwd)/weapons/assault/world/shadows.dat; fi
  142. if [ ! -e ./weapons/carbine/world/shadows.dat ]; then cp -v $ACDIRMODELS_SHADOWS/weapons/carbine/world/shadows.dat $(pwd)/weapons/carbine/world/shadows.dat; fi
  143. if [ ! -e ./weapons/grenade/static/shadows.dat ]; then cp -v $ACDIRMODELS_SHADOWS/weapons/grenade/static/shadows.dat $(pwd)/weapons/grenade/static/shadows.dat; fi
  144. if [ ! -e ./weapons/grenade/world/shadows.dat ]; then cp -v $ACDIRMODELS_SHADOWS/weapons/grenade/world/shadows.dat $(pwd)/weapons/grenade/world/shadows.dat; fi
  145. if [ ! -e ./weapons/knife/world/shadows.dat ]; then cp -v $ACDIRMODELS_SHADOWS/weapons/knife/world/shadows.dat $(pwd)/weapons/knife/world/shadows.dat; fi
  146. if [ ! -e ./weapons/pistol/world/shadows.dat ]; then cp -v $ACDIRMODELS_SHADOWS/weapons/pistol/world/shadows.dat $(pwd)/weapons/pistol/world/shadows.dat; fi
  147. if [ ! -e ./weapons/shotgun/world/shadows.dat ]; then cp -v $ACDIRMODELS_SHADOWS/weapons/shotgun/world/shadows.dat $(pwd)/weapons/shotgun/world/shadows.dat; fi
  148. if [ ! -e ./weapons/sniper/world/shadows.dat ]; then cp -v $ACDIRMODELS_SHADOWS/weapons/sniper/world/shadows.dat $(pwd)/weapons/sniper/world/shadows.dat; fi
  149. if [ ! -e ./weapons/subgun/world/shadows.dat ]; then cp -v $ACDIRMODELS_SHADOWS/weapons/subgun/world/shadows.dat $(pwd)/weapons/subgun/world/shadows.dat; fi
  150. until [ -f ./misc/gib01/shadows.dat ] \
  151. && [ -f ./misc/gib02/shadows.dat ] \
  152. && [ -f ./misc/gib03/shadows.dat ] \
  153. && [ -f ./pickups/akimbo/shadows.dat ] \
  154. && [ -f ./pickups/ammobox/shadows.dat ] \
  155. && [ -f ./pickups/health/shadows.dat ] \
  156. && [ -f ./pickups/helmet/shadows.dat ] \
  157. && [ -f ./pickups/kevlar/shadows.dat ] \
  158. && [ -f ./pickups/nade/shadows.dat ] \
  159. && [ -f ./pickups/pistolclips/shadows.dat ] \
  160. && [ -f ./playermodels/shadows.dat ] \
  161. && [ -f ./weapons/assault/world/shadows.dat ] \
  162. && [ -f ./weapons/carbine/world/shadows.dat ] \
  163. && [ -f ./weapons/grenade/static/shadows.dat ] \
  164. && [ -f ./weapons/grenade/world/shadows.dat ] \
  165. && [ -f ./weapons/knife/world/shadows.dat ] \
  166. && [ -f ./weapons/pistol/world/shadows.dat ] \
  167. && [ -f ./weapons/shotgun/world/shadows.dat ] \
  168. && [ -f ./weapons/sniper/world/shadows.dat ] \
  169. && [ -f ./weapons/subgun/world/shadows.dat ]; do
  170. echo -e "\033[1;31mERROR:\033[0m Some shadows.dat files are missing."
  171. echo "Please run AssaultCube to generate these files."
  172. read DUMMY
  173. done
  174. echo "All known shadows.dat files exist."
  175. echo -e "Proceeding to the next step...\n"
  176. # Check that map previews are all available:
  177. MAPSPATH="$ACDIR/packages/maps/official"
  178. MAPSCGZ=`cd $MAPSPATH && find ./*.cgz | xargs -i basename {} .cgz | sort -u | xargs`
  179. MAPSJPG=`cd $MAPSPATH/preview && find ./*.jpg | xargs -i basename {} .jpg | sort -u | xargs`
  180. if [ "$MAPSCGZ" = "$MAPSJPG" ]; then
  181. echo "All map \"previews\" are available!"
  182. echo -e "Proceeding to the next step...\n"
  183. else
  184. echo -e "\033[1;31mERROR:\033[0m Some map previews are missing."
  185. echo "Please go to $MAPSPATH/preview and create the ones that are missing!"
  186. exit
  187. fi
  188. # Check that bot waypoints are all available:
  189. MAPSCGZ2=`cd $MAPSPATH && find ./*.cgz | xargs -i basename {} .cgz | sort -u | xargs`
  190. MAPSBOTS=`cd $ACDIR/bot/waypoints && find ./*.wpt | xargs -i basename {} .wpt | sort -u | xargs`
  191. if [ "$MAPSBOTS" = "$MAPSCGZ2" ]; then
  192. echo "All bot waypoints are available!"
  193. echo -e "Proceeding to the next step...\n"
  194. else
  195. echo -e "\033[1;31mERROR:\033[0m Some bot waypoints are missing."
  196. echo "Please go generate the ones that are missing!"
  197. exit
  198. fi
  199. # Delete stuff related to git and GitHub:
  200. rm -rf ./.git
  201. rm -f ./.gitattributes
  202. rm -f ./.travis.yml
  203. find . -type f -name ".gitignore" -delete
  204. # Delete gedit backups:
  205. find . -type f -name "*~" -delete
  206. # Create config template for release:
  207. cd $ACDIR/config
  208. zip configtemplates.zip autoexec.cfg favourites.cfg pcksources.cfg
  209. # Clean out crufty files:
  210. echo "Please wait: Cleaning out some crufty files..."
  211. cd $ACDIR/source/enet && make distclean
  212. cd ../src && make clean
  213. rm -f init*.cfg saved*.cfg servervita*.cfg servers.cfg history
  214. rm -f ./clientlog*.txt
  215. rm -f ./bin_unix/native_*
  216. rm -f ./bin_unix/ac_*
  217. rm -f ./packages/maps/dev_*.cgz
  218. rm -f ./packages/maps/dev_*.cfg
  219. rm -f ./packages/maps/servermaps/incoming/*.cgz
  220. rm -f ./packages/maps/servermaps/incoming/*.cfg
  221. rm -f ./screenshots/*
  222. # Leave tutorial code here, just in case of future use:
  223. cd $ACDIR && rm -f `(find ./demos/* -type f | grep -v "tutorial_demo.dmo")`
  224. # Set up ./config/securemaps.cfg - just in-case:
  225. echo "... Generating ./config/securemaps.cfg"
  226. echo "resetsecuremaps" > ./config/securemaps.cfg
  227. find ./packages/maps/official/*.cgz | \
  228. xargs -i basename {} .cgz | \
  229. xargs -i echo -e "securemap" {} | \
  230. sort -u >> ./config/securemaps.cfg
  231. # update checksum file:
  232. sh $ACDIR/source/dev_tools/generate_md5_checksums.sh
  233. # Create the linux tarball:
  234. echo "\n... Creating the Linux tarball..."
  235. cd $SAVETARBALLPATH
  236. if [ -d "AssaultCube_v$NEWACVERSION" ]; then
  237. rm -r "AssaultCube_v$NEWACVERSION"
  238. fi
  239. mv $ACDIRFOLDERNAME AssaultCube_v$NEWACVERSION
  240. tar cjvf $SAVETARBALLPATH/AssaultCube_v$NEWACVERSION.tar.bz2 \
  241. --exclude=".*" \
  242. --exclude=*.bat \
  243. --exclude=*bin_win32* \
  244. --exclude=*doxygen* \
  245. --exclude="*source/lib*" \
  246. --exclude=*vcpp* \
  247. --exclude=*xcode* \
  248. --exclude=*AssaultCube.cbp \
  249. --exclude=*autoexec.cfg \
  250. --exclude=*favourites.cfg \
  251. --exclude=*pcksources.cfg \
  252. --exclude=*new_content.cfg \
  253. --exclude=*new_content.cgz \
  254. --exclude-vcs \
  255. AssaultCube_v$NEWACVERSION/