From d07c9d37240f3cc461a3878484b79788ce4c89bf Mon Sep 17 00:00:00 2001 From: Donald Curtis Date: Mon, 7 Jan 2013 10:22:58 -0600 Subject: [PATCH] add build script --- scripts/build | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 scripts/build diff --git a/scripts/build b/scripts/build new file mode 100755 index 00000000..8895a52e --- /dev/null +++ b/scripts/build @@ -0,0 +1,60 @@ +#!/bin/bash + +function melpa { + + date "+%Y%m%d %H:%M" + + date "+%Y%m%d %H:%M" > $HOME/www/status.txt + echo "building..." >> $HOME/www/status.txt + + MELPADIR=${MELPADIR:-$HOME/melpa} + MELPABRANCH=${MELPABRANCH:-master} + WEBROOT=${WEBROOT:-$HOME/www} + + PATH=$HOME/.cabal/bin:$HOME/usr/bin:$HOME/bin:$PATH + + [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" + + ENVLOG=$HOME/log/melpaenv.log + env > ${ENVLOG} + + STDOUT=`mktemp` + STDERR=`mktemp` + + ## git pull + cd ${MELPADIR} + git pull origin ${MELPABRANCH} &>> ${STDOUT} + echo >> ${STDOUT} + + MELPASTDOUT=`mktemp` + + ## run the script + cd ${MELPADIR} + make 1>> ${MELPASTDOUT} 2>> ${STDERR} + + ## sync to the web directory + rsync -avz --delete ${MELPADIR}/packages ${MELPADIR}/html/{index.html,updates.rss,highlight.pack.js,style.css,styles,languages} ${WEBROOT}/ 1>> ${STDOUT} 2>> ${STDERR} + + chmod -R go+r ${WEBROOT}/packages/* + chmod -R go-x ${WEBROOT}/packages/* + + /usr/sbin/logrotate -s $HOME/log/logrotate.state $HOME/log/melpa.logrotate 1>> ${STDOUT} 2>> ${STDERR} + + EMAIL=`mktemp` + echo "Subject: Melpa status `date '+%Y-%m-%d %H:%M:%S'`" > ${EMAIL} + cat ${MELPASTDOUT} ${STDOUT} ${ENVLOG} ${STDERR} >> ${EMAIL} + + /usr/sbin/sendmail dcurtis@milkbox.net < ${EMAIL} + cat ${ENVLOG} ${STDERR} ${STDOUT} | tee $WEBROOT/lastrun.txt + + date "+%Y%m%d %H:%M" > $HOME/www/status.txt + echo "completed" >> $HOME/www/status.txt +} + +if [[ `cat $HOME/www/updatemelpa.txt` == 1 ]] ; then + echo "Running MELPA" + echo "2" > $HOME/www/updatemelpa.txt + melpa + echo "0" > $HOME/www/updatemelpa.txt +fi +