You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BuildAll.sh 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #!/bin/sh
  2. # cron doesn't seem to like doing this iself...
  3. . /etc/profile
  4. # Used for nightly.log to help diagnosing problems
  5. env
  6. # Path to WWW Directory
  7. WWWDIR="/home/dmdirc/www"
  8. # Path to trunk
  9. MYDIR="/home/dmdirc/google"
  10. # Path to scripts
  11. SCRIPTDIR="/home/dmdirc/scripts"
  12. # Path to ant binary
  13. ANT="/usr/bin/ant"
  14. # Path to svn binary
  15. SVN="/usr/bin/svn"
  16. # Path to git binary
  17. GIT="/usr/bin/git"
  18. # Path to jar binary
  19. JAR="/usr/bin/jar"
  20. cd ${MYDIR}
  21. if [ -d .git ]; then
  22. $GIT reset --hard
  23. $GIT checkout master
  24. $GIT pull
  25. SVNREV=`$GIT describe`
  26. else
  27. $SVN update
  28. SVNREV=`$SVN info | grep Revision`
  29. SVNREV=${SVNREV##*: }
  30. fi;
  31. export DMDIRC_SVN=${SVNREV}
  32. # Archive old nightlies
  33. if [ `date +%d` = "01" ]; then
  34. echo "Archiving Last Months Nightlies"
  35. OLDDIR=${WWWDIR}/nightly/old/`date -d yesterday +%B%y | tr "[:upper:]" "[:lower:]"`
  36. mkdir -p ${OLDDIR}
  37. mv -fv ${WWWDIR}/nightly/*_`date -d yesterday +%Y%m`??_* ${OLDDIR}
  38. mv -fv ${WWWDIR}/nightly/*-`date -d yesterday +%Y%m`??_* ${OLDDIR}
  39. rm -Rf ${WWWDIR}/nightly/*_latest*
  40. fi
  41. # The date/svn prefix to add to the end of the file names of stuff
  42. FILEDATA=`date +%Y%m%d`_${SVNREV}
  43. # Copy default settings from www to trunk for compile (if they exist)
  44. REVERTLIST=""
  45. if [ -e "${HOME}/www/updates/" ]; then
  46. for updatedir in `ls -1 src/com/dmdirc/config/defaults/`; do
  47. src="${HOME}/www/updates/${updatedir}"
  48. if [ -e ${src} ]; then
  49. REVERTLIST=${REVERTLIST}" src/com/dmdirc/config/defaults/${updatedir}/"
  50. cp -Rfv ${src}/* src/com/dmdirc/config/defaults/${updatedir}/
  51. fi;
  52. done
  53. fi;
  54. # Build plugins/jar
  55. $ANT -Dchannel=NIGHTLY -k clean jar
  56. # Now revert the trunk so as not to break updates.
  57. if [ -d .git ]; then
  58. ${GIT} checkout src/com/dmdirc/config/defaults/;
  59. else
  60. for updatedir in ${REVERTLIST}; do
  61. ${SVN} revert ${updatedir}/*
  62. done;
  63. fi;
  64. PHP=`which php`
  65. # Check if build failed
  66. if [ ! -e "$MYDIR/dist/DMDirc.jar" ]; then
  67. # Report failure
  68. echo "Build Failure."
  69. if [ -e "$SCRIPTDIR/nightly-failure.php" -a "${PHP}" != "" ]; then
  70. $PHP -q $SCRIPTDIR/nightly-failure.php
  71. fi
  72. else
  73. # Build installers
  74. # Delete all automatically added plugins from the jar to allow the installer
  75. # to add its own on a per-os basis
  76. unzip -l ${MYDIR}/dist/DMDirc.jar | grep " plugins/" | tr -s ' ' | cut -d ' ' -f 5- | xargs zip ${MYDIR}/dist/DMDirc.jar -d
  77. cd "${MYDIR}/installer"
  78. ./release.sh --jar "${MYDIR}/dist/DMDirc.jar" --opt "--extra ${FILEDATA}" trunk
  79. cd "${MYDIR}"
  80. if [ ! -e "${MYDIR}/installer/output/DMDirc-Setup-${FILEDATA}.exe" -o ! -e "${MYDIR}/installer/output/DMDirc-Setup-${FILEDATA}.run" -o ! -e "${MYDIR}/installer/output/DMDirc-${FILEDATA}.dmg" -o ! -e "${MYDIR}/installer/output/DMDirc-${FILEDATA}.jar" ]; then
  81. # Report failure
  82. echo "Installer Build Failure."
  83. if [ -e "$SCRIPTDIR/nightly-failure.php" -a "${PHP}" != "" ]; then
  84. export DMDIRC_INSTALLERFAILURE=true;
  85. export BAMBOO_BUILD;
  86. $PHP -q $SCRIPTDIR/nightly-failure.php
  87. fi
  88. fi;
  89. # Re-Add all plugins to the jar so that the nightly .jar has everything.
  90. $JAR -uvf "dist/DMDirc.jar" plugins
  91. # Submit plugins to addons site
  92. if [ -e "${HOME}/www/addons/submitplugin.php" ]; then
  93. for plugin in `ls plugins/*.jar`; do
  94. $PHP ${HOME}/www/addons/submitplugin.php $plugin
  95. done;
  96. fi;
  97. # Move installers/jar to nightlies site
  98. FILENAME=DMDirc_${FILEDATA}.jar
  99. mv "installer/output/DMDirc-Setup-${FILEDATA}.exe" "${WWWDIR}/nightly/DMDirc-Setup-${FILEDATA}.exe"
  100. mv "installer/output/DMDirc-Setup-${FILEDATA}.run" "${WWWDIR}/nightly/DMDirc-Setup-${FILEDATA}.run"
  101. mv "installer/output/DMDirc-${FILEDATA}.dmg" "${WWWDIR}/nightly/DMDirc-${FILEDATA}.dmg"
  102. rm -Rf "installer/output/DMDirc-${FILEDATA}.jar"
  103. cp dist/DMDirc.jar /home/dmdirc/www/nightly/$FILENAME
  104. if [ -e "${WWWDIR}/nightly/${FILENAME}" ]; then
  105. ln -sf ${WWWDIR}/nightly/${FILENAME} $WWWDIR/nightly/DMDirc_latest.jar
  106. fi;
  107. if [ -e "${WWWDIR}/nightly/DMDirc-Setup-${FILEDATA}.run" ]; then
  108. ln -sf "${WWWDIR}/nightly/DMDirc-Setup-${FILEDATA}.run" $WWWDIR/nightly/DMDirc-Setup_latest.run
  109. fi;
  110. if [ -e "${WWWDIR}/nightly/DMDirc-Setup-${FILEDATA}.exe" ]; then
  111. ln -sf "${WWWDIR}/nightly/DMDirc-Setup-${FILEDATA}.exe" $WWWDIR/nightly/DMDirc-Setup_latest.exe
  112. fi;
  113. if [ -e "${WWWDIR}/nightly/DMDirc-${FILEDATA}.dmg" ]; then
  114. ln -sf "${WWWDIR}/nightly/DMDirc-${FILEDATA}.dmg" $WWWDIR/nightly/DMDirc_latest.dmg
  115. fi;
  116. # Do normal reports
  117. if [ "${IS_BAMBOO}" == "" ]; then
  118. /bin/sh $MYDIR/DoReports.sh
  119. fi;
  120. fi
  121. if [ -d .git ]; then
  122. $GIT checkout src/com/dmdirc/Main.java
  123. else
  124. $SVN revert src/com/dmdirc/Main.java
  125. fi;