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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 jar binary
  17. JAR="/usr/bin/jar"
  18. cd ${MYDIR}
  19. /bin/sh $MYDIR/oblong.sh "Nightly Build" "Build Started"
  20. cd $MYDIR/
  21. $SVN update
  22. SVNREV=`$SVN info | grep Revision`
  23. SVNREV=${SVNREV##*: }
  24. export DMDIRC_SVN=${SVNREV}
  25. # Substitute the version string
  26. awk '{gsub(/String VERSION = "SVN ("+SVN_REVISION+")"/,"String VERSION = \"Nightly - SVN Rev: '${SVNREV}'\"");print}' ${MYDIR}/src/com/dmdirc/Main.java > ${MYDIR}/src/com/dmdirc/Main.java.tmp
  27. mv ${MYDIR}/src/com/dmdirc/Main.java.tmp ${MYDIR}/src/com/dmdirc/Main.java
  28. # Substitute the update channel
  29. awk '{gsub(/UpdateChannel UPDATE_CHANNEL = UpdateChannel.NONE/,"UpdateChannel UPDATE_CHANNEL = UpdateChannel.NIGHTLY");print}' ${MYDIR}/src/com/dmdirc/Main.java > ${MYDIR}/src/com/dmdirc/Main.java.tmp
  30. mv ${MYDIR}/src/com/dmdirc/Main.java.tmp ${MYDIR}/src/com/dmdirc/Main.java
  31. # This no longer exists
  32. ## Substitue the release date
  33. #awk '{gsub(/int RELEASE_DATE = 0/,"int RELEASE_DATE = '`date +%Y%m%d`'");print}' ${MYDIR}/src/com/dmdirc/Main.java > ${MYDIR}/src/com/dmdirc/Main.java.tmp
  34. #mv ${MYDIR}/src/com/dmdirc/Main.java.tmp ${MYDIR}/src/com/dmdirc/Main.java
  35. # Archive old nightlies
  36. if [ `date +%d` = "01" ]; then
  37. echo "Archiving Last Months Nightlies"
  38. OLDDIR=${WWWDIR}/nightly/old/`date -d yesterday +%B%y | tr "[:upper:]" "[:lower:]"`
  39. mkdir -p ${OLDDIR}
  40. mv -fv ${WWWDIR}/nightly/*_`date -d yesterday +%Y%m`??_* ${OLDDIR}
  41. mv -fv ${WWWDIR}/nightly/*-`date -d yesterday +%Y%m`??_* ${OLDDIR}
  42. rm -Rf ${WWWDIR}/nightly/*_latest*
  43. fi
  44. # The date/svn prefix to add to the end of the file names of stuff
  45. FILEDATA=`date +%Y%m%d`_${SVNREV}
  46. # Copy default settings from www to trunk for compile (if they exist)
  47. REVERTLIST=""
  48. if [ -e "${HOME}/www/updates/" ]; then
  49. for updatedir in `ls -1 src/com/dmdirc/config/defaults/`; do
  50. src="${HOME}/www/updates/${updatedir}"
  51. if [ -e ${src} ]; then
  52. REVERTLIST=${REVERTLIST}" src/com/dmdirc/config/defaults/${updatedir}/"
  53. cp -Rfv ${src}/* src/com/dmdirc/config/defaults/${updatedir}/
  54. fi;
  55. done
  56. fi;
  57. # Build plugins/jar
  58. $ANT -buildfile $MYDIR/build.xml -k clean jar
  59. # Now revert the trunk so as not to break updates.
  60. for updatedir in ${REVERTLIST}; do
  61. ${SVN} revert ${updatedir}/*
  62. done;
  63. PHP=`which php`
  64. # Check if build failed
  65. if [ ! -e "$MYDIR/dist/DMDirc.jar" ]; then
  66. # Report failure
  67. if [ -e "$SCRIPTDIR/nightly-failure.php" -a "${PHP}" != "" ]; then
  68. $PHP -q $SCRIPTDIR/nightly-failure.php
  69. fi
  70. else
  71. # Build installers
  72. cd "${MYDIR}/installer"
  73. ./release.sh --jar "${MYDIR}/dist/DMDirc.jar" --opt "--tag ${FILEDATA}" trunk
  74. cd "${MYDIR}"
  75. 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
  76. # Report failure
  77. if [ -e "$SCRIPTDIR/nightly-failure.php" -a "${PHP}" != "" ]; then
  78. export DMDIRC_INSTALLERFAILURE=true;
  79. $PHP -q $SCRIPTDIR/nightly-failure.php
  80. fi
  81. fi;
  82. # Add plugins to jar
  83. $JAR -uvf "dist/DMDirc.jar" plugins
  84. # Submit plugins to addons site
  85. if [ -e "${HOME}/www/addons/submitplugin.php" ]; then
  86. for plugin in `ls plugins/*.jar`; do
  87. $PHP ${HOME}/www/addons/submitplugin.php $plugin
  88. done;
  89. fi;
  90. # Move installers/jar to nightlies site
  91. FILENAME=DMDirc_${FILEDATA}.jar
  92. mv "${MYDIR}/installer/output/DMDirc-Setup-${FILEDATA}.exe" "${WWWDIR}/nightly/DMDirc-Setup-${FILEDATA}.exe"
  93. mv "${MYDIR}/installer/output/DMDirc-Setup-${FILEDATA}.run" "${WWWDIR}/nightly/DMDirc-Setup-${FILEDATA}.run"
  94. mv "${MYDIR}/installer/output/DMDirc-${FILEDATA}.dmg" "${WWWDIR}/nightly/DMDirc-${FILEDATA}.dmg"
  95. rm -Rf "${MYDIR}/installer/output/DMDirc-${FILEDATA}.jar"
  96. cp $MYDIR/dist/DMDirc.jar /home/dmdirc/www/nightly/$FILENAME
  97. if [ -e "${WWWDIR}/nightly/${FILENAME}" ]; then
  98. ln -sf ${WWWDIR}/nightly/${FILENAME} $WWWDIR/nightly/DMDirc_latest.jar
  99. fi;
  100. if [ -e "${WWWDIR}/nightly/DMDirc-Setup-${FILEDATA}.run" ]; then
  101. ln -sf "${WWWDIR}/nightly/DMDirc-Setup-${FILEDATA}.run" $WWWDIR/nightly/DMDirc-Setup_latest.run
  102. fi;
  103. if [ -e "${WWWDIR}/nightly/DMDirc-Setup-${FILEDATA}.exe" ]; then
  104. ln -sf "${WWWDIR}/nightly/DMDirc-Setup-${FILEDATA}.exe" $WWWDIR/nightly/DMDirc-Setup_latest.exe
  105. fi;
  106. if [ -e "${WWWDIR}/nightly/DMDirc-${FILEDATA}.dmg" ]; then
  107. ln -sf "${WWWDIR}/nightly/DMDirc-${FILEDATA}.dmg" $WWWDIR/nightly/DMDirc_latest.dmg
  108. fi;
  109. cd ${MYDIR}
  110. # /bin/sh $MYDIR/oblong.sh "Nightly Build" "Build Successful";
  111. # Do normal reports
  112. /bin/sh $MYDIR/DoReports.sh
  113. fi
  114. $SVN revert ${MYDIR}/src/com/dmdirc/Main.java