From 3b4451ade5c4c7d931ab35de9155dddaaf19f8a1 Mon Sep 17 00:00:00 2001
From: Alexander Tsamutali <astsmtl@yandex.ru>
Date: Wed, 4 Jan 2012 16:46:25 +0000
Subject: [PATCH] games/tremulous: Removed rust.

svn path=/nixpkgs/trunk/; revision=31282
---
 pkgs/games/tremulous/default.nix |  9 ++++++++-
 pkgs/games/tremulous/parse.patch | 21 +++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)
 create mode 100644 pkgs/games/tremulous/parse.patch

diff --git a/pkgs/games/tremulous/default.nix b/pkgs/games/tremulous/default.nix
index 0124e2f448b0..a4a887e2ed3d 100644
--- a/pkgs/games/tremulous/default.nix
+++ b/pkgs/games/tremulous/default.nix
@@ -25,6 +25,12 @@ stdenv.mkDerivation rec {
     tar xvf $src3
     cd ..
   '';
+  patches = [ ./parse.patch ];
+  patchFlags = "-p 0";
+  NIX_LD_FLAGS = ''
+    -rpath ${stdenv.gcc}/lib
+    -rpath ${stdenv.gcc}/lib64
+  '';
   buildPhase = ''
     cd Release_1.011
     make
@@ -45,11 +51,12 @@ stdenv.mkDerivation rec {
         cat << EOF > $out/bin/$b
     #!/bin/sh
     cd $out/opt/tremulous
-    ./$b.$arch "$@"
+    exec ./$b.$arch "\$@"
     EOF
         chmod +x $out/bin/$b
     done
   '';
+  dontPatchELF = true;
   meta = {
     description = "A game that blends a team based FPS with elements of an RTS";
     longDescription = ''
diff --git a/pkgs/games/tremulous/parse.patch b/pkgs/games/tremulous/parse.patch
new file mode 100644
index 000000000000..12a73138c099
--- /dev/null
+++ b/pkgs/games/tremulous/parse.patch
@@ -0,0 +1,21 @@
+diff -ruN Release_1.011-old/src/qcommon/parse.c Release_1.011/src/qcommon/parse.c
+--- Release_1.011-old/src/qcommon/parse.c	2011-12-02 19:11:49.307368651 -0500
++++ Release_1.011/src/qcommon/parse.c	2011-12-02 19:13:27.556836387 -0500
+@@ -981,7 +981,7 @@
+ {
+   if (*string == '\"')
+   {
+-    strcpy(string, string+1);
++    memmove(string, string+1, strlen(string));
+   }
+   if (string[strlen(string)-1] == '\"')
+   {
+@@ -1784,7 +1784,7 @@
+     if ((*ptr == '\\' || *ptr == '/') &&
+         (*(ptr+1) == '\\' || *(ptr+1) == '/'))
+     {
+-      strcpy(ptr, ptr+1);
++      memmove(ptr, ptr+1, strlen(ptr));
+     }
+     else
+     {