Subversion Repositories eduke32

Rev

Rev 4003 | Rev 4023 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1999 plagman 1
#!/bin/bash
1512 plagman 2
 
4003 helixhorne 3
# The extension for executables.
4
exe=.exe
5
 
1512 plagman 6
# some paths
1651 terminx 7
top=/var/www/synthesis/eduke32
8
lockfile=$top/synthesis_building
9
source=eduke32
1518 plagman 10
output=/var/www/dukeworld.duke4.net/eduke32/synthesis
3351 Plagman 11
make=( make PLATFORM=WINDOWS CC='wine gcc' CXX='wine g++' AS='wine nasm' RC='wine windres' STRIP='wine strip' AR='wine ar' RANLIB='wine ranlib' PRETTY_OUTPUT=0 NEDMALLOC=0 )
1512 plagman 12
clean=veryclean
1535 terminx 13
 
1512 plagman 14
# the following file paths are relative to $source
4003 helixhorne 15
targets=( eduke32$exe mapster32$exe )
3235 hendricks2 16
package=package
3334 hendricks2 17
not_src_packaged=( psd $package/ebacktrace1.dll $package/ebacktrace1-64.dll )
1512 plagman 18
 
1535 terminx 19
# group that owns the resulting packages
20
group=dukeworld
1512 plagman 21
 
22
# some variables
23
dobuild=
24
 
1651 terminx 25
# controls resulting package filenames... will support linux later
26
basename=eduke32
27
platform=win32
28
 
1512 plagman 29
# if the output dir doesn't exist, create it
30
if [ ! -e $output ]
31
then
32
    mkdir -p $output
33
fi
34
 
1651 terminx 35
if [ -f $lockfile ]
36
then
3999 helixhorne 37
    echo "Build already in progress!"
38
    exit
1651 terminx 39
else
40
    touch $lockfile
41
fi
42
 
43
cd $top
44
 
1512 plagman 45
# update the code repository and get the last revision number from SVN
46
head=`svn update | tail -n1 | awk '{ print $NF }' | cut -d. -f1`
47
echo "HEAD is revision $head."
4002 helixhorne 48
headlog=`svn log -r $head`
1512 plagman 49
 
1940 plagman 50
lastrevision=`ls -A1 $output/????????-???? | tail -n1 | cut -d- -f2 | cut -d. -f1`
1512 plagman 51
 
3978 helixhorne 52
# If the log of HEAD contains DONT_BUILD, obey.
4002 helixhorne 53
if [ -n "`echo $headlog | grep DONT_BUILD`" ]; then
3978 helixhorne 54
    echo "HEAD requested to not build. Bailing out..."
3999 helixhorne 55
    rm -f $lockfile
3978 helixhorne 56
    exit
57
fi
58
 
1512 plagman 59
# if the output dir is empty, we build no matter what
60
if [ ! $lastrevision ]
61
then
62
    echo "No builds yet."
63
    dobuild=1
64
else
65
    echo "Last built revision is $lastrevision."
1651 terminx 66
 
1512 plagman 67
    # if the last built revision is less than HEAD, we also build
68
    if [ $lastrevision -lt $head ]
69
    then
70
        echo "Need a new build."
71
        dobuild=1
72
    fi
73
fi
74
 
75
if [ $dobuild ]
76
then
77
    echo "Launching a build..."
1714 plagman 78
 
1518 plagman 79
    cd $top/$source
1714 plagman 80
 
1822 terminx 81
    # throw the svn revision into a header.  this is ugly.
3116 hendricks2 82
    echo "s_buildRev = \"r$head\";" > source/rev.h
1940 plagman 83
 
1714 plagman 84
    # clean the tree and build debug first
85
    echo "${make[@]}" RELEASE=0 $clean all
86
    "${make[@]}" RELEASE=0 $clean all
87
 
88
    # make sure all the targets were produced
89
    for i in "${targets[@]}"; do
90
        if [ ! -e $i ]
91
        then
92
            echo "Build failed! Bailing out..."
3999 helixhorne 93
            rm -f $lockfile
1714 plagman 94
            exit
95
        fi
96
    done
97
 
3235 hendricks2 98
    # move the targets to $package
4003 helixhorne 99
    echo mv -f eduke32$exe "$package/eduke32.debug$exe"
100
    mv -f eduke32$exe "$package/eduke32.debug$exe"
101
    echo mv -f mapster32$exe "$package/mapster32.debug$exe"
102
    mv -f mapster32$exe "$package/mapster32.debug$exe"
1714 plagman 103
 
4022 helixhorne 104
    BUILD_LUNATIC="`echo $headlog | grep BUILD_LUNATIC`"
105
 
106
    if [ -n "$BUILD_LUNATIC" ]; then
3978 helixhorne 107
        # clean the tree and build Lunatic (pre-)release next
4002 helixhorne 108
        echo "${make[@]}" LUNATIC=1 $clean all
109
        "${make[@]}" LUNATIC=1 $clean all
3978 helixhorne 110
 
111
        # make sure all the targets were produced
112
        for i in "${targets[@]}"; do
113
            if [ ! -e $i ]
114
            then
115
                echo "Build failed! Bailing out..."
3999 helixhorne 116
                rm -f $lockfile
