diff options
author | aszlig <aszlig@redmoonstudios.org> | 2017-09-13 06:40:44 +0200 |
---|---|---|
committer | aszlig <aszlig@redmoonstudios.org> | 2017-09-13 15:26:39 +0200 |
commit | 633e7e8021e82dc831869071489412a8a2e50909 (patch) | |
tree | 63dd165fe224042f7d98c360b9b32684282c6942 /pkgs | |
parent | 217818dbb80b54ca9eac240c169e8c015a145dc7 (diff) |
pkgs/build-game: Try to evade tarbombs
A lot of games (especially Unity games) come as a tarbomb, so in order to avoid having those files all over the place we now create an additional directory before unpack and set the sourceRoot to that if it's a tarbomb and if that's not the case set it to the single file within that directory. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/games/build-support/build-game.nix | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/pkgs/games/build-support/build-game.nix b/pkgs/games/build-support/build-game.nix index 46ed83df..5117b330 100644 --- a/pkgs/games/build-support/build-game.nix +++ b/pkgs/games/build-support/build-game.nix @@ -4,6 +4,8 @@ assert withPulseAudio -> libpulseaudio != null; { buildInputs ? [] , nativeBuildInputs ? [] +, preUnpack ? "" +, setSourceRoot ? "" , installCheckPhase ? "" , runtimeDependencies ? [] , ... @@ -16,6 +18,23 @@ stdenv.mkDerivation ({ file ./setup-hooks/auto-patchelf.sh ] ++ nativeBuildInputs; + preUnpack = preUnpack + '' + mkdir "$name" + pushd "$name" &> /dev/null + ''; + + # Try to evade tarbombs + setSourceRoot = '' + popd &> /dev/null + '' + lib.optionalString (setSourceRoot == "") '' + unpackedFiles="$(find "$name" -mindepth 1 -maxdepth 1 -print)" + if [ $(echo "$unpackedFiles" | wc -l) -gt 1 ]; then + sourceRoot="$name" + else + sourceRoot="$name/''${unpackedFiles##*/}" + fi + ''; + runtimeDependencies = let deps = lib.optional withPulseAudio libpulseaudio ++ runtimeDependencies; in map (dep: dep.lib or dep) deps; @@ -45,5 +64,6 @@ stdenv.mkDerivation ({ dontStrip = true; dontPatchELF = true; } // removeAttrs attrs [ - "buildInputs" "nativeBuildInputs" "installCheckPhase" "runtimeDependencies" + "buildInputs" "nativeBuildInputs" "preUnpack" "setSourceRoot" + "installCheckPhase" "runtimeDependencies" ]) |