2011-09-01 20:11:22 +00:00
#!/bin/bash
2009-10-01 04:36:05 +00:00
# some paths
2010-05-25 10:47:52 +00:00
top = /var/www/synthesis/eduke32
lockfile = $top /synthesis_building
source = eduke32
2009-10-01 06:31:22 +00:00
output = /var/www/dukeworld.duke4.net/eduke32/synthesis
2012-11-25 16:04:07 +00:00
make = ( make PLATFORM = WINDOWS CC = 'i586-mingw32msvc-gcc' CXX = 'i586-mingw32msvc-g++' AS = 'nasm' RC = 'i586-mingw32msvc-windres' STRIP = 'i586-mingw32msvc-strip' AR = 'i586-mingw32msvc-ar' RANLIB = 'i586-mingw32msvc-ranlib' PRETTY_OUTPUT = 0 NEDMALLOC = 0 )
2009-10-01 04:36:05 +00:00
clean = veryclean
2009-10-18 02:59:31 +00:00
2009-10-01 04:36:05 +00:00
# the following file paths are relative to $source
2012-11-26 08:23:20 +00:00
targets = ( eduke32.exe mapster32.exe )
package = package
2012-03-04 09:33:23 +00:00
not_src_packaged = ( psd source/jaudiolib/third-party/vorbis.framework/Versions/A/vorbis Apple/lib )
2009-10-01 04:36:05 +00:00
2009-10-18 02:59:31 +00:00
# group that owns the resulting packages
group = dukeworld
2009-10-01 04:36:05 +00:00
# some variables
dobuild =
2010-05-25 10:47:52 +00:00
# controls resulting package filenames... will support linux later
basename = eduke32
platform = win32
2009-10-01 04:36:05 +00:00
# if the output dir doesn't exist, create it
if [ ! -e $output ]
then
mkdir -p $output
fi
2010-05-25 10:47:52 +00:00
if [ -f $lockfile ]
then
echo "Build already in progress!"
exit
else
touch $lockfile
fi
2009-10-01 04:36:05 +00:00
cd $top
2010-05-25 10:47:52 +00:00
# update the code repository and get the last revision number from SVN
2009-10-01 04:36:05 +00:00
head = ` svn update | tail -n1 | awk '{ print $NF }' | cut -d. -f1`
echo " HEAD is revision $head . "
2011-07-21 23:45:12 +00:00
lastrevision = ` ls -A1 $output /????????-???? | tail -n1 | cut -d- -f2 | cut -d. -f1`
2009-10-01 04:36:05 +00:00
# if the output dir is empty, we build no matter what
if [ ! $lastrevision ]
then
echo "No builds yet."
dobuild = 1
else
echo " Last built revision is $lastrevision . "
2010-05-25 10:47:52 +00:00
2009-10-01 04:36:05 +00:00
# if the last built revision is less than HEAD, we also build
if [ $lastrevision -lt $head ]
then
echo "Need a new build."
dobuild = 1
fi
fi
if [ $dobuild ]
then
echo "Launching a build..."
2010-10-19 04:39:54 +00:00
2009-10-01 06:31:22 +00:00
cd $top /$source
2010-10-19 04:39:54 +00:00
2011-03-04 09:29:54 +00:00
# throw the svn revision into a header. this is ugly.
2012-11-05 02:49:08 +00:00
echo " s_buildRev = \"r $head \"; " > source/rev.h
2011-07-21 23:45:12 +00:00
2010-10-19 04:39:54 +00:00
# clean the tree and build debug first
echo " ${ make [@] } " RELEASE = 0 $clean all
" ${ make [@] } " RELEASE = 0 $clean all
# make sure all the targets were produced
for i in " ${ targets [@] } " ; do
if [ ! -e $i ]
then
echo "Build failed! Bailing out..."
rm -r $lockfile
exit
fi
done
2012-11-26 08:23:20 +00:00
# move the targets to $package
echo mv -f eduke32.exe " $package /eduke32.debug.exe "
mv -f eduke32.exe " $package /eduke32.debug.exe "
echo mv -f mapster32.exe " $package /mapster32.debug.exe "
mv -f mapster32.exe " $package /mapster32.debug.exe "
echo mv -f ebacktrace1.dll " $package /ebacktrace1.dll "
mv -f ebacktrace1.dll " $package /ebacktrace1.dll "
2010-10-19 04:39:54 +00:00
# clean the tree and build release
2010-05-25 10:47:52 +00:00
echo " ${ make [@] } " $clean all
" ${ make [@] } " $clean all
2010-10-19 04:39:54 +00:00
2009-10-01 04:36:05 +00:00
# make sure all the targets were produced
for i in " ${ targets [@] } " ; do
if [ ! -e $i ]
then
2010-05-25 10:47:52 +00:00
echo "Build failed! Bailing out..."
rm -r $lockfile
exit
2009-10-01 04:36:05 +00:00
fi
done
2010-10-19 04:39:54 +00:00
2012-11-26 08:23:20 +00:00
# move the targets to $package
echo mv -f eduke32.exe " $package /eduke32.exe "
mv -f eduke32.exe " $package /eduke32.exe "
echo mv -f mapster32.exe " $package /mapster32.exe "
mv -f mapster32.exe " $package /mapster32.exe "
2011-10-02 07:47:18 +00:00
2009-10-01 04:36:05 +00:00
# get the date in the YYYYMMDD format (ex: 20091001)
date = ` date +%Y%m%d`
2010-05-25 10:47:52 +00:00
2009-10-01 04:36:05 +00:00
# create the output directory
mkdir $output /$date -$head
2010-05-25 10:47:52 +00:00
2009-10-01 04:36:05 +00:00
# package the binary snapshot
2012-11-26 08:23:20 +00:00
cd $package
echo zip -r -y -9 $output /$date -$head /${ basename } _${ platform } _$date -$head .zip * -x "*.svn*"
zip -r -y -9 $output /$date -$head /${ basename } _${ platform } _$date -$head .zip * -x "*.svn*"
cd $top /$source
2011-07-21 23:45:12 +00:00
2009-10-01 04:36:05 +00:00
# hack to restore [e]obj/keep.me
echo svn update -r $head
svn update -r $head
2010-05-25 10:47:52 +00:00
2009-10-01 04:36:05 +00:00
# export the source tree into the output directory
2010-05-25 11:26:09 +00:00
svn export . $output /$date -$head /${ basename } _$date -$head
echo svn export . $output /$date -$head /${ basename } _$date -$head
2010-05-25 10:47:52 +00:00
2009-10-01 04:36:05 +00:00
# package the source
cd $output /$date -$head
2010-05-25 10:47:52 +00:00
2009-10-01 06:31:22 +00:00
# first remove the unnecessary files
for i in " ${ not_src_packaged [@] } " ; do
2010-05-25 11:26:09 +00:00
echo rm -r ${ basename } _$date -$head /$i
rm -r ${ basename } _$date -$head /$i
2009-10-01 06:31:22 +00:00
done
2010-05-25 10:47:52 +00:00
2010-05-25 11:26:09 +00:00
echo tar cjf ${ basename } _src_$date -$head .tar.bz2 ${ basename } _$date -$head
tar cjf ${ basename } _src_$date -$head .tar.bz2 ${ basename } _$date -$head
rm -r ${ basename } _$date -$head
2012-11-26 08:23:20 +00:00
# clean up the revision header
cd $top /$source
echo svn revert "source/rev.h"
svn revert "source/rev.h"
2010-05-25 10:47:52 +00:00
2009-10-01 05:25:34 +00:00
# output the changelog since last snapshot in the output directory
2012-11-26 08:23:20 +00:00
if [ $lastrevision ]
2009-10-01 05:25:34 +00:00
then
2012-03-04 09:33:23 +00:00
# add one so that we only include what is new to this update
let lastrevision += 1
2009-10-01 05:33:49 +00:00
svn log -r $head :$lastrevision > $output /$date -$head /ChangeLog.txt
2009-10-01 05:25:34 +00:00
fi
2010-05-25 10:47:52 +00:00
# hack for our served directory structure... really belongs elsewhere,
# like in whatever script executes this one
2009-10-01 05:51:17 +00:00
chmod -R g+w $output /$date -$head
2009-10-18 02:59:31 +00:00
chown -R :$group $output /$date -$head
2010-05-25 10:47:52 +00:00
2011-07-21 23:45:12 +00:00
# link eduke32_latest.zip to the new archive
ln -sf $output /$date -$head /${ basename } _${ platform } _$date -$head .zip $output /eduke32_latest.zip
2010-05-25 10:47:52 +00:00
rm -r $lockfile
2009-10-01 04:36:05 +00:00
else
echo "Nothing to do."
2010-05-25 10:47:52 +00:00
rm -r $lockfile
2009-10-18 02:59:31 +00:00
fi