ut2004demo: refactor, 3120 -> 3334

+98 -77
+9
pkgs/games/ut2004/default.nix
··· 1 + { callPackage }: 2 + 3 + { 4 + ut2004-demo = callPackage ./demo.nix { }; 5 + 6 + ut2004 = gamePacks: callPackage ./wrapper.nix { 7 + inherit gamePacks; 8 + }; 9 + }
+40
pkgs/games/ut2004/demo.nix
··· 1 + { stdenv, fetchurl }: 2 + 3 + let 4 + arch = 5 + if stdenv.system == "x86_64-linux" then "amd64" 6 + else if stdenv.system == "i686-linux" then "x86" 7 + else throw "Unsupported architecture"; 8 + 9 + in stdenv.mkDerivation rec { 10 + name = "ut2004-demo-${version}"; 11 + version = "3334"; 12 + 13 + src = fetchurl { 14 + url = "http://treefort.icculus.org/ut2004/UT2004-LNX-Demo${version}.run.gz"; 15 + sha256 = "0d5f84qz8l1rg16yzx2k4ikr46n9iwj68na1bqi87wrww7ck6jh7"; 16 + }; 17 + 18 + buildCommand = '' 19 + cat $src | gunzip > setup.run 20 + chmod +x setup.run 21 + ./setup.run --noexec --target . 22 + mkdir $out 23 + tar -xaf ut2004demo.tar.bz2 -C $out 24 + tar -xaf linux-${arch}.tar.bz2 -C $out 25 + 26 + rm $out/System/libSDL-1.2.so.0 27 + rm $out/System/openal.so 28 + ''; 29 + 30 + dontStrip = true; 31 + dontPatchELF = true; 32 + 33 + meta = with stdenv.lib; { 34 + description = "A first-person shooter video game developed by Epic Games and Digital Extreme -- demo version"; 35 + homepage = "http://www.unrealtournament2004.com"; 36 + license = licenses.unfree; 37 + maintainers = with maintainers; [ abbradar ]; 38 + platforms = [ "x86_64-linux" "i686-linux" ]; 39 + }; 40 + }
+46
pkgs/games/ut2004/wrapper.nix
··· 1 + { stdenv, lib, runCommand, buildEnv, makeWrapper, makeDesktopItem, gamePacks, libstdcxx5, SDL, openal }: 2 + 3 + let 4 + game = buildEnv { 5 + name = "ut2004-game"; 6 + paths = gamePacks; 7 + ignoreCollisions = true; 8 + pathsToLink = [ "/" "/System" ]; 9 + postBuild = '' 10 + ln -s ${lib.getLib SDL}/lib/libSDL-1.2.so.0 $out/System 11 + ln -s ${lib.getLib openal}/lib/libopenal.so $out/System/openal.so 12 + for i in $out/System/*-bin; do 13 + path="$(readlink -f "$i")" 14 + rm "$i" 15 + cp "$path" "$i" 16 + chmod +w "$i" 17 + patchelf \ 18 + --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) \ 19 + --set-rpath "$out/System:${lib.makeLibraryPath [ libstdcxx5 ]}" \ 20 + "$i" 21 + done 22 + ''; 23 + }; 24 + 25 + desktop = makeDesktopItem { 26 + name = "ut2004"; 27 + desktopName = "Unreal Tournament 2004"; 28 + comment = "A first-person shooter video game developed by Epic Games and Digital Extreme"; 29 + genericName = "First-person shooter"; 30 + categories = "Application;Game;"; 31 + exec = "ut2004"; 32 + }; 33 + 34 + in runCommand "ut2004" { 35 + nativeBuildInputs = [ makeWrapper ]; 36 + } '' 37 + mkdir -p $out/bin 38 + for i in ${game}/System/*-bin; do 39 + name="$(basename "$i")" 40 + makeWrapper $i $out/bin/''${name%-bin} \ 41 + --run "cd ${game}/System" 42 + done 43 + 44 + mkdir -p $out/share/applications 45 + ln -s ${desktop}/share/applications/* $out/share/applications 46 + ''
-29
pkgs/games/ut2004demo/builder.sh
··· 1 - source $stdenv/setup 2 - 3 - skip=7976 4 - 5 - bunzip2 < $src | (dd bs=1 count=$skip of=/dev/null && dd bs=1M) | tar xvf - ut2004demo.tar 6 - 7 - mkdir $out 8 - 9 - (cd $out && tar xvf -) < ut2004demo.tar 10 - 11 - 12 - # Patch the executable from ELF OS/ABI type `Linux' (3) to `SVR4' (0). 13 - # This doesn't seem to matter to ld-linux.so.2 at all, except that it 14 - # refuses to load `Linux' executables when invokes explicitly, that 15 - # is, when we do `ld-linux.so.2 $out/System/ut2004-bin', which we need 16 - # to override the hardcoded ELF interpreter with our own. 17 - 18 - # This is a horrible hack, of course. A better solution would be to 19 - # patch Glibc so it accepts the `Linux' ELF type as well (why doesn't 20 - # it?); or to use FreeBSD's `brandelf' program to set to ELF type 21 - # (which is a bit cleaner than patching using `dd' :-) ). 22 - 23 - #(cd $out/System && (echo -en "\000" | dd bs=1 seek=7 of=ut2004-bin conv=notrunc)) 24 - 25 - 26 - # Set the ELF interpreter to our own Glibc. 27 - for i in "$out/System/ucc-bin" "$out/System/ut2004-bin"; do 28 - patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$i" 29 - done
-34
pkgs/games/ut2004demo/default.nix
··· 1 - {stdenv, fetchurl, xorg, mesa}: 2 - 3 - assert stdenv.system == "i686-linux"; 4 - 5 - let { 6 - 7 - raw = stdenv.mkDerivation { 8 - name = "ut2004-demo-3120"; 9 - src = fetchurl { 10 - urls = [ 11 - ("http://store.node-10.ds-servers.com/file/BcFLgoIgAADQA7kw0qZctDAF+4cj" 12 - + "mbnDMFOJTAyM0-cejkEIuDvQ6Uv9ZbvcWMnRmXXxhA0LyvzoKdvsnXne0D1DGTLiR0" 13 - + "I1CmM2M-E5ryH-tD3yweCXyNyH1WGI3Wh09ja29mHtzGF1rxEyhRfQ7ggCKdfCrhvz" 14 - + "H9oTJXSCAtGuSKdVDhe6tNtrqa151MIircZtRLPxQcGmJ+n3-iUeWYgHuqbmrK4ur7" 15 - + "Qcy6QrAhYa+e5jcfYjgPF3VGsw4qx+0ilxJUCiuYCX2H8A6X3rxJILa26w3O425W2G" 16 - + "kHPiQWrhFT8cIOyqSr8+dMO5Xi5-/ut2004-lnx-demo-3120.run.bz2") 17 - http://ftp.gameaholic.com/pub/demos/ut2004-lnx-demo-3120.run.bz2 18 - ]; 19 - sha256 = "1lravfkb1gsallqqird5dcbz42vwjg36m1qk76nmmnyyyghwqnli"; 20 - }; 21 - builder = ./builder.sh; 22 - }; 23 - 24 - body = stdenv.mkDerivation { 25 - name = raw.name; 26 - builder = ./make-wrapper.sh; 27 - inherit raw mesa; 28 - inherit (xorg) libX11 libXext; 29 - }; 30 - 31 - } 32 - 33 - # http://mirror1.icculus.org/ut2004/ut2004-lnxpatch3204.tar.bz2 34 - # 5f659552095b878a029b917d216d9664
-13
pkgs/games/ut2004demo/make-wrapper.sh
··· 1 - source $stdenv/setup 2 - 3 - mkdir -p $out/bin 4 - 5 - cat > $out/bin/ut2004demo <<EOF 6 - #! $SHELL -e 7 - 8 - cd $raw/System 9 - 10 - LD_LIBRARY_PATH=$libX11/lib:$libXext/lib\${LD_LIBRARY_PATH:+:}\$LD_LIBRARY_PATH ./ut2004-bin "\$@" 11 - EOF 12 - 13 - chmod +x $out/bin/ut2004demo
+3 -1
pkgs/top-level/all-packages.nix
··· 16199 16199 16200 16200 ue4demos = recurseIntoAttrs (callPackage ../games/ue4demos { }); 16201 16201 16202 - ut2004demo = callPackage_i686 ../games/ut2004demo { }; 16202 + ut2004Packages = callPackage ../games/ut2004 { }; 16203 + 16204 + ut2004demo = self.ut2004Packages.ut2004 [ self.ut2004Packages.ut2004-demo ]; 16203 16205 16204 16206 vapor = callPackage ../games/vapor { love = love_0_8; }; 16205 16207