updated on Wed Jan 25 12:16:47 UTC 2012
[aur-mirror.git] / xonotic-git / PKGBUILD
blob194effdc1993e65ca369b0da8ebed54f8f30ab1e
1 # Maintainer: MrBougo <bougospam at gmail dot com>
2 # Contributor: wido <widomaker2k7@gmail.com>
3 # Contributor: Alexander Suhoverhov <cy at ngs dot ru>
5 pkgname=xonotic-git
6 pkgver=20110808
7 pkgrel=1
8 pkgdesc="A free, fast-paced crossplatform first-person shooter"
9 arch=('i686' 'x86_64')
10 url="http://xonotic.org"
11 license=('GPL')
12 depends=(
13         'd0_blind_id-git'
14         'libxpm'
15         'libjpeg>=8'
16         'libpng>=1.4.0'
17         'libmodplug'
18         'libvorbis'
19         'libxxf86dga'
20         'libxxf86vm'
21         'alsa-lib'
22         'sdl'
23         'curl'
25 makedepends=('git' 'p7zip' 'zip' 'unzip' 'vorbis-tools' 'sdl' 'mesa' 'imagemagick')
26 optdepends=(
27         'libtheora: recording in ogv'
28         #'d0_blind_id-git: crypto libraries for player authentification'
30 provides=('xonotic')
31 conflicts=('xonotic')
33 _gitroot="git://git.xonotic.org/xonotic/xonotic.git"
34 _gitname="xonotic"
35 _releasename="git-AUR"
36 _compression=5
38 # the jpeg and ogg variables can be modified, the function may also be skipped for raw data
39 # the values here are also used in the official -low builds
40 _compress() {
41         find $1 -type f -print0 |
42                 git_src_repo=$2              \
43                 CACHEDIR="$srcdir"/datacache \
44                 do_jpeg=true                 \
45                 jpeg_qual_rgb=80             \
46                 jpeg_qual_a=97               \
47                 do_dds=false                 \
48                 do_ogg=true                  \
49                 ogg_qual=1                   \
50                 del_src=true                 \
51                 xargs -0 "$srcdir"/$_gitname/misc/tools/cached-converter.sh
54 _git_extract() {
55         _from=$1
56         _to=$2
57         shift 2
58         { cd "$_from"; git archive --format=tar HEAD -- "$@"; } \
59                 | {
60                         cd "$_to"
61                         tar xvf -
62                 }
65 # 7z compresses nicely but can't deal with flags and symlinks
66 _mkzip() {
67         _archive=$1
68         shift
69         _ziplist=`mktemp`
70         find "$@" -xtype f \( -executable -or -type l \) -print > "$_ziplist"
71         7za a -tzip -mx=$_compression -x@"$_ziplist" "$_archive" "$@" || true
72         zip         -$_compression -y -@<"$_ziplist" "$_archive"      || true
73         rm -f "$_ziplist"
76 #credit goes to omgwizard for the shallow clone idea
77 _update() {
78         cd "$srcdir"/$_gitname
79         sed 's/git clone/git clone --depth 1/g' --in-place=".PKGBUILD_BU" ./all
80         ./all update
81         mv -f ./all.PKGBUILD_BU ./all
82         cd "$OLDPWD"
85 build() {
86         cd "$srcdir"
87         msg "Connecting to GIT server...."
89         if [ -d $_gitname ] ; then
90                 #future updates might introduce new subrepos, use shallow cloning anyway
91                 cd $_gitname && _update
92                 msg "The local files are updated."
93         else
94                 git clone --depth 1 $_gitroot $_gitname
95                 cd $_gitname
96                 touch d0_blind_id.no
97                 touch netradiant.no
98                 _update
99         fi
101         msg "GIT checkout done or server timeout"
103         # BUILD
105         msg "Copying sources..."
107         rm -rf "$srcdir"/src
108         mkdir -p "$srcdir"/src/darkplaces "$srcdir"/src/fteqcc
109         _git_extract "$srcdir"/$_gitname/fteqcc "$srcdir"/src/fteqcc
110         _git_extract "$srcdir"/$_gitname/darkplaces "$srcdir"/src/darkplaces
111         _git_extract "$srcdir"/$_gitname/data/xonotic-data.pk3dir "$srcdir"/src \
112                 qcsrc Makefile update-cvarcount.sh
114         msg "Fetching map binaries..."
115         cd "$srcdir"/$_gitname
116         ./all update-maps
118         msg "Compiling the engine..."
119         cd "$srcdir"/src/darkplaces
120         CC="${CC:-gcc} -g -DSUPPORTIPV6" make release
122         msg "Compiling fteqcc..."
123         cd "$srcdir"/src/fteqcc
124         make all
126         msg "Compiling the game code"
127         cd "$srcdir"/src/
128         make FTEQCC="../../fteqcc/fteqcc.bin" # relative to the directories containing progs.src
130         msg "Building data pk3's..."
131         rm -rf "$srcdir"/temp # just in case it was interrupted previously
132         mkdir "$srcdir"/temp
133         cd "$srcdir"/temp
134         for _subrepo in font-nimbussansl font-xolonium xonotic-data xonotic-music xonotic-maps; do
135                 mkdir $_subrepo
136                 _git_extract "$srcdir"/$_gitname/data/$_subrepo.pk3dir "$srcdir"/temp/$_subrepo
137         done
139         rm -rf "$srcdir"/temp/xonotic-data/qcsrc
140         mv "$srcdir"/src/progs.dat "$srcdir"/src/csprogs.dat "$srcdir"/src/menu.dat "$srcdir"/temp/xonotic-data
142         cd "$srcdir"/temp/xonotic-maps
143         #2x40 question marks. That's as many as eight tens. And that's terrible.
144         for X in "$srcdir"/$_gitname/data/*-????????????????????????????????????????-????????????????????????????????????????.pk3; do
145                 if [ -f "$X" ]; then
146                         unzip "$X"
147                         rm -f maps/*.log maps/*.irc maps/*.lin
148                 fi
149         done
151         msg "Compressing data..."
152         cd "$srcdir"/temp/
153         # don't compress the font files
154         for _subrepo in xonotic-data xonotic-music xonotic-maps; do
155                 _compress $_subrepo "$srcdir"/$_gitname/data/$_subrepo.pk3dir
156         done
158         msg "Packing data..."
159         for _subrepo in font-nimbussansl font-xolonium xonotic-data xonotic-music xonotic-maps; do
160                 cd "$srcdir"/temp/$_subrepo
161                 _mkzip "$srcdir"/$_subrepo.pk3 * # this wildcard excludes dot files
162         done
164         msg "Removing temporary files..."
165         rm -rf "$srcdir"/temp
168 package() {
169         msg "Installing..."
170         mkdir -p "$pkgdir"/opt/$pkgname/
171         _git_extract "$srcdir"/$_gitname/ "$pkgdir"/opt/$pkgname \
172                 Docs \
173                 server \
174                 xonotic-linux-glx.sh xonotic-linux-sdl.sh \
175                 key_0.d0pk
176         chmod 755 "$pkgdir"/opt/$pkgname/xonotic-linux-glx.sh \
177                   "$pkgdir"/opt/$pkgname/xonotic-linux-sdl.sh
179         # Binaries -- those names are needed by the launcher script
180         case "$CARCH" in
181                 x86_64)  _arch="linux64" ;;
182                 *)       _arch="linux32" ;;
183         esac
184         install -m755 "$srcdir"/src/darkplaces/darkplaces-glx "$pkgdir"/opt/$pkgname/xonotic-$_arch-glx
185         install -m755 "$srcdir"/src/darkplaces/darkplaces-glx "$pkgdir"/opt/$pkgname/xonotic-$_arch-sdl
186         install -m755 "$srcdir"/src/darkplaces/darkplaces-dedicated "$pkgdir"/opt/$pkgname/xonotic-$_arch-dedicated
188         mkdir -p "$pkgdir"/opt/$pkgname/data/
189         mv -f "$srcdir"/*.pk3 "$pkgdir"/opt/$pkgname/data || true # those files are too big to be copied
191         # Launch scripts
192         mkdir -p "$pkgdir"/usr/bin
193         mv -f "$pkgdir"/opt/$pkgname/server/server_linux.sh "$pkgdir"/opt/$pkgname/
194         ln -sf /opt/$pkgname/xonotic-linux-glx.sh "$pkgdir"/usr/bin/xonotic-glx
195         ln -sf /opt/$pkgname/xonotic-linux-sdl.sh "$pkgdir"/usr/bin/xonotic-sdl
196         ln -sf /opt/$pkgname/server_linux.sh "$pkgdir"/usr/bin/xonotic-dedicated