From c82a9ac9214cf73f9b920b9160959afd06b3a1e4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?=
 <viric@vicerveza.homeunix.net>
Date: Sat, 8 May 2010 21:25:56 +0000
Subject: [PATCH] Updating blender

svn path=/nixpkgs/trunk/; revision=21670
---
 pkgs/applications/misc/blender/default.nix    | 57 ++++++-------------
 .../misc/blender/python-chmod.patch           | 14 +++++
 pkgs/top-level/all-packages.nix               | 16 +++---
 3 files changed, 39 insertions(+), 48 deletions(-)
 create mode 100644 pkgs/applications/misc/blender/python-chmod.patch

diff --git a/pkgs/applications/misc/blender/default.nix b/pkgs/applications/misc/blender/default.nix
index 7ab744f6a36b..2d806cc042d3 100644
--- a/pkgs/applications/misc/blender/default.nix
+++ b/pkgs/applications/misc/blender/default.nix
@@ -1,50 +1,29 @@
-args: with args;
+{stdenv, fetchurl, cmake, mesa, gettext, python, libjpeg, libpng, zlib, openal, SDL
+, openexr, libsamplerate, libXi, libtiff, ilmbase }:
+
 stdenv.mkDerivation {
-  name = "blender-2.48";
+  name = "blender-2.50a";
 
   src = fetchurl {
-    url = http://download.blender.org/source/blender-2.48a.tar.gz;
-    sha256 = "0ijfpy510ls8xq1i8fb6j6wd0vac1jvnzmpiga4g7x1j4fg4s7bq";
+    url = http://download.blender.org/source/blender-2.50a1.tar.gz;
+    sha256 = "1cik05fmf9b8z3qpwsm6q9h1ia87w1piz87hxhfs24jw6l5pyiwr";
   };
 
-  phases="unpackPhase buildPhase";
+  buildInputs = [ cmake mesa gettext python libjpeg libpng zlib openal SDL openexr libsamplerate
+    libXi libtiff ilmbase ];
 
-  inherit scons SDL freetype openal python openexr mesa;
+  cmakeFlags = [ "-DOPENEXR_INC=${openexr}/include/OpenEXR" "-DWITH_OPENCOLLADA=OFF"
+    "-DPYTHON_LIBPATH=${python}/lib" ];
 
-  buildInputs = [python scons
-         gettext libjpeg libpng zlib freetype /* fmod smpeg */ freealut openal x11 mesa inputproto libtiff libXi 
-         ];
+  NIX_CFLAGS_COMPILE = "-iquote ${ilmbase}/include/OpenEXR -I${python}/include/${python.libPrefix}";
 
-  # patch SConstruct so that we can pass on additional include.  Either blender
-  # or openEXR is broken. I think OpenEXR should use include "" isntead of <> to
-  # include files beeing in the same directory
-  buildPhase = "
-cat >> user-config.py << EOF
-WITH_BF_OPENAL = 'true'
-WITH_BF_GAMEENGINE='true'
-WITH_BF_BULLET = 'true'
-WITH_BF_INTERNATIONAL = 'true'
-WITH_BF_OPENEXR = 'true'
-EOF
-
-    sed -i -e \"s=##### END SETUP ##########=env['CPPFLAGS'].append(os.getenv('CPPFLAGS').split(':'))\\n##### END SETUP ##########=\" SConstruct\n"
-    + " CPPFLAGS=-I$openexr/include/OpenEXR"
-    + " scons PREFIX=\$out/nix-support"
-    + " BF_SDL=\$SDL"
-    + " BF_SDL_LIBPATH=\$SDL/lib"
-    + " BF_FREETYPE=\$freetype"
-    + " BF_OPENAL=\$openal"
-    + " BF_PYTHON=\$python"
-    + " BF_OPENEXR_INC=\$openexr/include"
-    + " BF_OPENEXR_LIBPATH=\$openexr/lib"
-    + " BF_INSTALLDIR=\$out/nix-support/dontLinkThatMuch \n"
-    + " ensureDir \$out/bin\n"
-    + " ln -s \$out/nix-support/dontLinkThatMuch/blender \$out/bin/blender"
-    ;
+  patches = [ ./python-chmod.patch ];
 
   meta = { 
-      description = "3D Creation/Animation/Publishing System";
-      homepage = http://www.blender.org;
-      license = "GPL-2 BL";
-    };
+    description = "3D Creation/Animation/Publishing System";
+    homepage = http://www.blender.org;
+    # They comment two licenses: GPLv2 and Blender License, but they
+    # say: "We've decided to cancel the BL offering for an indefinite period."
+    license = "GPLv2+";
+  };
 }
diff --git a/pkgs/applications/misc/blender/python-chmod.patch b/pkgs/applications/misc/blender/python-chmod.patch
new file mode 100644
index 000000000000..bda04b1cbb41
--- /dev/null
+++ b/pkgs/applications/misc/blender/python-chmod.patch
@@ -0,0 +1,14 @@
+As the code copied from the nix store, the files there do not have the 'writeable' permission.
+Hence this fix, needed on nix but not on usual LSB linuces.
+diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
+index 386ef1b..6a180fa 100644
+--- a/source/creator/CMakeLists.txt
++++ b/source/creator/CMakeLists.txt
+@@ -152,6 +152,7 @@ IF(WITH_INSTALL)
+ 				COMMAND mkdir ${TARGETDIR}/.blender/python # PYTHONPATH and PYTHONHOME is set here
+ 				COMMAND mkdir ${TARGETDIR}/.blender/python/lib/
+ 				COMMAND cp -R ${PYTHON_LIBPATH}/python${PYTHON_VERSION} ${TARGETDIR}/.blender/python/lib/
++        COMMAND chmod -R +w ${TARGETDIR}/.blender/python/lib/
+         
+ 				COMMAND rm -rf ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION}/distutils
+ 				COMMAND rm -rf ${TARGETDIR}/.blender/python/lib/python${PYTHON_VERSION}/lib2to3
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index f34a369b41f2..6848c1f244b5 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -4920,6 +4920,8 @@ let
     version = "1.4.0";
   };
 
+  openexr = openexr_1_6_1;
+
   openldap = import ../development/libraries/openldap {
     inherit fetchurl stdenv openssl cyrus_sasl db4 groff;
   };
@@ -7119,15 +7121,11 @@ let
   };
 
   blender = import ../applications/misc/blender {
-    inherit cmake mesa gettext freetype SDL libtiff fetchurl glibc scons x11 lib
-      libjpeg libpng zlib /* smpeg sdl */ python;
-    inherit (xlibs) inputproto libXi;
-    freealut = freealut_soft;
-    openal = openalSoft;
-    openexr = openexr_1_4_0;
-    # using gcc43 makes blender segfault when pressing p then esc.
-    # is this related to the PHP bug? I'm to lazy to try recompilng it without optimizations
-    stdenv = overrideGCC stdenv gcc42;
+    inherit fetchurl cmake mesa gettext libjpeg libpng zlib openal SDL openexr
+      libsamplerate libtiff ilmbase;
+    inherit (xlibs) libXi;
+    python = python31Base;
+    stdenv = stdenv2;
   };
 
   bmp = import ../applications/audio/bmp {