Subversion Repositories eduke32

Rev

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

Rev Author Line No. Line
1651 terminx 1
#!/bin/sh
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 )
1715 Plagman 13
bin_packaged=( eduke32.exe eduke32.debug.exe mapster32.exe mapster32.debug.exe backtrace.dll libiconv2.dll libintl3.dll SEHELP.HLP STHELP.HLP names.h buildlic.txt GNU.TXT m32help.hlp nedmalloc.dll samples/* )
1651 terminx 14
not_src_packaged=( psd source/jaudiolib/third-party/vorbis.framework/Versions/A/vorbis Apple )
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
98
 
99
    # clean the tree and build release
1651 terminx 100
    echo "${make[@]}" $clean all
101
    "${make[@]}" $clean all
1714 plagman 102
 
1512 plagman 103
    # make sure all the targets were produced
104
    for i in "${targets[@]}"; do
105
        if [ ! -e $i ]
106
        then
1651 terminx 107
            echo "Build failed! Bailing out..."
108
                rm -r $lockfile
109
            exit
1512 plagman 110
        fi
111
    done
1714 plagman 112
 
1512 plagman 113
    # get the date in the YYYYMMDD format (ex: 20091001)
114
    date=`date +%Y%m%d`
1651 terminx 115
 
1512 plagman 116
    # create the output directory
117
    mkdir $output/$date-$head
1651 terminx 118
 
1512 plagman 119
    # package the binary snapshot
1654 terminx 120
    echo zip -9 $output/$date-$head/${basename}_${platform}_$date-$head.zip ${bin_packaged[@]}
121
    zip -9 $output/$date-$head/${basename}_${platform}_$date-$head.zip ${bin_packaged[@]}
1940 plagman 122
 
1512 plagman 123
    # hack to restore [e]obj/keep.me
124
    echo svn update -r $head
125
    svn update -r $head
1651 terminx 126
 
1512 plagman 127
    # export the source tree into the output directory
1654 terminx 128
    svn export . $output/$date-$head/${basename}_$date-$head
129
    echo svn export . $output/$date-$head/${basename}_$date-$head
1651 terminx 130
 
1512 plagman 131
    # package the source
132
    cd $output/$date-$head
1651 terminx 133
 
1518 plagman 134
    # first remove the unnecessary files
135
    for i in "${not_src_packaged[@]}"; do
1654 terminx 136
        echo rm -r ${basename}_$date-$head/$i
137
        rm -r ${basename}_$date-$head/$i
1518 plagman 138
    done
1651 terminx 139
 
1654 terminx 140
    echo tar cjf ${basename}_src_$date-$head.tar.bz2 ${basename}_$date-$head
141
    tar cjf ${basename}_src_$date-$head.tar.bz2 ${basename}_$date-$head
142
    rm -r ${basename}_$date-$head
1651 terminx 143
 
1515 plagman 144
    # output the changelog since last snapshot in the output directory
145
    if [  $lastrevision ]
146
    then
1518 plagman 147
        cd $top/$source
1516 plagman 148
        svn log -r $head:$lastrevision > $output/$date-$head/ChangeLog.txt
1515 plagman 149
    fi
1651 terminx 150
 
151
    # hack for our served directory structure... really belongs elsewhere,
152
    # like in whatever script executes this one
1517 plagman 153
    chmod -R g+w $output/$date-$head
1535 terminx 154
    chown -R :$group $output/$date-$head
1651 terminx 155
 
1940 plagman 156
   # link eduke32_latest.zip to the new archive
157
    ln -sf $output/$date-$head/${basename}_${platform}_$date-$head.zip $output/eduke32_latest.zip
158
 
1651 terminx 159
    rm -r $lockfile
1512 plagman 160
else
161
    echo "Nothing to do."
1651 terminx 162
    rm -r $lockfile
1535 terminx 163
fi