Subversion Repositories eduke32

Rev

Rev 4002 | Rev 4022 | 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
 
4002 helixhorne 104
    if [ -n "`echo $headlog | grep BUILD_LUNATIC`" ]; then
3978 helixhorne 105
        # clean the tree and build Lunatic (pre-)release next
4002 helixhorne 106
        echo "${make[@]}" LUNATIC=1 $clean all
107
        "${make[@]}" LUNATIC=1 $clean all
3978 helixhorne 108
 
109
        # make sure all the targets were produced
110
        for i in "${targets[@]}"; do
111
            if [ ! -e $i ]
112
            then
113
                echo "Build failed! Bailing out..."
3999 helixhorne 114
                rm -f $lockfile
3978 helixhorne 115
                exit
116
            fi
117
        done
118
 
119
        # move the targets to $package
4003 helixhorne 120
        echo mv -f eduke32$exe "$package/leduke32_PREVIEW$exe"
121
        mv -f eduke32$exe "$package/leduke32_PREVIEW$exe"
3978 helixhorne 122
    fi
123
 
1714 plagman 124
    # clean the tree and build release
1651 terminx 125
    echo "${make[@]}" $clean all
126
    "${make[@]}" $clean all
1714 plagman 127
 
1512 plagman 128
    # make sure all the targets were produced
129
    for i in "${targets[@]}"; do
130
        if [ ! -e $i ]
131
        then
1651 terminx 132
            echo "Build failed! Bailing out..."
3999 helixhorne 133
            rm -f $lockfile
1651 terminx 134
            exit
1512 plagman 135
        fi
136
    done
1714 plagman 137
 
3235 hendricks2 138
    # move the targets to $package
4003 helixhorne 139
    echo mv -f eduke32$exe "$package/eduke32$exe"
140
    mv -f eduke32$exe "$package/eduke32$exe"
141
    echo mv -f mapster32$exe "$package/mapster32$exe"
142
    mv -f mapster32$exe "$package/mapster32$exe"
2062 hendricks2 143
 
1512 plagman 144
    # get the date in the YYYYMMDD format (ex: 20091001)
145
    date=`date +%Y%m%d`
1651 terminx 146
 
1512 plagman 147
    # create the output directory
148
    mkdir $output/$date-$head
1651 terminx 149
 
1512 plagman 150
    # package the binary snapshot
3235 hendricks2 151
    cd $package
152
    echo zip -r -y -9 $output/$date-$head/${basename}_${platform}_$date-$head.zip * -x "*.svn*"
153
    zip -r -y -9 $output/$date-$head/${basename}_${platform}_$date-$head.zip * -x "*.svn*"
154
    cd $top/$source
1940 plagman 155
 
1512 plagman 156
    # hack to restore [e]obj/keep.me
157
    echo svn update -r $head
158
    svn update -r $head
1651 terminx 159
 
1512 plagman 160
    # export the source tree into the output directory
1654 terminx 161
    svn export . $output/$date-$head/${basename}_$date-$head
162
    echo svn export . $output/$date-$head/${basename}_$date-$head
1651 terminx 163
 
1512 plagman 164
    # package the source
165
    cd $output/$date-$head
1651 terminx 166
 
1518 plagman 167
    # first remove the unnecessary files
168
    for i in "${not_src_packaged[@]}"; do
1654 terminx 169
        echo rm -r ${basename}_$date-$head/$i
170
        rm -r ${basename}_$date-$head/$i
1518 plagman 171
    done
1651 terminx 172
 
1654 terminx 173
    echo tar cjf ${basename}_src_$date-$head.tar.bz2 ${basename}_$date-$head
174
    tar cjf ${basename}_src_$date-$head.tar.bz2 ${basename}_$date-$head
175
    rm -r ${basename}_$date-$head
3235 hendricks2 176
 
177
    # clean up the revision header
178
    cd $top/$source
179
    echo svn revert "source/rev.h"
180
    svn revert "source/rev.h"
1651 terminx 181
 
1515 plagman 182
    # output the changelog since last snapshot in the output directory
3235 hendricks2 183
    if [ $lastrevision ]
1515 plagman 184
    then
2402 hendricks2 185
        # add one so that we only include what is new to this update
186
        let lastrevision+=1
1516 plagman 187
        svn log -r $head:$lastrevision > $output/$date-$head/ChangeLog.txt
1515 plagman 188
    fi
1651 terminx 189
 
190
    # hack for our served directory structure... really belongs elsewhere,
191
    # like in whatever script executes this one
1517 plagman 192
    chmod -R g+w $output/$date-$head
1535 terminx 193
    chown -R :$group $output/$date-$head
1651 terminx 194
 
1940 plagman 195
   # link eduke32_latest.zip to the new archive
196
    ln -sf $output/$date-$head/${basename}_${platform}_$date-$head.zip $output/eduke32_latest.zip
197
 
3999 helixhorne 198
    rm -f $lockfile
1512 plagman 199
else
200
    echo "Nothing to do."
3999 helixhorne 201
    rm -f $lockfile
1535 terminx 202
fi