1#!/bin/bash
2# This file is executed by contigratord when a build is triggered.
3# You can execute it manually too by executing /home/contigrator/contigrator/tool/trigBuild.sh
4
5#These variables are available:
6# $WD = The workspace $BN = Zero padded build Number (%07i) and $BN_NUM for unpadded.
7# $OUT = This empty directory is created for you to store the output of the build.
8set -e;set -x
9
10#Add your build instructions below:
11
12echo "Osgg build script."
13
14rm -Rf Osgg-version*
15# Ouch, extract version from source code...
16VER=$(cat main.cpp | grep "define VERSION" | cut -f 2 -d '"')
17DST="$JOBNAME"-version_$VER"-build_$BN"
18mkdir $DST
19
20# =
21# == Building 64 bit linux version ...
22# ===
23
24# 64 bit version
25pushd launcher
26qmake DEFINES+='EXECPATH=\"\\\"./osgg_linux_x64\\\"\"'
27make clean
28make
29popd
30make clean
31make
32
33mv launcher/launcher $DST/launcher_linux_x64
34mv osgg $DST/osgg_linux_x64
35
36# Clean
37make clean
38pushd launcher
39make clean
40popd
41
42# =
43# == Building 32 bit linux version ...
44# ===
45
46TMPSCRIPT=`mktemp`
47if [ -f $TMPSCRIPT ]
48then
49  # I seriously can't figure out a sane way of getting the literal string: qmake DEFINES+='EXECPATH=\"\\\"./osgg_linux_x64\\\"\"' executed in the chrooted environment in a different way.. except for committing the file, and that's also ugly..
50  echo IyEvYmluL2Jhc2gKY2QgL2hvbWUvY29udGlncmF0b3Ivam9icy9Pc2dnL3dvcmtzcGFjZS9sYXVuY2hlcgpxbWFrZSBERUZJTkVTKz0nRVhFQ1BBVEg9XCJcXFwiLi9vc2dnX2xpbnV4X3g4NlxcXCJcIicKbWFrZQpjZCAuLgptYWtlCg== | base64 -d > $TMPSCRIPT
51  chmod +x $TMPSCRIPT
52
53# The chrooted 32 bit linux version.
54  sudo -E -P USER=$USER USERNAME=$USER LOGNAME=$LOGNAME -- /usr/sbin/chroot /var/local/32bitDeb/ su -p -l $USER -c "$TMPSCRIPT"
55  rm -f $TMPSCRIPT
56
57  mv launcher/launcher $DST/launcher_linux_x86
58  mv osgg $DST/osgg_linux_x86
59fi
60
61# =
62# == Building 32 bit windows version ...
63# ===
64
65# The windows version
66pushd launcher
67OLDPATH="$PATH"
68PATH="/home/contigrator/mxe/usr/bin:$PATH"
69echo "Current path: $PATH"
70i686-w64-mingw32.static-qmake-qt4 DEFINES+='EXECPATH=\"\\\"osgg_windows.exe\\\"\"'
71make
72PATH="$OLDPATH"
73unset OLDPATH
74find .
75mv "./release/launcher.exe" "../launcher.exe"
76rm -Rf debug
77rm -Rf release
78rm -f *.o
79rm -f *.exe
80popd
81make clean
82make -f Makefile.win
83
84# =
85# == Packaging ...
86# ===
87
88# Add changelog
89git log > changelog.txt
90cp changelog.txt $DST/changelog.txt
91
92# Data files
93cp -r demos levels *.txt *.ttf *.txt *.ogg *.png start.sh $DST
94
95#Package the Linux version
96tar -c $DST | pbzip2 > "$DST"_linux.tar.bz2
97
98# Remove linux binaries for the zip
99rm $DST/*_linux_*
100rm $DST/*.sh
101# Add .exe files for the windows version
102mv launcher.exe $DST/launcher_windows.exe
103mv osgg.exe $DST/osgg_windows.exe
104unix2dos $DST/changelog.txt
105# Add dlls for the windows version
106cp -r ../dlls/* $DST
107# Add .bat for the windows version
108cp start.bat $DST
109zip -r "$DST"_windows.zip $DST
110
111mv "$DST"_linux.tar.bz2 $OUT
112mv "$DST"_windows.zip $OUT
113
114rm -R "$DST"
115
116# Build the source code
117git archive --prefix="osgg_build_$BN"_src/ HEAD > "$DST"_src.tar
118tar --file "$DST"_src.tar --append --transform 's%^%osgg_build_'$BN'_src/%' changelog.txt
119cat "$DST"_src.tar | pxz > "$OUT/$DST"_src.tar.xz
120
121rm -f "$DST"_src.tar changelog.txt
122