Subversion Repositories eduke32

Rev

Rev 1675 | Rev 1715 | 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 )
1714 plagman 13
bin_packaged=( eduke32.exe eduke32.debug.exe mapster32.exe mapster32.debug.exe 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
 
46
lastrevision=`ls -A1 $output | tail -n1 | cut -d- -f2`
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
 
76
    # clean the tree and build debug first
77
    echo "${make[@]}" RELEASE=0 $clean all
78
    "${make[@]}" RELEASE=0 $clean all
79
 
80
    # make sure all the targets were produced
81
    for i in "${targets[@]}"; do
82
        if [ ! -e $i ]
83
        then
84
            echo "Build failed! Bailing out..."
85
                rm -r $lockfile
86
            exit
87
        fi
88
    done
89
 
90
    # move the debug binaries out of the way
91
    echo mv eduke32.exe eduke32.debug.exe
92
    mv eduke32.exe eduke32.debug.exe
93
    echo mv mapster32.exe mapster32.debug.exe
94
    mv mapster32.exe mapster32.debug.exe
95
 
96
    # clean the tree and build release
1651 terminx 97
    echo "${make[@]}" $clean all
98
    "${make[@]}" $clean all
1714 plagman 99
 
1512 plagman 100
    # make sure all the targets were produced
101
    for i in "${targets[@]}"; do
102
        if [ ! -e $i ]
103
        then
1651 terminx 104
            echo "Build failed! Bailing out..."
105
                rm -r $lockfile
106
            exit
1512 plagman 107
        fi
108
    done
1714 plagman 109
 
1512 plagman 110
    # get the date in the YYYYMMDD format (ex: 20091001)
111
    date=`date +%Y%m%d`
1651 terminx 112
 
1512 plagman 113
    # create the output directory
114
    mkdir $output/$date-$head
1651 terminx 115
 
1512 plagman 116
    # package the binary snapshot
1654 terminx 117
    echo zip -9 $output/$date-$head/${basename}_${platform}_$date-$head.zip ${bin_packaged[@]}
118
    zip -9 $output/$date-$head/${basename}_${platform}_$date-$head.zip ${bin_packaged[@]}
1651 terminx 119
 
1512 plagman 120
    # hack to restore [e]obj/keep.me
121
    echo svn update -r $head
122
    svn update -r $head
1651 terminx 123
 
1512 plagman 124
    # export the source tree into the output directory
1654 terminx 125
    svn export . $output/$date-$head/${basename}_$date-$head
126
    echo svn export . $output/$date-$head/${basename}_$date-$head
1651 terminx 127
 
1512 plagman 128
    # package the source
129
    cd $output/$date-$head
1651 terminx 130
 
1518 plagman 131
    # first remove the unnecessary files
132
    for i in "${not_src_packaged[@]}"; do
1654 terminx 133
        echo rm -r ${basename}_$date-$head/$i
134
        rm -r ${basename}_$date-$head/$i
1518 plagman 135
    done
1651 terminx 136
 
1654 terminx 137
    echo tar cjf ${basename}_src_$date-$head.tar.bz2 ${basename}_$date-$head
138
    tar cjf ${basename}_src_$date-$head.tar.bz2 ${basename}_$date-$head
139
    rm -r ${basename}_$date-$head
1651 terminx 140
 
1515 plagman 141
    # output the changelog since last snapshot in the output directory
142
    if [  $lastrevision ]
143
    then
1518 plagman 144
        cd $top/$source
1516 plagman 145
        svn log -r $head:$lastrevision > $output/$date-$head/ChangeLog.txt
1515 plagman 146
    fi
1651 terminx 147
 
148
    # hack for our served directory structure... really belongs elsewhere,
149
    # like in whatever script executes this one
1517 plagman 150
    chmod -R g+w $output/$date-$head
1535 terminx 151
    chown -R :$group $output/$date-$head
1651 terminx 152
 
153
    rm -r $lockfile
1512 plagman 154
else
155
    echo "Nothing to do."
1651 terminx 156
    rm -r $lockfile
1535 terminx 157
fi