3978 helixhorne 117
                exit
118
            fi
119
        done
120
 
121
        # move the targets to $package
4003 helixhorne 122
        echo mv -f eduke32$exe "$package/leduke32_PREVIEW$exe"
123
        mv -f eduke32$exe "$package/leduke32_PREVIEW$exe"
3978 helixhorne 124
    fi
125
 
1714 plagman 126
    # clean the tree and build release
1651 terminx 127
    echo "${make[@]}" $clean all
128
    "${make[@]}" $clean all
1714 plagman 129
 
1512 plagman 130
    # make sure all the targets were produced
131
    for i in "${targets[@]}"; do
132
        if [ ! -e $i ]
133
        then
1651 terminx 134
            echo "Build failed! Bailing out..."
3999 helixhorne 135
            rm -f $lockfile
1651 terminx 136
            exit
1512 plagman 137
        fi
138
    done
1714 plagman 139
 
3235 hendricks2 140
    # move the targets to $package
4003 helixhorne 141
    echo mv -f eduke32$exe "$package/eduke32$exe"
142
    mv -f eduke32$exe "$package/eduke32$exe"
143
    echo mv -f mapster32$exe "$package/mapster32$exe"
144
    mv -f mapster32$exe "$package/mapster32$exe"
2062 hendricks2 145
 
1512 plagman 146
    # get the date in the YYYYMMDD format (ex: 20091001)
147
    date=`date +%Y%m%d`
1651 terminx 148
 
1512 plagman 149
    # create the output directory
150
    mkdir $output/$date-$head
4022 helixhorne 151
 
1512 plagman 152
    # package the binary snapshot
3235 hendricks2 153
    cd $package
4022 helixhorne 154
 
155
    # Package some Lunatic test and demo files.
156
    if [ -n "$BUILD_LUNATIC" ]; then
157
        mkdir -p lunatic/test
158
        cp $top/$source/source/lunatic/test.lua lunatic
159
        cp $top/$source/source/lunatic/test/test_{bitar,geom,rotspr}.lua lunatic/test
160
        cp $top/$source/source/lunatic/test/{delmusicsfx,helixspawner}.lua lunatic/test
161
    fi
162
 
3235 hendricks2 163
    echo zip -r -y -9 $output/$date-$head/${basename}_${platform}_$date-$head.zip * -x "*.svn*"
164
    zip -r -y -9 $output/$date-$head/${basename}_${platform}_$date-$head.zip * -x "*.svn*"
4022 helixhorne 165
 
166
    # Remove the packaged Lunatic test/demo files.
167
    if [ -n "$BUILD_LUNATIC" ]; then
168
        rm lunatic/test/*.lua lunatic/test.lua
169
        rmdir lunatic/test
170
        rmdir lunatic
171
    fi
172
 
3235 hendricks2 173
    cd $top/$source
1940 plagman 174
 
1512 plagman 175
    # hack to restore [e]obj/keep.me
176
    echo svn update -r $head
177
    svn update -r $head
1651 terminx 178
 
1512 plagman 179
    # export the source tree into the output directory
1654 terminx 180
    svn export . $output/$date-$head/${basename}_$date-$head
181
    echo svn export . $output/$date-$head/${basename}_$date-$head
1651 terminx 182
 
1512 plagman 183
    # package the source
184
    cd $output/$date-$head
1651 terminx 185
 
1518 plagman 186
    # first remove the unnecessary files
187
    for i in "${not_src_packaged[@]}"; do
1654 terminx 188
        echo rm -r ${basename}_$date-$head/$i
189
        rm -r ${basename}_$date-$head/$i
1518 plagman 190
    done
1651 terminx 191
 
1654 terminx 192
    echo tar cjf ${basename}_src_$date-$head.tar.bz2 ${basename}_$date-$head
193
    tar cjf ${basename}_src_$date-$head.tar.bz2 ${basename}_$date-$head
194
    rm -r ${basename}_$date-$head
3235 hendricks2 195
 
196
    # clean up the revision header
197
    cd $top/$source
198
    echo svn revert "source/rev.h"
199
    svn revert "source/rev.h"
1651 terminx 200
 
1515 plagman 201
    # output the changelog since last snapshot in the output directory
3235 hendricks2 202
    if [ $lastrevision ]
1515 plagman 203
    then
2402 hendricks2 204
        # add one so that we only include what is new to this update
205
        let lastrevision+=1
1516 plagman 206
        svn log -r $head:$lastrevision > $output/$date-$head/ChangeLog.txt
1515 plagman 207
    fi
1651 terminx 208
 
209
    # hack for our served directory structure... really belongs elsewhere,
210
    # like in whatever script executes this one
1517 plagman 211
    chmod -R g+w $output/$date-$head
1535 terminx 212
    chown -R :$group $output/$date-$head
1651 terminx 213
 
1940 plagman 214
   # link eduke32_latest.zip to the new archive
215
    ln -sf $output/$date-$head/${basename}_${platform}_$date-$head.zip $output/eduke32_latest.zip
216
 
3999 helixhorne 217
    rm -f $lockfile
1512 plagman 218
else
219
    echo "Nothing to do."
3999 helixhorne 220
    rm -f $lockfile
1535 terminx 221
fi