Subversion Repositories eduke32

Rev

Rev 2062 | Rev 3116 | 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
1651 terminx 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
12
targets=( eduke32.exe mapster32.exe )
2041 helixhorne 13
bin_packaged=( eduke32.exe eduke32.debug.exe mapster32.exe mapster32.debug.exe ebacktrace1.dll SEHELP.HLP STHELP.HLP names.h buildlic.txt GNU.TXT m32help.hlp nedmalloc.dll tiles.cfg samples/* )
2402 hendricks2 14
not_src_packaged=( psd source/jaudiolib/third-party/vorbis.framework/Versions/A/vorbis Apple/lib )
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
34
        echo "Build already in progress!"
35
        exit
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."
45
 
1940 plagman 46
lastrevision=`ls -A1 $output/????????-???? | tail -n1 | cut -d- -f2 | cut -d. -f1`
1512 plagman 47
 
48
# if the output dir is empty, we build no matter what
49
if [ ! $lastrevision ]
50
then
51
    echo "No builds yet."
52
    dobuild=1
53
else
54
    echo "Last built revision is $lastrevision."
1651 terminx 55
 
1512 plagman 56
    # if the last built revision is less than HEAD, we also build
57
    if [ $lastrevision -lt $head ]
58
    then
59
        echo "Need a new build."
60
        dobuild=1
61
    fi
62
fi
63
 
64
if [ $dobuild ]
65
then
66
    echo "Launching a build..."
1714 plagman 67
 
1518 plagman 68
    cd $top/$source
1714 plagman 69
 
70
    # remove possible old debug binaries
71
    echo rm eduke32.debug.exe
72
    rm eduke32.debug.exe
73
    echo rm mapster32.debug.exe
74
    rm mapster32.debug.exe
75
 
1822 terminx 76
    # throw the svn revision into a header.  this is ugly.
77
    echo "const char *s_buildRev = \"r$head\";" > source/rev.h
1940 plagman 78
 
1714 plagman 79
    # clean the tree and build debug first
80
    echo "${make[@]}" RELEASE=0 $clean all
81
    "${make[@]}" RELEASE=0 $clean all
82
 
83
    # make sure all the targets were produced
84
    for i in "${targets[@]}"; do
85
        if [ ! -e $i ]
86
        then
87
            echo "Build failed! Bailing out..."
88
                rm -r $lockfile
89
            exit
90
        fi
91
    done
92
 
93
    # move the debug binaries out of the way
94
    echo mv eduke32.exe eduke32.debug.exe
95
    mv eduke32.exe eduke32.debug.exe
96
    echo mv mapster32.exe mapster32.debug.exe
97
    mv mapster32.exe mapster32.debug.exe
2062 hendricks2 98
    echo mv ebacktrace1.dll ebacktrace1.debug.dll
99
    mv ebacktrace1.dll ebacktrace1.debug.dll
1714 plagman 100
 
101
    # clean the tree and build release
1651 terminx 102
    echo "${make[@]}" $clean all
103
    "${make[@]}" $clean all
1714 plagman 104
 
1512 plagman 105
    # make sure all the targets were produced
106
    for i in "${targets[@]}"; do
107
        if [ ! -e $i ]
108
        then
1651 terminx 109
            echo "Build failed! Bailing out..."
110
                rm -r $lockfile
111
            exit
1512 plagman 112
        fi
113
    done
1714 plagman 114
 
2062 hendricks2 115
    # move this back where it belongs
116
    echo mv ebacktrace1.debug.dll ebacktrace1.dll
117
    mv ebacktrace1.debug.dll ebacktrace1.dll
118
 
1512 plagman 119
    # get the date in the YYYYMMDD format (ex: 20091001)
120
    date=`date +%Y%m%d`
1651 terminx 121
 
1512 plagman 122
    # create the output directory
123
    mkdir $output/$date-$head
1651 terminx 124
 
1512 plagman 125
    # package the binary snapshot
1654 terminx 126
    echo zip -9 $output/$date-$head/${basename}_${platform}_$date-$head.zip ${bin_packaged[@]}
127
    zip -9 $output/$date-$head/${basename}_${platform}_$date-$head.zip ${bin_packaged[@]}
1940 plagman 128
 
1512 plagman 129
    # hack to restore [e]obj/keep.me
130
    echo svn update -r $head
131
    svn update -r $head
1651 terminx 132
 
1512 plagman 133
    # export the source tree into the output directory
1654 terminx 134
    svn export . $output/$date-$head/${basename}_$date-$head
135
    echo svn export . $output/$date-$head/${basename}_$date-$head
1651 terminx 136
 
1512 plagman 137
    # package the source
138
    cd $output/$date-$head
1651 terminx 139
 
1518 plagman 140
    # first remove the unnecessary files
141
    for i in "${not_src_packaged[@]}"; do
1654 terminx 142
        echo rm -r ${basename}_$date-$head/$i
143
        rm -r ${basename}_$date-$head/$i
1518 plagman 144
    done
1651 terminx 145
 
1654 terminx 146
    echo tar cjf ${basename}_src_$date-$head.tar.bz2 ${basename}_$date-$head
147
    tar cjf ${basename}_src_$date-$head.tar.bz2 ${basename}_$date-$head
148
    rm -r ${basename}_$date-$head
1651 terminx 149
 
1515 plagman 150
    # output the changelog since last snapshot in the output directory
151
    if [  $lastrevision ]
152
    then
2402 hendricks2 153
        # add one so that we only include what is new to this update
154
        let lastrevision+=1
1518 plagman 155
        cd $top/$source
1516 plagman 156
        svn log -r $head:$lastrevision > $output/$date-$head/ChangeLog.txt
1515 plagman 157
    fi
1651 terminx 158
 
159
    # hack for our served directory structure... really belongs elsewhere,
160
    # like in whatever script executes this one
1517 plagman 161
    chmod -R g+w $output/$date-$head
1535 terminx 162
    chown -R :$group $output/$date-$head
1651 terminx 163
 
1940 plagman 164
   # link eduke32_latest.zip to the new archive
165
    ln -sf $output/$date-$head/${basename}_${platform}_$date-$head.zip $output/eduke32_latest.zip
166
 
1651 terminx 167
    rm -r $lockfile
1512 plagman 168
else
169
    echo "Nothing to do."
1651 terminx 170
    rm -r $lockfile
1535 terminx 171
fi