Subversion Repositories eduke32

Rev

Rev 3233 | Rev 3236 | 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
3233 Plagman 8
make=( make PLATFORM=WINDOWS CC='i586-mingw32msvc-gcc' CXX='i586-mingw32msvc-g++' AS='nasm' RC='i586-mingw32msvc-windres' STRIP='i586-mingw32msvc-strip' AR='i586-mingw32msvc-ar' RANLIB='i586-mingw32msvc-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
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
 
1822 terminx 70
    # throw the svn revision into a header.  this is ugly.
3116 hendricks2 71
    echo "s_buildRev = \"r$head\";" > source/rev.h
1940 plagman 72
 
1714 plagman 73
    # clean the tree and build debug first
74
    echo "${make[@]}" RELEASE=0 $clean all
75
    "${make[@]}" RELEASE=0 $clean all
76
 
77
    # make sure all the targets were produced
78
    for i in "${targets[@]}"; do
79
        if [ ! -e $i ]
80
        then
81
            echo "Build failed! Bailing out..."
82
                rm -r $lockfile
83
            exit
84
        fi
85
    done
86
 
3235 hendricks2 87
    # move the targets to $package
88
    echo mv -f eduke32.exe "$package/eduke32.debug.exe"
89
    mv -f eduke32.exe "$package/eduke32.debug.exe"
90
    echo mv -f mapster32.exe "$package/mapster32.debug.exe"
91
    mv -f mapster32.exe "$package/mapster32.debug.exe"
92
    echo mv -f ebacktrace1.dll "$package/ebacktrace1.dll"
93
    mv -f ebacktrace1.dll "$package/ebacktrace1.dll"
1714 plagman 94
 
95
    # clean the tree and build release
1651 terminx 96
    echo "${make[@]}" $clean all
97
    "${make[@]}" $clean all
1714 plagman 98
 
1512 plagman 99
    # make sure all the targets were produced
100
    for i in "${targets[@]}"; do
101
        if [ ! -e $i ]
102
        then
1651 terminx 103
            echo "Build failed! Bailing out..."
104
                rm -r $lockfile
105
            exit
1512 plagman 106
        fi
107
    done
1714 plagman 108
 
3235 hendricks2 109
    # move the targets to $package
110
    echo mv -f eduke32.exe "$package/eduke32.exe"
111
    mv -f eduke32.exe "$package/eduke32.exe"
112
    echo mv -f mapster32.exe "$package/mapster32.exe"
113
    mv -f mapster32.exe "$package/mapster32.exe"
2062 hendricks2 114
 
1512 plagman 115
    # get the date in the YYYYMMDD format (ex: 20091001)
116
    date=`date +%Y%m%d`
1651 terminx 117
 
1512 plagman 118
    # create the output directory
119
    mkdir $output/$date-$head
1651 terminx 120
 
1512 plagman 121
    # package the binary snapshot
3235 hendricks2 122
    cd $package
123
    echo zip -r -y -9 $output/$date-$head/${basename}_${platform}_$date-$head.zip * -x "*.svn*"
124
    zip -r -y -9 $output/$date-$head/${basename}_${platform}_$date-$head.zip * -x "*.svn*"
125
    cd $top/$source
1940 plagman 126
 
1512 plagman 127
    # hack to restore [e]obj/keep.me
128
    echo svn update -r $head
129
    svn update -r $head
1651 terminx 130
 
1512 plagman 131
    # export the source tree into the output directory
1654 terminx 132
    svn export . $output/$date-$head/${basename}_$date-$head
133
    echo svn export . $output/$date-$head/${basename}_$date-$head
1651 terminx 134
 
1512 plagman 135
    # package the source
136
    cd $output/$date-$head
1651 terminx 137
 
1518 plagman 138
    # first remove the unnecessary files
139
    for i in "${not_src_packaged[@]}"; do
1654 terminx 140
        echo rm -r ${basename}_$date-$head/$i
141
        rm -r ${basename}_$date-$head/$i
1518 plagman 142
    done
1651 terminx 143
 
1654 terminx 144
    echo tar cjf ${basename}_src_$date-$head.tar.bz2 ${basename}_$date-$head
145
    tar cjf ${basename}_src_$date-$head.tar.bz2 ${basename}_$date-$head
146
    rm -r ${basename}_$date-$head
3235 hendricks2 147
 
148
    # clean up the revision header
149
    cd $top/$source
150
    echo svn revert "source/rev.h"
151
    svn revert "source/rev.h"
1651 terminx 152
 
1515 plagman 153
    # output the changelog since last snapshot in the output directory
3235 hendricks2 154
    if [ $lastrevision ]
1515 plagman 155
    then
2402 hendricks2 156
        # add one so that we only include what is new to this update
157
        let lastrevision+=1
1516 plagman 158
        svn log -r $head:$lastrevision > $output/$date-$head/ChangeLog.txt
1515 plagman 159
    fi
1651 terminx 160
 
161
    # hack for our served directory structure... really belongs elsewhere,
162
    # like in whatever script executes this one
1517 plagman 163
    chmod -R g+w $output/$date-$head
1535 terminx 164
    chown -R :$group $output/$date-$head
1651 terminx 165
 
1940 plagman 166
   # link eduke32_latest.zip to the new archive
167
    ln -sf $output/$date-$head/${basename}_${platform}_$date-$head.zip $output/eduke32_latest.zip
168
 
1651 terminx 169
    rm -r $lockfile
1512 plagman 170
else
171
    echo "Nothing to do."
1651 terminx 172
    rm -r $lockfile
1535 terminx 173
fi