Advertisement
mrk1989

build.sh

Nov 11th, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.54 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. cd "$(dirname "$0")"
  4.  
  5. INCLUDE=1
  6. . extras/scripts/rmlib.sh || exit 1
  7. require md5sum tar 7za:zip %convert
  8.  
  9. RELEASE=0
  10. BUILD_DATE="$(date +"%F %T %Z")"
  11. BUILD_DATE_PLAIN="$(date +%y%m%d%H%M%S)"
  12. BRANCH="`git symbolic-ref HEAD 2>/dev/null | sed -e 's@^refs/heads/@@'`"
  13. COMMIT="$(git show 2>/dev/null | head -n 1 | sed -e 's/commit //' | head -c 8)"
  14. VERSION="$(rm-version)"
  15. BUILT_PACKAGES=""
  16. BUILT_PKGINFOS=""
  17. BUILT_PKGNAMES=""
  18. COMMONSUM=""
  19. MENUSUM=""
  20. CSQCSUM=""
  21.  
  22. WINDOWS=0
  23. if [ "$(uname -o)" = "Cygwin" ]; then
  24. WINDOWS=1
  25. fi
  26.  
  27. function getfiledircache
  28. {
  29. filecache=()
  30. dircache=()
  31.  
  32. checkdir "${1}/"
  33. pushd "${1}/"
  34.  
  35. if [ "${2}" = "reverse" ]; then
  36. read -r -d '' -a filecache < <( find ./ -type f | awk '{ print length, $0 }' | sort -rn | cut -d" " -f2-)
  37. read -r -d '' -a dircache < <( find ./ -type d | awk '{ print length, $0 }' | sort -rn | cut -d" " -f2-)
  38. else
  39. read -r -d '' -a filecache < <( find ./ -type f | awk '{ print length, $0 }' | sort -n | cut -d" " -f2-)
  40. read -r -d '' -a dircache < <( find ./ -type d | awk '{ print length, $0 }' | sort -n | cut -d" " -f2-)
  41. fi
  42.  
  43. popd
  44. }
  45.  
  46. function removeoldfiles
  47. {
  48. if [ -n "${LINKDIRS}" ]; then
  49.  
  50. getfiledircache "${BUILDDIR}" reverse
  51.  
  52. for j in "${LINKDIRS[@]}"; do
  53. echo " -- Removing old files and directories in '${j}/'.."
  54. checkdir "${j}"
  55.  
  56. for i in "${filecache[@]}"; do
  57. rm "${j}/${i:2}" &>/dev/null
  58. rm "${BUILDDIR}/${i:2}"
  59. done
  60.  
  61. for i in "${dircache[@]}"; do
  62. rmdir "${j}/${i:2}/" &>/dev/null
  63. rmdir "${BUILDDIR}/${i:2}/"
  64. done
  65. done
  66. fi
  67.  
  68. }
  69.  
  70. function linkfiles
  71. {
  72. if [ -n "${LINKDIRS}" ]; then
  73. getfiledircache "${BUILDDIR}"
  74.  
  75. for j in "${LINKDIRS[@]}"; do
  76. echo " -- Linking files and directories in '${BUILDDIR}/' to '${j}/'"
  77. checkdir "${j}/"
  78.  
  79. for i in "${dircache[@]}"; do
  80. mkdir "${j}/${i:2}/"
  81. done
  82.  
  83. for i in "${filecache[@]}"; do
  84. if [ "$WINDOWS" = 1 ]; then
  85. cp -vf "${BUILDDIR}/${i:2}" "${j}/${i:2}"
  86. else
  87. ln --symbolic --force "${BUILDDIR}/${i:2}" "${j}/${i:2}"
  88. fi
  89. done
  90.  
  91. done
  92. fi
  93. }
  94.  
  95. function checkdir
  96. {
  97. local dir="$(readlink -f "${1}")"
  98. if [[ -d "${dir}" ]]; then
  99. if [[ -x "${dir}" && -w "${dir}" ]]; then
  100. return 0
  101. else
  102. error "\"${dir}/\" has wrong permissions."
  103. fi
  104. else
  105. echo " -- Creating \"${dir}/\".."
  106. mkdir -p "${dir}/" || error "Could not create directory \"${dir}/\" in \"${dir%/*}/\"."
  107. fi
  108. }
  109.  
  110. function buildall
  111. {
  112. # $1 = suffix
  113. # $2 = desc
  114.  
  115. USEQCC="$(getqcc)"
  116. [ -z "$USEQCC" ] && error "Couldn't get a QC compiller"
  117.  
  118. echo " -- Calculating sum of menu/..."
  119. MENUSUM="$(find "$QCSOURCE/menu" -type f | grep -v "fteqcc.log" | xargs md5sum | md5sum | sed -e 's/ .*//g')"
  120.  
  121. echo " -- Calculating sum of common/..."
  122. COMMONSUM="$(find "$QCSOURCE/common" -type f | grep -v "fteqcc.log" | grep -v "rm_auto.qh" | xargs md5sum | md5sum | sed -e 's/ .*//g')"
  123. MENUSUM="$MENUSUM$COMMONSUM"
  124.  
  125. echo "#define RM_BUILD_DATE \"$BUILD_DATE ($2)\"" > "$QCSOURCE"/common/rm_auto.qh
  126. echo "#define RM_BUILD_NAME \"RocketMinsta$1\"" >> "$QCSOURCE"/common/rm_auto.qh
  127. echo "#define RM_BUILD_VERSION \"$VERSION\"" >> "$QCSOURCE"/common/rm_auto.qh
  128. echo "#define RM_BUILD_MENUSUM \"$MENUSUM\"" >> "$QCSOURCE"/common/rm_auto.qh
  129. echo "#define RM_BUILD_SUFFIX \"${1##-}\"" >> "$QCSOURCE"/common/rm_auto.qh
  130. echo "#define RM_BUILD_COMMIT \"$COMMIT\"" >> "$QCSOURCE"/common/rm_auto.qh
  131.  
  132. echo "#define RM_SUPPORT_CLIENTPKGS" >> "$QCSOURCE"/common/rm_auto.qh
  133. for i in $BUILT_PKGNAMES; do
  134. echo "#define RM_SUPPORT_PKG_$i" >> "$QCSOURCE"/common/rm_auto.qh
  135. done
  136.  
  137. buildqc server/
  138. mv -v progs.dat "$SVPROGS"
  139. mv -v progs.lno "${SVPROGS%%dat}lno"
  140.  
  141. buildqc client/
  142.  
  143. if [ "$PACKCSQC" = 1 ]; then
  144. rm "csqc.pk3dir"/*.{dat,lno}
  145. CSQCSUM="$(md5sum csprogs.dat | sed -e 's/ .*//')"
  146. cp -v csprogs.dat "csqc.pk3dir/$CSPROGNAME"
  147. cp -v csprogs.lno "csqc.pk3dir/${CSPROGNAME%%dat}lno"
  148. makedata csqc "$1" "$2"
  149. rm -v "csqc.pk3dir"/*.{dat,lno}
  150. fi
  151.  
  152. mv -v csprogs.dat "$CSPROGS"
  153. mv -v csprogs.lno "${CSPROGS%%dat}lno"
  154.  
  155. buildqc menu/
  156. rm "menu.pk3dir"/*.{dat,lno}
  157. mv -v menu.dat "menu.pk3dir/menu.dat"
  158. mv -v menu.lno "menu.pk3dir/menu.lno"
  159. makedata menu "$1" "$2"
  160. rm -v "menu.pk3dir"/*.{dat,lno}
  161.  
  162. rm -v "$QCSOURCE"/common/rm_auto.qh
  163.  
  164. mv -v --target-directory="${BUILDDIR}" *.lno *.log
  165. }
  166.  
  167. function tocompress
  168. {
  169. cat compressdirs | while read line; do find "$line" -name "*.tga" -maxdepth 1; done
  170. }
  171.  
  172. function compress-gfx
  173. {
  174. [ $COMPRESSGFX = 0 ] && return
  175.  
  176. echo " -- Compressing graphics"
  177.  
  178. COMPRESSGFX_ABORT=0
  179.  
  180. if [ ! -e compressdirs ]; then
  181. echo "Package didn't provide a list of directories to compress"
  182. COMPRESSGFX_ABORT=1
  183. return 0
  184. fi
  185.  
  186. COMPRESSGFX_TEMPDIR="$(mktemp -d)"
  187. echo " - Temporary directory with original graphics to be compressed: $COMPRESSGFX_TEMPDIR"
  188.  
  189. if [ ! -e $COMPRESSGFX_TEMPDIR ]; then
  190. warning "Failed to create temporary directory! Skipping this package"
  191. COMPRESSGFX_ABORT=1
  192. return 1
  193. fi
  194.  
  195. tocompress | while read line; do
  196. dir="$(echo $line | sed -e 's@/[^/]*.tga@@')"
  197. file="$(echo $line | sed -e 's@.*/@@')"
  198.  
  199. mkdir -pv $COMPRESSGFX_TEMPDIR/$dir
  200.  
  201. echo "Compressing: $line"
  202.  
  203. if ! convert "$line" -quality $COMPRESSGFX_QUALITY "${line%%.tga}.jpg"; then
  204. warning "Failed to compress $line! Restoring the uncompressed file"
  205. fi
  206.  
  207. mv -v "$line" $COMPRESSGFX_TEMPDIR/$dir
  208. done
  209. }
  210.  
  211. function compress-restore
  212. {
  213. [ $COMPRESSGFX = 0 ] && return
  214. [ $COMPRESSGFX_ABORT = 1 ] && return
  215.  
  216. echo " -- Cleaning up after compression"
  217.  
  218. pkgdir="$PWD"
  219. pushd "$COMPRESSGFX_TEMPDIR"
  220.  
  221. find -type f | sed -e 's@^./@@' | while read line; do
  222. mv -v "$line" "$pkgdir/$line"
  223. rm -vf "$pkgdir/${line%%.tga}.jpg"
  224. done
  225.  
  226. popd
  227.  
  228. rm -rf "$COMPRESSGFX_TEMPDIR"
  229. }
  230.  
  231. function rmpack
  232. {
  233. if hascommand 7za; then
  234. 7za a -tzip -mfb258 -mpass15 "$@"
  235. elif hascommand zip; then
  236. echo zip -r "$@"
  237. zip -r "$@"
  238. else
  239. error "No usable archiver, WTF?"
  240. fi
  241. }
  242.  
  243. function makedata
  244. {
  245. local rmdata="$1"
  246. local suffix="$2"
  247. local desc="$3"
  248.  
  249. echo " -- Building client-side package $1"
  250.  
  251. pushd "$rmdata.pk3dir"
  252. rmdata="zzz-rm-$rmdata"
  253.  
  254. local sum=""
  255. if [ "$1" = "menu" ]; then
  256. sum="$MENUSUM"
  257. elif [ "$1" = "csqc" ]; then
  258. sum="$CSQCSUM"
  259. else
  260. echo " -- Calculating md5 sums"
  261. find -regex "^\./[^_].*" -type f -exec md5sum '{}' \; > _md5sums
  262. sum="$(md5sum "_md5sums" | sed -e 's/ .*//g')"
  263. fi
  264.  
  265. if [ $CACHEPKGS = 1 ] && [ -e "${CACHEDIR}/$rmdata-$sum.pk3" ]; then
  266. echo " -- A cached package with the same sum already exists, using it"
  267.  
  268. popd
  269. cp -v "${CACHEDIR}/$rmdata-$sum.pk3" "${BUILDDIR}/$rmdata-$sum.pk3"
  270. echo " -- Done"
  271.  
  272. BUILT_PACKAGES="${BUILT_PACKAGES}$rmdata-$sum.pk3 "
  273. BUILT_PKGINFOS="${BUILT_PKGINFOS}_pkginfo_$sum.txt "
  274. BUILT_PKGNAMES="${BUILT_PKGNAMES}$1 "
  275.  
  276. return
  277. fi
  278.  
  279. compress-gfx
  280.  
  281. echo " -- Writing version info"
  282. echo "RocketMinsta$2 $VERSION client-side package $1 ($3)" > _pkginfo_$sum.txt
  283. echo "Built at $BUILD_DATE" >> _pkginfo_$sum.txt
  284.  
  285. echo " -- Compressing package"
  286. if ! rmpack "/tmp/$rmdata-${BUILD_DATE_PLAIN}_tmp.zip" *; then
  287. compress-restore
  288. error "Failed to package $rmdata"
  289. fi
  290. echo " -- Removing temporary files"
  291. rm -vf _*
  292.  
  293. compress-restore
  294. popd
  295.  
  296. echo " -- Installing to ${BUILDDIR}/"
  297. mv -v "/tmp/$rmdata-${BUILD_DATE_PLAIN}_tmp.zip" "${BUILDDIR}/$rmdata-$sum.pk3"
  298.  
  299. if [ $CACHEPKGS = 1 ]; then
  300. echo " -- Copying the package to cache"
  301. cp -v "${BUILDDIR}/$rmdata-$sum.pk3" "${CACHEDIR}/"
  302. fi
  303.  
  304. echo " -- Done"
  305. BUILT_PACKAGES="${BUILT_PACKAGES}$rmdata-$sum.pk3 "
  306. BUILT_PKGINFOS="${BUILT_PKGINFOS}_pkginfo_$sum.txt "
  307. BUILT_PKGNAMES="${BUILT_PKGNAMES}$1 "
  308. }
  309.  
  310. function buildqc
  311. {
  312. qcdir="$QCSOURCE/$1"
  313.  
  314. # this is ugly, needs fixing
  315. if [ "$1" = "server/" ]; then
  316. progname="progs"
  317. elif [ "$1" = "client/" ]; then
  318. progname="csprogs"
  319. elif [ "$1" = "menu/" ]; then
  320. progname="menu"
  321. else
  322. error "$1 is unknown"
  323. fi
  324.  
  325. local sum=""
  326. if [ $CACHEQC != 0 ]; then
  327. echo " -- Calculating sum of $1..."
  328. sum="$(find "$qcdir" -type f | grep -v "fteqcc.log" | xargs md5sum | md5sum | sed -e 's/ .*//g')"
  329.  
  330. if [ "$progname" = "csprogs" ]; then # CSQC needs to know sum of menu
  331. sum="$sum.$MENUSUM"
  332. fi
  333.  
  334. if [ -e "${CACHEDIR}/qccache/$progname.dat.$sum.$COMMONSUM" ]; then
  335. echo " -- Found a cached build of $1, using it"
  336.  
  337. cp -v "${CACHEDIR}/qccache/$progname.dat.$sum.$COMMONSUM" "$progname.dat" || error "Failed to copy progs??"
  338. return
  339. fi
  340. fi
  341.  
  342. echo " -- Building $qcdir"
  343. local olddir="$PWD"
  344. pushd "$qcdir" &>/dev/null || error "Build target does not exist? huh"
  345. $USEQCC $QCCFLAGS || error "Failed to build $qcdir"
  346.  
  347. local compiled="$(cat progs.src | sed -e 's@//.*@@g' | sed -e '/^$/d' | head -1 | sed -e 's/[ \t]*$//')"
  348. local cname="$(echo "$compiled" | sed -e 's@.*/@@g')"
  349. if [ "$(readlink -f "$compiled")" != "$(readlink -f "$olddir/$cname")" ]; then
  350. cp -v "$compiled" "$olddir" || error "Failed to copy progs??"
  351. fi
  352. popd &>/dev/null
  353.  
  354. if [ $CACHEQC != 0 ]; then
  355. echo " -- Copying compilled progs to cache"
  356.  
  357. [ ! -e "${CACHEDIR}/qccache" ] && mkdir -p "${CACHEDIR}/qccache"
  358. cp -v "$progname.dat" "${CACHEDIR}/qccache/$progname.dat.$sum.$COMMONSUM" || error "WTF"
  359. fi
  360. }
  361.  
  362. function is-included
  363. {
  364. # special rule: menu package gets built after menu QC
  365. if [ $1 = "menu" ]; then
  366. return 1;
  367. fi
  368.  
  369. # special rule: csqc package gets built after client QC
  370. if [ $1 = "csqc" ]; then
  371. return 1;
  372. fi
  373.  
  374. if [ $1 = ${1##o_} ] && [ $1 = ${1##c_} ]; then
  375. # Not a prefixed package, checking if ignored
  376. for i in $IGNOREPKG; do
  377. [ $i = $1 ] && return 1;
  378. done
  379.  
  380. return 0;
  381. fi
  382.  
  383. for i in $BUILDPKG_OPTIONAL; do
  384. [ $i = ${1##o_} ] && return 0;
  385. done
  386.  
  387. for i in $BUILDPKG_CUSTOM; do
  388. [ $i = ${1##c_} ] && return 0;
  389. done
  390.  
  391. return 1
  392. }
  393.  
  394. function makedata-all
  395. {
  396. local suffix="$1"
  397. local desc="$2"
  398.  
  399. #ls | grep -P "\.pk3dir/?$" | while read line; do #damn subshells
  400. for line in $(ls | perlgrep "\.pk3dir/?$"); do
  401. is-included "$(echo $line | sed -e 's@\.pk3dir/*$@@g')" || continue
  402. makedata "$(echo $line | sed -e 's@\.pk3dir/*$@@g')" "$suffix" "$desc"
  403. done
  404. }
  405.  
  406. function listcustom
  407. {
  408. find "${BUILDDIR}/rm-custom" -maxdepth 1 -name "*.cfg" | while read cfg; do
  409. scfg="${cfg##*/}"
  410. scfg="${scfg%%.cfg}"
  411. echo -n " $scfg "
  412. for ((i=$(echo -n "$scfg" | wc -c); i <= 15; ++i)); do echo -n " "; done
  413. echo "$(head -1 "$cfg" | sed -e 's@//cfgname:@@')"
  414. done
  415. }
  416.  
  417. function finalize-install
  418. {
  419. cp -vr modfiles/* "${BUILDDIR}/"
  420.  
  421. cat <<EOF >>"${BUILDDIR}/rocketminsta.cfg"
  422. rm_clearpkgs
  423. $(for i in $BUILT_PKGINFOS; do
  424. echo "rm_putpackage $i"
  425. done)
  426. EOF
  427.  
  428. cat <<EOF >>"${BUILDDIR}/rocketminsta.cfg"
  429.  
  430. // Tells the engine to load the mod
  431. set sv_progs $(echo "$SVPROGS" | sed -e 's@.*/@@g')
  432. set csqc_progname $(echo "$CSPROGS" | sed -e 's@.*/@@g')
  433. EOF
  434. }
  435.  
  436. function configtest
  437. {
  438. if [ -n "$SUPPORT_CLIENTPKGS" ] && [ "$SUPPORT_CLIENTPKGS" == 0 ]; then
  439. error "You have SUPPORT_CLIENTPKGS disabled, but this option is no longer supported. Please find a way to let your clients download the zzz-rm packages and remove this option from your config."
  440. fi
  441.  
  442. SUPPORT_CLIENTPKGS=1
  443.  
  444. if [ "$COMPRESSGFX" != 0 ] && ! hasoptional convert; then
  445. warning "You have COMPRESSGFX on without ImageMagick installed. Compression will be DISABLED."
  446. COMPRESSGFX=0
  447. fi
  448. }
  449.  
  450. ################################################################################
  451.  
  452. [ -e "config.sh" ] || error "No configuration file found. Please run \`cp EXAMPLE_config.sh config.sh', edit config.sh and try again."
  453. . "config.sh" || error "Failed to read configuration"
  454.  
  455. if [ -z $BUILDPKG_OPTIONAL ]; then
  456. warn-oldconfig "config.sh" "BUILDPKG_OPTIONAL" "(-)"
  457. BUILDPKG_OPTIONAL=(-)
  458. fi
  459.  
  460. if [ -z $BUILDPKG_CUSTOM ]; then
  461. warn-oldconfig "config.sh" "BUILDPKG_CUSTOM" "(-)"
  462. BUILDPKG_CUSTOM=(-)
  463. fi
  464.  
  465. if [ -z $IGNOREPKG ]; then
  466. warn-oldconfig "config.sh" "IGNOREPKG" "(-)"
  467. IGNOREPKG=(-)
  468. fi
  469.  
  470. if [ -z $CACHEPKGS ]; then
  471. warn-oldconfig "config.sh" "CACHEPKGS" "0"
  472. CACHEPKGS=0
  473. fi
  474.  
  475. if [ -z $CACHEQC ]; then
  476. warn-oldconfig "config.sh" "CACHEQC" "0"
  477. CACHEQC=0
  478. fi
  479.  
  480. if [ -z $COMPRESSGFX ]; then
  481. warn-oldconfig "config.sh" "COMPRESSGFX" "1"
  482. COMPRESSGFX=1
  483. fi
  484.  
  485. if [ -z $COMPRESSGFX_QUALITY ]; then
  486. warn-oldconfig "config.sh" "COMPRESSGFX_QUALITY" "85"
  487. COMPRESSGFX_QUALITY=85
  488. fi
  489.  
  490. if [ -z ${BUILDDIR} ]; then
  491. warn-oldconfig "config.sh" "BUILDDIR" "build"
  492. BUILDDIR="build"
  493. fi
  494.  
  495. if ! [ "${LINKDIRS+test}" = "test" ]; then
  496. warn-oldconfig "config.sh" "LINKDIRS" "NEXDATA' or '$HOME/.nexuiz/data"
  497. LINKDIRS=("${NEXDATA:-${HOME}/.nexuiz/data}")
  498. fi
  499.  
  500. if [ -z ${CACHEDIR} ]; then
  501. warn-oldconfig "config.sh" "CACHEDIR" "pkgcache"
  502. CACHEDIR="pkgcache"
  503. fi
  504.  
  505. if [ -n "$BUILDNAME" ]; then
  506. BRANCH=$BUILDNAME
  507. fi
  508.  
  509. if [ -z "$PACKCSQC" ]; then
  510. warn-oldconfig "config.sh" "PACKCSQC" "1"
  511. PACKCSQC=1
  512. fi
  513.  
  514. CACHEDIR="$(readlink -f "${CACHEDIR}/")"
  515. BUILDDIR="$(readlink -f "${BUILDDIR}/")"
  516.  
  517. if [ "$1" = "cleancache" ]; then
  518. echo " -- Cleaning package cache"
  519. rm -vf "${CACHEDIR}/"*.pk3 "${CACHEDIR}/qccache/"*.dat.* || error "rm failed"
  520. exit
  521. fi
  522.  
  523. configtest
  524.  
  525. removeoldfiles
  526.  
  527. SVPROGNAME="$(echo "$SVPROGS" | sed -e 's@.*/@@g')"
  528. CSPROGNAME="$(echo "$CSPROGS" | sed -e 's@.*/@@g')"
  529. SVPROGS="$BUILDDIR/$SVPROGNAME"
  530. CSPROGS="$BUILDDIR/$CSPROGNAME"
  531.  
  532. if [ "$1" = "release" ]; then
  533. RELEASE=1
  534.  
  535. if [ -n "$2" ]; then
  536. RELCFG="_$2"
  537. fi
  538.  
  539. [ -e "releaseconfig$RELCFG.sh" ] || error "No release configuration file found. Please run \`cp EXAMPLE_releaseconfig.sh releaseconfig$RELCFG.sh', edit releaseconfig$RELCFG.sh and try again."
  540. . "releaseconfig$RELCFG.sh" || error "Failed to read release configuration"
  541.  
  542. configtest
  543.  
  544. [ -n "$RELEASE_SUFFIX" ] && RELEASE_REALSUFFIX="-$RELEASE_SUFFIX"
  545. [ z"$BRANCH" = z"master" ] || RELEASE_REALSUFFIX="-$BRANCH$RELEASE_REALSUFFIX"
  546.  
  547. if [ -n "$RELEASE_DEFAULTCFG" ]; then
  548. if [ -n "$RELEASE_REALSUFFIX" ]; then
  549. RELEASE_REALSUFFIX="${RELEASE_REALSUFFIX}_cfg$RELEASE_DEFAULTCFG"
  550. else
  551. RELEASE_REALSUFFIX="-cfg$RELEASE_DEFAULTCFG"
  552. fi
  553.  
  554. [ -e "modfiles/rm-custom/$RELEASE_DEFAULTCFG.cfg" ] || error "Default configuration '$RELEASE_DEFAULTCFG.cfg' does not exist in rm-custom"
  555. fi
  556.  
  557. PKGNAME="RocketMinsta${RELEASE_REALSUFFIX}"
  558.  
  559. if rm-hasversion; then
  560. RELEASE_PKGNAME="${PKGNAME}_$VERSION"
  561. else
  562. RELEASE_PKGNAME="${PKGNAME}_$BUILD_DATE_PLAIN"
  563. fi
  564.  
  565. RELEASE_PKGPATH="$(readlink -f "$RELEASE_PKGPATH")"
  566. mkdir "$RELEASE_PKGPATH/$RELEASE_PKGNAME" || error "Failed to create package directory"
  567.  
  568. BUILDDIR="$(readlink -f "$RELEASE_PKGPATH/$RELEASE_PKGNAME")"
  569. SVPROGS="${BUILDDIR}/$(echo "$SVPROGS" | sed -e 's@.*/@@g')"
  570. CSPROGS="${BUILDDIR}/$(echo "$CSPROGS" | sed -e 's@.*/@@g')"
  571.  
  572. checkdir "${BUILDDIR}/"
  573. makedata-all "$RELEASE_REALSUFFIX" "$RELEASE_DESCRIPTION"
  574. buildall "$RELEASE_REALSUFFIX" "$RELEASE_DESCRIPTION"
  575. finalize-install
  576.  
  577. if [ -n "$RELEASE_DEFAULTCFG" ]; then
  578. cat "modfiles/rm-custom/$RELEASE_DEFAULTCFG.cfg" >> "${BUILDDIR}/rocketminsta-gameplay.cfg"
  579. sed -i '/exec "$rm_gameplay_config"/d' "${BUILDDIR}/rocketminsta-gameplay.cfg" # Without this, a recursive include will occur
  580. fi
  581.  
  582. cp -v CHANGELOG "${BUILDDIR}/CHANGELOG.rmrelease"
  583. cp -v COPYING "${BUILDDIR}/COPYING.rmrelease"
  584. cat <<EOF > "${BUILDDIR}/README.rmrelease"
  585.  
  586. This is an auto generated $PKGNAME $VERSION release package, built at $BUILD_DATE. Installation:
  587.  
  588. 1) Extract the contents of this package into your Nexuiz data directory (typically ~/.nexuiz/data/)
  589. 2) Edit your server config and add the following line at very top:
  590.  
  591. exec rocketminsta.cfg
  592.  
  593. If you'd like to use one of the custom configurations,
  594. add the following at the bottom of your config:
  595.  
  596. rmcustom NAME_OF_CUSTOM_CONFIG
  597.  
  598. The following configurations were included at build time:
  599. $(listcustom)
  600. 3) MAKE SURE that the following packages can be autodownloaded by clients:
  601. $(for i in $BUILT_PACKAGES; do
  602. echo " $i"
  603. done)
  604.  
  605. This package contains all of them
  606. 4) Start the server and enjoy.
  607.  
  608.  
  609. RocketMinsta project: http://rocketminsta.net/
  610.  
  611. EOF
  612.  
  613. prepackage "$RELEASE_PKGPATH/$RELEASE_PKGNAME" || error "prepackage failed"
  614.  
  615. pushd "${BUILDDIR}/" &>/dev/null
  616. tar -zcvf "$RELEASE_PKGPATH/$RELEASE_PKGNAME.tar.gz" * | while read line; do
  617. echo "Adding file: $line"
  618. done
  619. popd &>/dev/null
  620.  
  621. if [ $RELEASE_CLEANUP -eq 1 ]; then
  622. rm -vrf "$RELEASE_PKGPATH/$RELEASE_PKGNAME"
  623. fi
  624.  
  625. postpackage "$RELEASE_PKGPATH/$RELEASE_PKGNAME.tar.gz" || error "postpackage failed"
  626.  
  627. cat <<EOF
  628. **************************************************
  629.  
  630. Finished $PKGNAME release
  631.  
  632. Package path:
  633. $RELEASE_PKGPATH/$RELEASE_PKGNAME.tar.gz
  634.  
  635. **************************************************
  636. EOF
  637.  
  638. exit
  639. fi
  640.  
  641. PREFIX="-$BRANCH"
  642. [ $PREFIX = "-master" ] && PREFIX=""
  643.  
  644. checkdir "${BUILDDIR}/"
  645. makedata-all "$PREFIX" "git build"
  646. buildall "$PREFIX" "git build"
  647. finalize-install
  648. linkfiles
  649.  
  650. cat <<EOF
  651. **************************************************
  652.  
  653. RocketMinsta has been built successfully
  654.  
  655. Server QC progs:
  656. $SVPROGS
  657.  
  658. Client QC progs:
  659. $CSPROGS
  660.  
  661. CVAR defaults for server configuration:
  662. ${BUILDDIR}/rocketminsta.cfg
  663.  
  664. Optional custom configurations:
  665. ${BUILDDIR}/rm-custom
  666. $(listcustom)
  667.  
  668. Please make sure all of these files are accessible by Nexuiz.
  669. Then add the following line at top of your server config:
  670.  
  671. exec rocketminsta.cfg
  672.  
  673. If you'd like to use one of the custom configurations,
  674. add the following at the bottom of your config:
  675.  
  676. rmcustom NAME_OF_CUSTOM_CONFIG
  677.  
  678. In addition, these packages MUST be available on your download server:
  679. $(for i in $BUILT_PACKAGES;
  680. do echo " $i";
  681. done)
  682.  
  683. All of them have been also installed into:
  684. ${BUILDDIR}/
  685.  
  686. They will be added to sv_curl_serverpackages automatically.
  687.  
  688. **************************************************
  689. EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement