From 3ce9294eebec3c6e5189a407842d6bf9effb0bd7 Mon Sep 17 00:00:00 2001 From: Ricardo Ardissone Date: Fri, 15 Apr 2016 20:37:09 -0300 Subject: [PATCH 1/3] freeorion: init at 0.4.5 --- pkgs/games/freeorion/92455f9.patch | 19 +++++++++++++++++++ pkgs/games/freeorion/default.nix | 23 +++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ 3 files changed, 44 insertions(+) create mode 100644 pkgs/games/freeorion/92455f9.patch create mode 100644 pkgs/games/freeorion/default.nix diff --git a/pkgs/games/freeorion/92455f9.patch b/pkgs/games/freeorion/92455f9.patch new file mode 100644 index 000000000000..e40ee78de6df --- /dev/null +++ b/pkgs/games/freeorion/92455f9.patch @@ -0,0 +1,19 @@ +diff -Naur GG/src/Font.cpp +--- /GG/src/Font.cpp ++++ /GG/src/Font.cpp +@@ -1586,8 +1586,13 @@ + using boost::lexical_cast; + FT_UInt index = FT_Get_Char_Index(face, ch); + if (index) { +- if (FT_Load_Glyph(face, index, FT_LOAD_DEFAULT)) +- ThrowBadGlyph("GG::Font::GetGlyphBitmap : Freetype could not load the glyph for character '%1%'", ch); ++ if (FT_Load_Glyph(face, index, FT_LOAD_DEFAULT)) { ++ // loading of a glpyh failed so we replace it with ++ // the 'Replacement Character' at codepoint 0xFFFD ++ FT_UInt tmp_index = FT_Get_Char_Index(face, 0xFFFD); ++ if (FT_Load_Glyph(face, tmp_index, FT_LOAD_DEFAULT)) ++ ThrowBadGlyph("GG::Font::GetGlyphBitmap : Freetype could not load the glyph for character '%1%'", ch); ++ } + + FT_GlyphSlot glyph = face->glyph; + diff --git a/pkgs/games/freeorion/default.nix b/pkgs/games/freeorion/default.nix new file mode 100644 index 000000000000..a3b0a11e177f --- /dev/null +++ b/pkgs/games/freeorion/default.nix @@ -0,0 +1,23 @@ +{ stdenv, fetchurl, cmake, boost, SDL2, python2, freetype, openal, libogg, libvorbis, zlib, libpng, libtiff, libjpeg, mesa, glew, doxygen }: + +stdenv.mkDerivation rec { + version = "0.4.5"; + name = "freeorion-${version}"; + + src = fetchurl { + url = "https://github.com/freeorion/freeorion/releases/download/v0.4.5/FreeOrion_v0.4.5_2015-09-01.f203162_Source.tar.gz"; + sha256 = "3b99b92eeac72bd059566dbabfab54368989ba83f72e769bc94eb8dd4fe414c0"; + }; + + buildInputs = [ cmake boost SDL2 python2 freetype openal libogg libvorbis zlib libpng libtiff libjpeg mesa glew doxygen ]; + + # cherry pick for acceptable performance https://github.com/freeorion/freeorion/commit/92455f97c28055e296718230d2e3744eccd738ec + patches = [ ./92455f9.patch ]; + + meta = with stdenv.lib; { + description = "A free, open source, turn-based space empire and galactic conquest (4X) computer game"; + homepage = "http://www.freeorion.org"; + license = [ licenses.gpl2 licenses.cc-by-sa-30 ]; + platforms = platforms.linux; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f8a5bdb8605f..2dda51bd76c7 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -14686,6 +14686,8 @@ in freedink = callPackage ../games/freedink { }; + freeorion = callPackage ../games/freeorion { }; + fsg = callPackage ../games/fsg { wxGTK = wxGTK28.override { unicode = false; }; }; From 756a83191c1ce3597e9d903e2bd7a89932420e53 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Mon, 18 Apr 2016 16:48:17 +0300 Subject: [PATCH 2/3] freeorion: enable parallel building --- pkgs/games/freeorion/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/games/freeorion/default.nix b/pkgs/games/freeorion/default.nix index a3b0a11e177f..8c3921c12361 100644 --- a/pkgs/games/freeorion/default.nix +++ b/pkgs/games/freeorion/default.nix @@ -14,6 +14,8 @@ stdenv.mkDerivation rec { # cherry pick for acceptable performance https://github.com/freeorion/freeorion/commit/92455f97c28055e296718230d2e3744eccd738ec patches = [ ./92455f9.patch ]; + enableParallelBuilding = true; + meta = with stdenv.lib; { description = "A free, open source, turn-based space empire and galactic conquest (4X) computer game"; homepage = "http://www.freeorion.org"; From d8eec18ce20ae7b0dde087937d4daf78b9619748 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Mon, 18 Apr 2016 16:48:38 +0300 Subject: [PATCH 3/3] freeorion: fix paths in configuration file before start --- pkgs/games/freeorion/default.nix | 20 ++++++++++++++++++-- pkgs/games/freeorion/fix-paths.sh | 6 ++++++ pkgs/games/freeorion/fix-paths.xslt | 13 +++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 pkgs/games/freeorion/fix-paths.sh create mode 100644 pkgs/games/freeorion/fix-paths.xslt diff --git a/pkgs/games/freeorion/default.nix b/pkgs/games/freeorion/default.nix index 8c3921c12361..e143b6ebcf31 100644 --- a/pkgs/games/freeorion/default.nix +++ b/pkgs/games/freeorion/default.nix @@ -1,4 +1,5 @@ -{ stdenv, fetchurl, cmake, boost, SDL2, python2, freetype, openal, libogg, libvorbis, zlib, libpng, libtiff, libjpeg, mesa, glew, doxygen }: +{ stdenv, fetchurl, cmake, boost, SDL2, python2, freetype, openal, libogg, libvorbis, zlib, libpng, libtiff, libjpeg, mesa, glew, doxygen +, libxslt, makeWrapper }: stdenv.mkDerivation rec { version = "0.4.5"; @@ -9,13 +10,28 @@ stdenv.mkDerivation rec { sha256 = "3b99b92eeac72bd059566dbabfab54368989ba83f72e769bc94eb8dd4fe414c0"; }; - buildInputs = [ cmake boost SDL2 python2 freetype openal libogg libvorbis zlib libpng libtiff libjpeg mesa glew doxygen ]; + buildInputs = [ cmake boost SDL2 python2 freetype openal libogg libvorbis zlib libpng libtiff libjpeg mesa glew doxygen makeWrapper ]; # cherry pick for acceptable performance https://github.com/freeorion/freeorion/commit/92455f97c28055e296718230d2e3744eccd738ec patches = [ ./92455f9.patch ]; enableParallelBuilding = true; + postInstall = '' + mkdir -p $out/fixpaths + # We need final slashes for XSLT replace to work properly + substitute ${./fix-paths.xslt} $out/fixpaths/fix-paths.xslt \ + --subst-var-by nixStore "$NIX_STORE/" \ + --subst-var-by out "$out/" + substitute ${./fix-paths.sh} $out/fixpaths/fix-paths \ + --subst-var-by libxsltBin ${libxslt.bin} \ + --subst-var out + chmod +x $out/fixpaths/fix-paths + + wrapProgram $out/bin/freeorion \ + --run $out/fixpaths/fix-paths + ''; + meta = with stdenv.lib; { description = "A free, open source, turn-based space empire and galactic conquest (4X) computer game"; homepage = "http://www.freeorion.org"; diff --git a/pkgs/games/freeorion/fix-paths.sh b/pkgs/games/freeorion/fix-paths.sh new file mode 100644 index 000000000000..cd6f381de255 --- /dev/null +++ b/pkgs/games/freeorion/fix-paths.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +if [ -e ~/.freeorion/config.xml ]; then + @libxsltBin@/bin/xsltproc -o ~/.freeorion/config.xml @out@/fixpaths/fix-paths.xslt ~/.freeorion/config.xml +fi +exit 0 diff --git a/pkgs/games/freeorion/fix-paths.xslt b/pkgs/games/freeorion/fix-paths.xslt new file mode 100644 index 000000000000..f0db646b81ad --- /dev/null +++ b/pkgs/games/freeorion/fix-paths.xslt @@ -0,0 +1,13 @@ + + + + + + + + + + + + +