dwarf-{fortress,therapist}: Update

DwarfTherapist does some ugly stuff by matching the first 8 characters
of the md5sum of the game binary to match its binary content. This patch
adds support to automatically patch the ini files.
This commit is contained in:
Moritz Ulrich 2014-12-15 22:13:51 +01:00
parent 997531d172
commit 54f3587549
2 changed files with 28 additions and 29 deletions

View File

@ -4,17 +4,17 @@
let
baseVersion = "40";
patchVersion = "18";
patchVersion = "19";
srcs = {
df_unfuck = fetchgit {
url = "https://github.com/svenstaro/dwarf_fortress_unfuck";
rev = "f7ef8d4fa92bcbbf8e4790056c6c3668e3c3b20b";
sha256 = "0kpb3gzjllvi1lahhi74cp2ny1dl7kvnhdlca7i2yxkmyzaaj9qy";
rev = "dadf3d48e93a2800db5d4f98d775ba8453ca55a4";
sha256 = "011pbcfc3a0mnwqg3pkhngnb1h7z1jbx4qbvj03blpzfjia075sv";
};
df = fetchurl {
url = "http://www.bay12games.com/dwarves/df_${baseVersion}_${patchVersion}_linux.tar.bz2";
sha256 = "0l29dn24xhkyj8fvmz8318i5sz2wpl420mwy1ccpdd3yfd3hrjmb";
sha256 = "16xb6py7l1hf9hc7gn50nwajqgmv01zdhbkh7g6a8gnx7wlhl2p9";
};
};
@ -25,6 +25,7 @@ assert stdenv.system == "i686-linux";
stdenv.mkDerivation rec {
name = "dwarf-fortress-0.${baseVersion}.${patchVersion}";
inherit baseVersion patchVersion;
buildInputs = [ SDL SDL_image SDL_ttf gtk2 glib glew mesa ncurses openal glibc libsndfile pango atk cmake gdk_pixbuf];
src = "${srcs.df_unfuck} ${srcs.df}";
@ -46,6 +47,10 @@ stdenv.mkDerivation rec {
cd ../../
cp -r ./df_linux/* $out/share/df_linux
rm $out/share/df_linux/libs/lib*
# Store the original hash for dwarf-therapist
echo $(md5sum $out/share/df_linux/libs/Dwarf_Fortress | cut -c1-8) > $out/share/df_linux/hash.md5.orig
# Fix rpath
patchelf --set-rpath "${stdenv.lib.makeLibraryPath [ stdenv.gcc.gcc stdenv.glibc ]}:$out/share/df_linux/libs" $out/share/df_linux/libs/Dwarf_Fortress
cp -f ./git-export/build/libgraphics.so $out/share/df_linux/libs/libgraphics.so
@ -53,6 +58,9 @@ stdenv.mkDerivation rec {
patchelf --set-interpreter ${glibc}/lib/ld-linux.so.2 $out/share/df_linux/libs/Dwarf_Fortress
# Store new hash for dwarf-therapist
echo $(md5sum $out/share/df_linux/libs/Dwarf_Fortress | cut -c1-8) > $out/share/df_linux/hash.md5.patched
cat > $out/bin/dwarf-fortress << EOF
#!${stdenv.shell}

View File

@ -1,39 +1,30 @@
{ stdenv, coreutils, fetchhg, qt4, dwarf_fortress, bash, makeWrapper }:
{ stdenv, coreutils, fetchurl, qt4, dwarf_fortress, bash, makeWrapper }:
let
version = "30.1.0";
df = dwarf_fortress;
in
stdenv.mkDerivation rec {
name = "dwarf-therapist-${rev}";
rev = "eeeac8544d94";
name = "dwarf-therapist-${version}";
src = fetchhg {
url = "https://code.google.com/r/splintermind-attributes/";
inherit rev;
sha256 = "0a9m967q6p2q3plrl6qysg1xrdmg65jzil6awjh2wr3g10x2x15z";
src = fetchurl {
url = "https://github.com/splintermind/Dwarf-Therapist/archive/v${version}.tar.gz";
sha256 = "1x9dkis6b3f8iqcfrc2cj9mcgkwf0rzhxhq2lgy4xdr2n0yjkyv7";
};
# Needed for hashing
dwarfBinary = "${dwarf_fortress}/share/df_linux/libs/Dwarf_Fortress";
dfHashFile = "${df}/share/df_linux/hash.md5";
buildInputs = [ coreutils qt4 dwarf_fortress makeWrapper ];
buildInputs = [ coreutils qt4 df makeWrapper ];
enableParallelBuilding = false;
preConfigure = ''
configurePhase = ''
substituteInPlace dwarftherapist.pro \
--replace /usr/bin $out/bin \
--replace /usr/share $out/share \
--replace "INSTALLS += doc" ""
'';
preBuild = ''
# Log to current directory, otherwise it crashes if log/ doesn't
# exist Note: Whis is broken because we cd to the nix store in the
# wrapper-script
substituteInPlace src/dwarftherapist.cpp \
--replace "log/run.log" "dwarf-therapist.log"
'';
buildPhase = ''
qmake INSTALL_PREFIX=$out;
make;
qmake INSTALL_PREFIX=$out
'';
postInstall = ''
@ -46,8 +37,8 @@ stdenv.mkDerivation rec {
postFixup = ''
# Fix checksum of memory access directives
substituteInPlace $out/share/dwarftherapist/etc/memory_layouts/linux/v034.11.ini \
--replace "e966ee88" $(md5sum ${dwarfBinary} | cut -c1-8)
substituteInPlace $out/share/dwarftherapist/memory_layouts/linux/v0${df.baseVersion}.${df.patchVersion}.ini \
--replace $(cat "${dfHashFile}.orig") $(cat "${dfHashFile}.patched")
'';
meta = {
@ -58,4 +49,4 @@ stdenv.mkDerivation rec {
hydraPlatforms = [];
homepage = https://code.google.com/r/splintermind-attributes/;
};
}
}