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.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. # Where are the bamboo log files?
  21. BAMBOO=/home/dmdirc/Bamboo/xml-data/builds/DMDIRC-NIGHTLY/download-data/build_logs/
  22. cd ${MYDIR}
  23. if [ -d .git ]; then
  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. if [ "${BAMBOO_INSTALL}" != "" -a -e "${BAMBOO}" ]; then
  66. export BAMBOO_DIR=${BAMBOO};
  67. export BAMBOO_BUILD=`ls -cr1 ${BAMBOO} | tail -n 1 | awk -F. '{print $1}'`
  68. echo "This is Bamboo build "${BAMBOO_BUILD};
  69. fi
  70. # Check if build failed
  71. if [ ! -e "$MYDIR/dist/DMDirc.jar" ]; then
  72. # Report failure
  73. echo "Build Failure."
  74. if [ -e "$SCRIPTDIR/nightly-failure.php" -a "${PHP}" != "" ]; then
  75. $PHP -q $SCRIPTDIR/nightly-failure.php
  76. fi
  77. else
  78. # Build installers
  79. # Delete all automatically added plugins from the jar to allow the installer
  80. # to add its own on a per-os basis
  81. unzip -l ${MYDIR}/dist/DMDirc.jar | grep " plugins/" | tr -s ' ' | cut -d ' ' -f 5- | xargs zip ${MYDIR}/dist/DMDirc.jar -d
  82. cd "${MYDIR}/installer"
  83. ./release.sh --jar "${MYDIR}/dist/DMDirc.jar" --opt "--extra ${FILEDATA}" trunk
  84. cd "${MYDIR}"
  85. 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
  86. # Report failure
  87. echo "Installer Build Failure."
  88. if [ -e "$SCRIPTDIR/nightly-failure.php" -a "${PHP}" != "" ]; then
  89. export DMDIRC_INSTALLERFAILURE=true;
  90. export BAMBOO_BUILD;
  91. $PHP -q $SCRIPTDIR/nightly-failure.php
  92. fi
  93. fi;
  94. # Re-Add all plugins to the jar so that the nightly .jar has everything.
  95. $JAR -uvf "dist/DMDirc.jar" plugins
  96. # Submit plugins to addons site
  97. if [ -e "${HOME}/www/addons/submitplugin.php" ]; then
  98. for plugin in `ls plugins/*.jar`; do
  99. $PHP ${HOME}/www/addons/submitplugin.php $plugin
  100. done;
  101. fi;
  102. # Move installers/jar to nightlies site
  103. FILENAME=DMDirc_${FILEDATA}.jar
  104. mv "installer/output/DMDirc-Setup-${FILEDATA}.exe" "${WWWDIR}/nightly/DMDirc-Setup-${FILEDATA}.exe"
  105. mv "installer/output/DMDirc-Setup-${FILEDATA}.run" "${WWWDIR}/nightly/DMDirc-Setup-${FILEDATA}.run"
  106. mv "installer/output/DMDirc-${FILEDATA}.dmg" "${WWWDIR}/nightly/DMDirc-${FILEDATA}.dmg"
  107. rm -Rf "installer/output/DMDirc-${FILEDATA}.jar"
  108. cp dist/DMDirc.jar /home/dmdirc/www/nightly/$FILENAME
  109. if [ -e "${WWWDIR}/nightly/${FILENAME}" ]; then
  110. ln -sf ${WWWDIR}/nightly/${FILENAME} $WWWDIR/nightly/DMDirc_latest.jar
  111. fi;
  112. if [ -e "${WWWDIR}/nightly/DMDirc-Setup-${FILEDATA}.run" ]; then
  113. ln -sf "${WWWDIR}/nightly/DMDirc-Setup-${FILEDATA}.run" $WWWDIR/nightly/DMDirc-Setup_latest.run
  114. fi;
  115. if [ -e "${WWWDIR}/nightly/DMDirc-Setup-${FILEDATA}.exe" ]; then
  116. ln -sf "${WWWDIR}/nightly/DMDirc-Setup-${FILEDATA}.exe" $WWWDIR/nightly/DMDirc-Setup_latest.exe
  117. fi;
  118. if [ -e "${WWWDIR}/nightly/DMDirc-${FILEDATA}.dmg" ]; then
  119. ln -sf "${WWWDIR}/nightly/DMDirc-${FILEDATA}.dmg" $WWWDIR/nightly/DMDirc_latest.dmg
  120. fi;
  121. # Do normal reports
  122. if [ "${IS_BAMBOO}" == "" ]; then
  123. /bin/sh $MYDIR/DoReports.sh
  124. fi;
  125. fi
  126. if [ -d .git ]; then
  127. $GIT checkout src/com/dmdirc/Main.java
  128. else
  129. $SVN revert src/com/dmdirc/Main.java
  130. fi;