3
0
Fork 0
forked from mirrors/nixpkgs

Fix dfhack's Dwarf Fortress MD5 in the correct environment

This commit is contained in:
Morgan Jones 2018-07-15 03:58:37 +00:00
parent 4ada74e293
commit f14d3b4795
2 changed files with 45 additions and 27 deletions

View file

@ -30,11 +30,17 @@ in symlinkJoin {
# Fix up memory layouts
rm -rf $out/share/dwarftherapist/memory_layouts/linux
mkdir -p $out/share/dwarftherapist/memory_layouts/linux
origmd5=$(cat "${dwarf-fortress}/hash.md5.orig" | cut -c1-8)
patchedmd5=$(cat "${dwarf-fortress}/hash.md5" | cut -c1-8)
substitute \
${dwarf-therapist}/share/dwarftherapist/memory_layouts/${inifile} \
$out/share/dwarftherapist/memory_layouts/${inifile} \
--replace "$origmd5" "$patchedmd5"
orig_md5=$(cat "${dwarf-fortress}/hash.md5.orig" | cut -c1-8)
patched_md5=$(cat "${dwarf-fortress}/hash.md5" | cut -c1-8)
input_file="${dwarf-therapist}/share/dwarftherapist/memory_layouts/${inifile}"
output_file="$out/share/dwarftherapist/memory_layouts/${inifile}"
echo "[Dwarf Therapist Wrapper] Fixing Dwarf Fortress MD5 prefix:"
echo " Input: $input_file"
echo " Search: $orig_md5"
echo " Output: $output_file"
echo " Replace: $patched_md5"
substitute "$input_file" "$output_file" --replace "$orig_md5" "$patched_md5"
'';
}

View file

@ -37,6 +37,39 @@ let
paths = themePkg ++ pkgs;
pathsToLink = [ "/" "/hack" "/hack/scripts" ];
postBuild = ''
# De-symlink init.txt
cp $out/data/init/init.txt init.txt
rm -f $out/data/init/init.txt
mv init.txt $out/data/init/init.txt
'' + lib.optionalString enableDFHack ''
# De-symlink symbols.xml
rm $out/hack/symbols.xml
# Patch the MD5
orig_md5=$(cat "${dwarf-fortress}/hash.md5.orig")
patched_md5=$(cat "${dwarf-fortress}/hash.md5")
input_file="${dfhack_}/hack/symbols.xml"
output_file="$out/hack/symbols.xml"
echo "[DFHack Wrapper] Fixing Dwarf Fortress MD5:"
echo " Input: $input_file"
echo " Search: $orig_md5"
echo " Output: $output_file"
echo " Replace: $patched_md5"
substitute "$input_file" "$output_file" --replace "$orig_md5" "$patched_md5"
'' + lib.optionalString enableTWBT ''
substituteInPlace $out/data/init/init.txt \
--replace '[PRINT_MODE:2D]' '[PRINT_MODE:TWBT]'
'' + ''
substituteInPlace $out/data/init/init.txt \
--replace '[INTRO:YES]' '[INTRO:${unBool enableIntro}]' \
--replace '[TRUETYPE:YES]' '[TRUETYPE:${unBool enableTruetype}]' \
--replace '[FPS:NO]' '[FPS:${unBool enableFPS}]'
'';
ignoreCollisions = true;
};
in
@ -78,26 +111,5 @@ stdenv.mkDerivation rec {
chmod 755 $out/bin/soundsense
'';
postBuild = ''
# De-symlink init.txt
cp $out/data/init/init.txt init.txt
rm $out/data/init/init.txt
mv init.txt $out/data/init/init.txt
'' + lib.optionalString enableDFHack ''
rm $out/hack/symbols.xml
echo "[$out/hack/symbols.xml] $(cat ${dwarf-fortress}/hash.md5.orig) => $(cat ${dwarf-fortress}/hash.md5)"
substitute ${dfhack_}/hack/symbols.xml $out/hack/symbols.xml \
--replace $(cat ${dwarf-fortress}/hash.md5.orig) \
$(cat ${dwarf-fortress}/hash.md5)
'' + lib.optionalString enableTWBT ''
substituteInPlace $out/data/init/init.txt \
--replace '[PRINT_MODE:2D]' '[PRINT_MODE:TWBT]'
'' + ''
substituteInPlace $out/data/init/init.txt \
--replace '[INTRO:YES]' '[INTRO:${unBool enableIntro}]' \
--replace '[TRUETYPE:YES]' '[TRUETYPE:${unBool enableTruetype}]' \
--replace '[FPS:NO]' '[FPS:${unBool enableFPS}]'
'';
preferLocalBuild = true;
}