Subversion Repositories eduke32

Rev

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