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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #!/bin/bash
  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/working/nightly"
  10. # Path to scripts
  11. SCRIPTDIR="/home/dmdirc/scripts"
  12. # Path to ant binary
  13. ANT="/usr/bin/ant"
  14. # Path to git binary
  15. GIT="/usr/bin/git"
  16. # Path to jar binary
  17. JAR="/usr/bin/jar"
  18. cd ${MYDIR}
  19. if [ -d .git ]; then
  20. $GIT reset --hard
  21. $GIT checkout master
  22. $GIT pull
  23. $GIT submodule init
  24. $GIT submodule update
  25. GITREV=`$GIT describe`
  26. else
  27. echo "GIT Directory not found."
  28. exit 1;
  29. fi;
  30. export DMDIRC_GIT=${GITREV}
  31. # Archive old nightlies
  32. if [ `date +%d` = "01" ]; then
  33. echo "Archiving last month's nightlies..."
  34. OLDDIR=${WWWDIR}/nightly/old/`date -d yesterday +%B%y | tr "[:upper:]" "[:lower:]"`
  35. mkdir -p ${OLDDIR}
  36. mv -fv ${WWWDIR}/nightly/*_`date -d yesterday +%Y%m`??_* ${OLDDIR}
  37. mv -fv ${WWWDIR}/nightly/*-`date -d yesterday +%Y%m`??_* ${OLDDIR}
  38. rm -Rf ${WWWDIR}/nightly/*_latest*
  39. fi
  40. # The date/git rev to add to the end of the file names of stuff
  41. FILEDATA=`date +%Y%m%d`_${GITREV}
  42. # Force rebuild of plugins.
  43. export REBUILDPLUGINS="true"
  44. # Build plugins/jar
  45. $ANT -Dchannel=NIGHTLY -k clean jar
  46. PHP=`which php`
  47. # Check if build failed
  48. if [ ! -e "$MYDIR/dist/DMDirc.jar" ]; then
  49. # Report failure
  50. echo "Build failure"
  51. if [ -e "$SCRIPTDIR/nightly-failure.php" -a "${PHP}" != "" ]; then
  52. $PHP -q $SCRIPTDIR/nightly-failure.php
  53. fi
  54. else
  55. # Build installers
  56. # Delete all automatically added plugins from the jar to allow the installer
  57. # to add its own on a per-os basis
  58. # unzip -l "${MYDIR}/dist/DMDirc.jar" | grep " plugins/" | tr -s ' ' | cut -d ' ' -f 5- | xargs zip "${MYDIR}/dist/DMDirc.jar" -d
  59. # Temporary, add certain plugins back in as the installer builds no
  60. # longer add any at all
  61. # cd "${MYDIR}"
  62. #$JAR -uvf "${MYDIR}/dist/DMDirc.jar" plugins/ui_swing.jar plugins/tabcompletion_bash.jar plugins/tabcompletion_mirc.jar plugins/parser_irc.jar
  63. # Build files automatically do the above, so lets just not remove them for now.
  64. cd "${MYDIR}/modules/installer"
  65. PACKAGENAME="DMDirc-Nightly"
  66. ./makeAll.sh --extra "${FILEDATA}" --packagename "${PACKAGENAME}" --jar "${MYDIR}/dist/DMDirc.jar" --version "${GITREV}"
  67. cd "${MYDIR}"
  68. OUTPUTDIR="${MYDIR}/modules/installer/output"
  69. if [ ! -e "${OUTPUTDIR}/${PACKAGENAME}-${FILEDATA}.exe" -o ! -e "${OUTPUTDIR}/${PACKAGENAME}-${FILEDATA}.deb" -o ! -e "${OUTPUTDIR}/${PACKAGENAME}-${FILEDATA}.dmg" -o ! -e "${OUTPUTDIR}/${PACKAGENAME}-${FILEDATA}.jar" ]; then
  70. # Report failure
  71. echo "Installer build failure."
  72. if [ -e "$SCRIPTDIR/nightly-failure.php" -a "${PHP}" != "" ]; then
  73. export DMDIRC_INSTALLERFAILURE=true;
  74. export BAMBOO_BUILD;
  75. $PHP -q $SCRIPTDIR/nightly-failure.php
  76. fi
  77. fi;
  78. # Re-add all plugins to the jar so that the nightly .jar has everything.
  79. # $JAR -uvf "${OUTPUTDIR}/${PACKAGENAME}-${FILEDATA}.jar" plugins
  80. function handleNightly() {
  81. PACKAGENAME="${1}"
  82. FILEDATA="${2}"
  83. EXT="${3}"
  84. mv -v "${OUTPUTDIR}/${PACKAGENAME}-${FILEDATA}.${EXT}" "${WWWDIR}/nightly/${PACKAGENAME}-${FILEDATA}.${EXT}"
  85. if [ -e "${WWWDIR}/nightly/${PACKAGENAME}-${FILEDATA}.${EXT}" ]; then
  86. ln -sfv "${WWWDIR}/nightly/${PACKAGENAME}-${FILEDATA}.${EXT}" "${WWWDIR}/nightly/${PACKAGENAME}_latest.${EXT}"
  87. fi;
  88. }
  89. handleNightly "${PACKAGENAME}" "${FILEDATA}" "exe"
  90. handleNightly "${PACKAGENAME}" "${FILEDATA}" "dmg"
  91. handleNightly "${PACKAGENAME}" "${FILEDATA}" "deb"
  92. handleNightly "${PACKAGENAME}" "${FILEDATA}" "rpm"
  93. ## Add to apt repo.
  94. REPREPRO=`which reprepro`
  95. if [ "" != "${REPREPRO}" -a -e "/home/dmdirc/www/apt/" ]; then
  96. ${REPREPRO} -V -C dmdirc-nightly -b /home/dmdirc/www/apt/ includedeb all ${WWWDIR}/nightly/${PACKAGENAME}-${FILEDATA}.deb
  97. fi;
  98. # Jars get a different name for some reason.
  99. mv -v "${OUTPUTDIR}/${PACKAGENAME}-${FILEDATA}.jar" "${WWWDIR}/nightly/DMDirc_${FILEDATA}.jar"
  100. if [ -e "${WWWDIR}/nightly/DMDirc_${FILEDATA}.jar" ]; then
  101. ln -sfv "${WWWDIR}/nightly/DMDirc_${FILEDATA}.jar" "${WWWDIR}/nightly/DMDirc_latest.jar"
  102. fi;
  103. # # Update Launchers
  104. # cd ${MYDIR}/launcher
  105. # sh ${MYDIR}/launcher/createUpdate.sh
  106. fi