2011-09-01 20:11:22 +00:00
|
|
|
#!/bin/bash
|
2009-10-01 04:36:05 +00:00
|
|
|
|
2013-08-11 15:28:47 +00:00
|
|
|
# The extension for executables.
|
|
|
|
exe=.exe
|
|
|
|
|
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
|
2013-10-27 18:14:25 +00:00
|
|
|
make=( make SYNTHESIS=1 PLATFORM=WINDOWS CROSS='i686-w64-mingw32-' CC='i686-w64-mingw32-gcc-4.8.0' AS='nasm' PRETTY_OUTPUT=0 )
|
|
|
|
make64=( make SYNTHESIS=1 PLATFORM=WINDOWS CROSS='x86_64-w64-mingw32-' CC='x86_64-w64-mingw32-gcc-4.8.0' AS='nasm' PRETTY_OUTPUT=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
|
2013-08-11 15:28:47 +00:00
|
|
|
targets=( eduke32$exe mapster32$exe )
|
2013-11-04 03:59:26 +00:00
|
|
|
package=$top/$source/package/package
|
|
|
|
not_src_packaged=( package/debug/win32/ebacktrace1.dll package/debug/win64/ebacktrace1-64.dll )
|
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
|
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
|
2013-08-11 15:28:40 +00:00
|
|
|
echo "Build already in progress!"
|
|
|
|
exit
|
2010-05-25 10:47:52 +00:00
|
|
|
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."
|
2013-08-11 15:28:46 +00:00
|
|
|
headlog=`svn log -r $head`
|
2009-10-01 04:36:05 +00:00
|
|
|
|
2013-11-15 19:41:02 +00:00
|
|
|
lastrevision=`ls -A1 $output/????????-???? | grep ${basename}_ - | tail -n1 | cut -d- -f2 | cut -d. -f1`
|
2009-10-01 04:36:05 +00:00
|
|
|
|
2013-08-04 20:37:50 +00:00
|
|
|
# If the log of HEAD contains DONT_BUILD, obey.
|
2013-08-11 15:28:46 +00:00
|
|
|
if [ -n "`echo $headlog | grep DONT_BUILD`" ]; then
|
2013-08-04 20:37:50 +00:00
|
|
|
echo "HEAD requested to not build. Bailing out..."
|
2013-08-11 15:28:40 +00:00
|
|
|
rm -f $lockfile
|
2013-08-04 20:37:50 +00:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
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."
|
2013-11-04 03:59:26 +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
|
|
|
|
|
2013-10-13 06:16:27 +00:00
|
|
|
function verifytargets ()
|
|
|
|
{
|
|
|
|
for i in "${targets[@]}"; do
|
|
|
|
if [ ! -e $i ]
|
|
|
|
then
|
|
|
|
echo "Build failed! Bailing out..."
|
|
|
|
rm -f $lockfile
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
done
|
2013-11-04 03:59:26 +00:00
|
|
|
|
|
|
|
# create the output directory
|
|
|
|
mkdir -p $output/$date-$head
|
|
|
|
}
|
|
|
|
|
|
|
|
function package_start ()
|
|
|
|
{
|
|
|
|
mkdir -p $package
|
|
|
|
|
|
|
|
cd $package
|
|
|
|
|
|
|
|
cp -R $top/$source/package/common/* ./
|
2014-02-22 08:02:23 +00:00
|
|
|
cp -R $top/$source/package/sdk/* ./
|
2013-11-04 03:59:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function package_debug ()
|
|
|
|
{
|
|
|
|
cp -R $top/$source/package/debug/${*}/* ./
|
|
|
|
}
|
|
|
|
|
|
|
|
function package_game_lunatic ()
|
|
|
|
{
|
|
|
|
# Package some Lunatic test and demo files.
|
2013-11-15 05:45:22 +00:00
|
|
|
mkdir -p ./lunatic/test
|
|
|
|
cp $top/$source/source/lunatic/test.lua ./lunatic/
|
|
|
|
cp $top/$source/source/lunatic/test/test_{bitar,geom,rotspr}.lua ./lunatic/test/
|
2014-01-02 00:08:41 +00:00
|
|
|
cp $top/$source/source/lunatic/test/{damagehplane,delmusicsfx,helixspawner,shadexfog}.lua ./lunatic/test/
|
2013-11-04 03:59:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function package_execute ()
|
|
|
|
{
|
2013-11-04 04:32:28 +00:00
|
|
|
echo 7zr a -mx9 -t7z $output/$date-$head/${*}_$date-$head.7z *
|
|
|
|
7zr a -mx9 -t7z $output/$date-$head/${*}_$date-$head.7z *
|
2013-11-04 03:59:26 +00:00
|
|
|
|
|
|
|
cd $top/$source
|
|
|
|
|
|
|
|
rm -rf $package
|
2013-10-13 06:16:27 +00:00
|
|
|
}
|
|
|
|
|
2009-10-01 04:36:05 +00:00
|
|
|
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
|
|
|
|
2013-11-04 03:59:26 +00:00
|
|
|
# get the date in the YYYYMMDD format (ex: 20091001)
|
|
|
|
date=`date +%Y%m%d`
|
|
|
|
|
2013-10-13 06:16:27 +00:00
|
|
|
|
|
|
|
# 32-bit debug
|
|
|
|
|
|
|
|
# clean the tree and build
|
2010-10-19 04:39:54 +00:00
|
|
|
echo "${make[@]}" RELEASE=0 $clean all
|
|
|
|
"${make[@]}" RELEASE=0 $clean all
|
|
|
|
|
|
|
|
# make sure all the targets were produced
|
2013-10-13 06:16:27 +00:00
|
|
|
verifytargets
|
2010-10-19 04:39:54 +00:00
|
|
|
|
2014-02-22 08:02:23 +00:00
|
|
|
# package
|
2013-11-04 03:59:26 +00:00
|
|
|
package_start
|
|
|
|
package_debug win32
|
2013-11-04 04:32:28 +00:00
|
|
|
mv -f $top/$source/eduke32$exe "$package/eduke32.debug$exe"
|
|
|
|
mv -f $top/$source/mapster32$exe "$package/mapster32.debug$exe"
|
2014-02-22 08:02:23 +00:00
|
|
|
package_execute ${basename}_win32_debug
|
2010-10-19 04:39:54 +00:00
|
|
|
|
2013-10-13 06:16:27 +00:00
|
|
|
|
|
|
|
# 64-bit debug
|
|
|
|
|
|
|
|
# clean the tree and build
|
|
|
|
echo "${make64[@]}" RELEASE=0 $clean all
|
|
|
|
"${make64[@]}" RELEASE=0 $clean all
|
|
|
|
|
|
|
|
# make sure all the targets were produced
|
|
|
|
verifytargets
|
|
|
|
|
2014-02-22 08:02:23 +00:00
|
|
|
# package
|
2013-11-04 03:59:26 +00:00
|
|
|
package_start
|
|
|
|
package_debug win64
|
2013-11-04 04:32:28 +00:00
|
|
|
mv -f $top/$source/eduke32$exe "$package/eduke32.debug$exe"
|
|
|
|
mv -f $top/$source/mapster32$exe "$package/mapster32.debug$exe"
|
2014-02-22 08:02:23 +00:00
|
|
|
package_execute ${basename}_win64_debug
|
2013-10-13 06:16:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
# 32-bit Lunatic (pre-)release
|
|
|
|
|
2013-08-18 19:24:27 +00:00
|
|
|
BUILD_LUNATIC="`echo $headlog | grep BUILD_LUNATIC`"
|
|
|
|
|
|
|
|
if [ -n "$BUILD_LUNATIC" ]; then
|
2013-10-13 06:16:27 +00:00
|
|
|
# clean the tree and build
|
2015-02-22 19:35:01 +00:00
|
|
|
echo "${make[@]}" LUNATIC=1 CPLUSPLUS=0 $clean all
|
|
|
|
"${make[@]}" LUNATIC=1 CPLUSPLUS=0 $clean all
|
2013-08-04 20:37:50 +00:00
|
|
|
|
|
|
|
# make sure all the targets were produced
|
2013-10-13 06:16:27 +00:00
|
|
|
verifytargets
|
2013-08-04 20:37:50 +00:00
|
|
|
|
2014-02-22 08:02:23 +00:00
|
|
|
# package
|
2013-11-04 03:59:26 +00:00
|
|
|
package_start
|
|
|
|
package_game_lunatic
|
2013-11-04 04:32:28 +00:00
|
|
|
mv -f $top/$source/eduke32$exe "$package/leduke32_PREVIEW$exe"
|
2014-02-12 21:03:07 +00:00
|
|
|
mv -f $top/$source/mapster32$exe "$package/lmapster32_PREVIEW$exe"
|
2013-11-15 19:18:10 +00:00
|
|
|
package_execute l${basename}_lunatic_PREVIEW_win32
|
2013-08-04 20:37:50 +00:00
|
|
|
fi
|
|
|
|
|
2013-10-13 06:16:27 +00:00
|
|
|
|
2014-02-10 11:00:34 +00:00
|
|
|
# 64-bit Lunatic (pre-)release
|
|
|
|
|
|
|
|
if [ -n "$BUILD_LUNATIC" ]; then
|
|
|
|
# clean the tree and build
|
2015-02-22 19:31:17 +00:00
|
|
|
echo "${make64[@]}" LUNATIC=1 CPLUSPLUS=0 $clean all
|
|
|
|
"${make64[@]}" LUNATIC=1 CPLUSPLUS=0 $clean all
|
2014-02-10 11:00:34 +00:00
|
|
|
|
|
|
|
# make sure all the targets were produced
|
|
|
|
verifytargets
|
|
|
|
|
2014-02-22 08:02:23 +00:00
|
|
|
# package
|
2014-02-10 11:00:34 +00:00
|
|
|
package_start
|
|
|
|
package_game_lunatic
|
|
|
|
mv -f $top/$source/eduke32$exe "$package/leduke32_PREVIEW$exe"
|
2014-02-12 21:03:07 +00:00
|
|
|
mv -f $top/$source/mapster32$exe "$package/lmapster32_PREVIEW$exe"
|
2014-02-10 11:00:34 +00:00
|
|
|
package_execute l${basename}_lunatic_PREVIEW_win64
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2013-10-13 06:16:27 +00:00
|
|
|
# 32-bit release
|
|
|
|
|
|
|
|
# clean the tree and build
|
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
|
2013-10-13 06:16:27 +00:00
|
|
|
verifytargets
|
2010-10-19 04:39:54 +00:00
|
|
|
|
2014-02-22 08:02:23 +00:00
|
|
|
# package
|
2013-11-04 03:59:26 +00:00
|
|
|
package_start
|
2013-11-04 04:32:28 +00:00
|
|
|
mv -f $top/$source/eduke32$exe "$package/eduke32$exe"
|
|
|
|
mv -f $top/$source/mapster32$exe "$package/mapster32$exe"
|
2014-02-22 08:02:23 +00:00
|
|
|
package_execute ${basename}_win32
|
2011-10-02 07:47:18 +00:00
|
|
|
|
2013-10-13 06:16:27 +00:00
|
|
|
|
|
|
|
# 64-bit release
|
|
|
|
|
|
|
|
# clean the tree and build
|
|
|
|
echo "${make64[@]}" $clean all
|
|
|
|
"${make64[@]}" $clean all
|
|
|
|
|
|
|
|
# make sure all the targets were produced
|
|
|
|
verifytargets
|
|
|
|
|
2014-02-22 08:02:23 +00:00
|
|
|
# package
|
2013-11-04 03:59:26 +00:00
|
|
|
package_start
|
2013-11-04 04:32:28 +00:00
|
|
|
mv -f $top/$source/eduke32$exe "$package/eduke32$exe"
|
|
|
|
mv -f $top/$source/mapster32$exe "$package/mapster32$exe"
|
2014-02-22 08:02:23 +00:00
|
|
|
package_execute ${basename}_win64
|
2013-08-18 19:24:27 +00:00
|
|
|
|
|
|
|
|
2013-11-04 03:59:26 +00:00
|
|
|
# clean up
|
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
|
2013-11-04 03:59:26 +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
|
2013-11-04 03:59:26 +00:00
|
|
|
|
2009-10-01 04:36:05 +00:00
|
|
|
# package the source
|
|
|
|
cd $output/$date-$head
|
2013-11-04 03:59:26 +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
|
2013-11-04 03:59:26 +00:00
|
|
|
|
2016-01-12 10:30:36 +00:00
|
|
|
# throw the svn revision into a file the Makefile will read
|
2016-01-22 01:24:52 +00:00
|
|
|
echo "$head" > ${basename}_$date-$head/EDUKE32_REVISION
|
2016-01-12 10:30:36 +00:00
|
|
|
|
2013-11-04 02:35:39 +00:00
|
|
|
echo tar cJf ${basename}_src_$date-$head.tar.xz ${basename}_$date-$head
|
|
|
|
tar cJf ${basename}_src_$date-$head.tar.xz ${basename}_$date-$head
|
2010-05-25 11:26:09 +00:00
|
|
|
rm -r ${basename}_$date-$head
|
2012-11-26 08:23:20 +00:00
|
|
|
|
2016-01-22 01:24:52 +00:00
|
|
|
cd $top/$source
|
|
|
|
|
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
|
2013-11-15 20:05:20 +00:00
|
|
|
|
|
|
|
echo "See http://svn.eduke32.com/listing.php?repname=eduke32 for more details." >> $output/$date-$head/ChangeLog.txt
|
2009-10-01 05:25:34 +00:00
|
|
|
fi
|
2013-11-04 03:59:26 +00:00
|
|
|
|
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
|
|
|
|
2013-11-04 03:59:26 +00:00
|
|
|
# link eduke32_latest.zip to the new archive
|
|
|
|
ln -sf $output/$date-$head/${basename}_win32_$date-$head.7z $output/eduke32_latest.7z
|
2011-07-21 23:45:12 +00:00
|
|
|
|
2013-08-11 15:28:40 +00:00
|
|
|
rm -f $lockfile
|
2009-10-01 04:36:05 +00:00
|
|
|
else
|
|
|
|
echo "Nothing to do."
|
2013-08-11 15:28:40 +00:00
|
|
|
rm -f $lockfile
|
2009-10-18 02:59:31 +00:00
|
|
|
fi
|