Merge pull request #18259 from abbradar/ut2004

Update and refactor UT2004
This commit is contained in:
Nikolay Amiantov 2016-09-18 00:07:49 +04:00 committed by GitHub
commit d997f4581c
9 changed files with 268 additions and 77 deletions

View File

@ -0,0 +1,115 @@
{ stdenv, fetchurl, fetchpatch, flex, bison, file }:
stdenv.mkDerivation rec {
name = "libstdc++5-${version}";
version = "3.3.6";
src = [
(fetchurl {
url = "mirror://gcc/releases/gcc-${version}/gcc-core-${version}.tar.bz2";
sha256 = "1dpyrpsgakilz2rnh5f8gvrzq5pwzvndacc0df6m04bpqn5fx6sg";
})
(fetchurl {
url = "mirror://gcc/releases/gcc-${version}/gcc-g++-${version}.tar.bz2";
sha256 = "14lxl81f7adpc9jxfiwzdxsdzs5zv4piv8xh7f9w910hfzrgvsby";
})
];
patches = [
./no-sys-dirs.patch
(fetchpatch {
name = "siginfo.patch";
url = "https://git.archlinux.org/svntogit/packages.git/plain/trunk/siginfo.patch?h=packages/libstdc%2B%2B5&id=e36ee8ed9bb5942db14cf6249a2ead14974a2bfa";
sha256 = "15zldbm33yba293dgrgsbv3j332hkc3iqpyc8fa7zl42mh9qk22j";
addPrefixes = true;
})
(fetchpatch {
name = "gcc-3.4.3-no_multilib_amd64.patch";
url = "https://git.archlinux.org/svntogit/packages.git/plain/trunk/gcc-3.4.3-no_multilib_amd64.patch?h=packages/libstdc%2B%2B5&id=e36ee8ed9bb5942db14cf6249a2ead14974a2bfa";
sha256 = "11m5lc51b0addhc4yq4rz0dwpv6k73rrj73wya3lqdk8rly6cjpm";
addPrefixes = true;
})
];
postPatch = ''
# fix build issue with recent gcc
sed -i "s#O_CREAT#O_CREAT, 0666#" gcc/collect2.c
# No fixincludes
sed -i -e 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
'';
preConfigure = ''
mkdir ../build
cd ../build
configureScript=../$sourceRoot/configure
'';
preBuild = ''
# libstdc++ needs this; otherwise it will use /lib/cpp, which is a Bad
# Thing.
export CPP="gcc -E"
# Use *real* header files, otherwise a limits.h is generated
# that does not include Glibc's limits.h (notably missing
# SSIZE_MAX, which breaks the build).
export NIX_FIXINC_DUMMY="$(cat $NIX_CC/nix-support/orig-libc-dev)/include"
# The path to the Glibc binaries such as `crti.o'.
glibc_libdir="$(cat $NIX_CC/nix-support/orig-libc)/lib"
# Figure out what extra flags to pass to the gcc compilers
# being generated to make sure that they use our glibc.
EXTRA_FLAGS="-I$NIX_FIXINC_DUMMY $(cat $NIX_CC/nix-support/libc-cflags) -O2"
extraLDFlags="-L$glibc_libdir -rpath $glibc_libdir $(cat $NIX_CC/nix-support/libc-ldflags) $(cat $NIX_CC/nix-support/libc-ldflags-before)"
for i in $extraLDFlags; do
EXTRA_FLAGS="$EXTRA_FLAGS -Wl,$i"
done
# CFLAGS_FOR_TARGET are needed for the libstdc++ configure script to find
# the startfiles.
# FLAGS_FOR_TARGET are needed for the target libraries to receive the -Bxxx
# for the startfiles.
makeFlagsArray=( \
"''${makeFlagsArray[@]}" \
NATIVE_SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \
CFLAGS_FOR_BUILD="$EXTRA_FLAGS" \
CFLAGS_FOR_TARGET="$EXTRA_FLAGS" \
CXXFLAGS_FOR_BUILD="$EXTRA_FLAGS" \
CXXFLAGS_FOR_TARGET="$EXTRA_FLAGS" \
FLAGS_FOR_TARGET="$EXTRA_FLAGS" \
LDFLAGS_FOR_BUILD="$EXTRA_FLAGS" \
LDFLAGS_FOR_TARGET="$EXTRA_FLAGS" \
BOOT_CFLAGS="$EXTRA_FLAGS" \
BOOT_LDFLAGS="$EXTRA_FLAGS"
)
'';
hardeningDisable = [ "format" ];
nativeBuildInputs = [ flex bison file ];
configureFlags = [ "--disable-multilib" "--enable-__cxa-atexit" "--enable-threads=posix" "--enable-languages=c++" "--enable-clocale=gnu" ];
buildFLags = [ "all-target-libstdc++-v3" ];
installFlags = [ "install-target-libstdc++-v3" ];
postInstall = ''
# Remove includefiles and libs provided by gcc
shopt -s extglob
rm -rf $out/{bin,include,share,man,info}
rm -f $out/lib/*.a
rm -rf $out/lib/!(libstdc++*)
'';
meta = with stdenv.lib; {
homepage = http://gcc.gnu.org/;
license = licenses.lgpl3Plus;
description = "GNU Compiler Collection, version ${version} -- C++ standard library";
platforms = platforms.linux;
maintainers = with maintainers; [ abbradar ];
};
}

View File

@ -0,0 +1,53 @@
diff -ru3 gcc-3.3.6-old/gcc/cppdefault.c gcc-3.3.6/gcc/cppdefault.c
--- gcc-3.3.6-old/gcc/cppdefault.c 2003-11-07 02:13:31.000000000 +0300
+++ gcc-3.3.6/gcc/cppdefault.c 2016-09-02 16:00:03.492484016 +0300
@@ -26,6 +26,10 @@
#include "system.h"
#include "cppdefault.h"
+#undef LOCAL_INCLUDE_DIR
+#undef SYSTEM_INCLUDE_DIR
+#undef STANDARD_INCLUDE_DIR
+
const struct default_include cpp_include_defaults[]
#ifdef INCLUDE_DEFAULTS
= INCLUDE_DEFAULTS;
diff -ru3 gcc-3.3.6-old/gcc/gcc.c gcc-3.3.6/gcc/gcc.c
--- gcc-3.3.6-old/gcc/gcc.c 2004-04-01 20:55:17.000000000 +0400
+++ gcc-3.3.6/gcc/gcc.c 2016-09-02 16:01:24.843520114 +0300
@@ -6130,10 +6130,6 @@
NULL, PREFIX_PRIORITY_LAST, 0, NULL, 1);
}
- add_sysrooted_prefix (&startfile_prefixes, standard_startfile_prefix_1,
- "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1);
- add_sysrooted_prefix (&startfile_prefixes, standard_startfile_prefix_2,
- "BINUTILS", PREFIX_PRIORITY_LAST, 0, NULL, 1);
#if 0 /* Can cause surprises, and one can use -B./ instead. */
add_prefix (&startfile_prefixes, "./", NULL,
PREFIX_PRIORITY_LAST, 1, NULL, 0);
diff -ru3 gcc-3.3.6-old/gcc/Makefile.in gcc-3.3.6/gcc/Makefile.in
--- gcc-3.3.6-old/gcc/Makefile.in 2004-04-01 20:55:23.000000000 +0400
+++ gcc-3.3.6/gcc/Makefile.in 2016-09-02 16:00:03.493484017 +0300
@@ -260,7 +260,11 @@
PARTITION_H = $(srcdir)/../include/partition.h
# Default native SYSTEM_HEADER_DIR, to be overridden by targets.
-NATIVE_SYSTEM_HEADER_DIR = /usr/include
+# Nix: we override NATIVE_SYSTEM_HEADER_DIR in order to prevent
+# `fixinc' from fixing header files in /usr/include. However,
+# NATIVE_SYSTEM_HEADER_DIR must point to an existing directory, so set
+# it to some dummy directory.
+NATIVE_SYSTEM_HEADER_DIR = $(NIX_FIXINC_DUMMY)
# Default cross SYSTEM_HEADER_DIR, to be overridden by targets.
CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@
@@ -2201,7 +2205,7 @@
-DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
-DGPLUSPLUS_TOOL_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/$(target_alias)\" \
-DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/backward\" \
- -DLOCAL_INCLUDE_DIR=\"$(local_includedir)\" \
+ -DLOCAL_INCLUDE_DIR=\"/no-such-dir\" \
-DCROSS_INCLUDE_DIR=\"$(CROSS_SYSTEM_HEADER_DIR)\" \
-DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
@TARGET_SYSTEM_ROOT_DEFINE@

View File

@ -0,0 +1,9 @@
{ callPackage }:
{
ut2004-demo = callPackage ./demo.nix { };
ut2004 = gamePacks: callPackage ./wrapper.nix {
inherit gamePacks;
};
}

View File

@ -0,0 +1,40 @@
{ stdenv, fetchurl }:
let
arch =
if stdenv.system == "x86_64-linux" then "amd64"
else if stdenv.system == "i686-linux" then "x86"
else throw "Unsupported architecture";
in stdenv.mkDerivation rec {
name = "ut2004-demo-${version}";
version = "3334";
src = fetchurl {
url = "http://treefort.icculus.org/ut2004/UT2004-LNX-Demo${version}.run.gz";
sha256 = "0d5f84qz8l1rg16yzx2k4ikr46n9iwj68na1bqi87wrww7ck6jh7";
};
buildCommand = ''
cat $src | gunzip > setup.run
chmod +x setup.run
./setup.run --noexec --target .
mkdir $out
tar -xaf ut2004demo.tar.bz2 -C $out
tar -xaf linux-${arch}.tar.bz2 -C $out
rm $out/System/libSDL-1.2.so.0
rm $out/System/openal.so
'';
dontStrip = true;
dontPatchELF = true;
meta = with stdenv.lib; {
description = "A first-person shooter video game developed by Epic Games and Digital Extreme -- demo version";
homepage = "http://www.unrealtournament2004.com";
license = licenses.unfree;
maintainers = with maintainers; [ abbradar ];
platforms = [ "x86_64-linux" "i686-linux" ];
};
}

View File

@ -0,0 +1,46 @@
{ stdenv, lib, runCommand, buildEnv, makeWrapper, makeDesktopItem, gamePacks, libstdcxx5, SDL, openal }:
let
game = buildEnv {
name = "ut2004-game";
paths = gamePacks;
ignoreCollisions = true;
pathsToLink = [ "/" "/System" ];
postBuild = ''
ln -s ${lib.getLib SDL}/lib/libSDL-1.2.so.0 $out/System
ln -s ${lib.getLib openal}/lib/libopenal.so $out/System/openal.so
for i in $out/System/*-bin; do
path="$(readlink -f "$i")"
rm "$i"
cp "$path" "$i"
chmod +w "$i"
patchelf \
--set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) \
--set-rpath "$out/System:${lib.makeLibraryPath [ libstdcxx5 ]}" \
"$i"
done
'';
};
desktop = makeDesktopItem {
name = "ut2004";
desktopName = "Unreal Tournament 2004";
comment = "A first-person shooter video game developed by Epic Games and Digital Extreme";
genericName = "First-person shooter";
categories = "Application;Game;";
exec = "ut2004";
};
in runCommand "ut2004" {
nativeBuildInputs = [ makeWrapper ];
} ''
mkdir -p $out/bin
for i in ${game}/System/*-bin; do
name="$(basename "$i")"
makeWrapper $i $out/bin/''${name%-bin} \
--run "cd ${game}/System"
done
mkdir -p $out/share/applications
ln -s ${desktop}/share/applications/* $out/share/applications
''

View File

@ -1,29 +0,0 @@
source $stdenv/setup
skip=7976
bunzip2 < $src | (dd bs=1 count=$skip of=/dev/null && dd bs=1M) | tar xvf - ut2004demo.tar
mkdir $out
(cd $out && tar xvf -) < ut2004demo.tar
# Patch the executable from ELF OS/ABI type `Linux' (3) to `SVR4' (0).
# This doesn't seem to matter to ld-linux.so.2 at all, except that it
# refuses to load `Linux' executables when invokes explicitly, that
# is, when we do `ld-linux.so.2 $out/System/ut2004-bin', which we need
# to override the hardcoded ELF interpreter with our own.
# This is a horrible hack, of course. A better solution would be to
# patch Glibc so it accepts the `Linux' ELF type as well (why doesn't
# it?); or to use FreeBSD's `brandelf' program to set to ELF type
# (which is a bit cleaner than patching using `dd' :-) ).
#(cd $out/System && (echo -en "\000" | dd bs=1 seek=7 of=ut2004-bin conv=notrunc))
# Set the ELF interpreter to our own Glibc.
for i in "$out/System/ucc-bin" "$out/System/ut2004-bin"; do
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$i"
done

View File

@ -1,34 +0,0 @@
{stdenv, fetchurl, xorg, mesa}:
assert stdenv.system == "i686-linux";
let {
raw = stdenv.mkDerivation {
name = "ut2004-demo-3120";
src = fetchurl {
urls = [
("http://store.node-10.ds-servers.com/file/BcFLgoIgAADQA7kw0qZctDAF+4cj"
+ "mbnDMFOJTAyM0-cejkEIuDvQ6Uv9ZbvcWMnRmXXxhA0LyvzoKdvsnXne0D1DGTLiR0"
+ "I1CmM2M-E5ryH-tD3yweCXyNyH1WGI3Wh09ja29mHtzGF1rxEyhRfQ7ggCKdfCrhvz"
+ "H9oTJXSCAtGuSKdVDhe6tNtrqa151MIircZtRLPxQcGmJ+n3-iUeWYgHuqbmrK4ur7"
+ "Qcy6QrAhYa+e5jcfYjgPF3VGsw4qx+0ilxJUCiuYCX2H8A6X3rxJILa26w3O425W2G"
+ "kHPiQWrhFT8cIOyqSr8+dMO5Xi5-/ut2004-lnx-demo-3120.run.bz2")
http://ftp.gameaholic.com/pub/demos/ut2004-lnx-demo-3120.run.bz2
];
sha256 = "1lravfkb1gsallqqird5dcbz42vwjg36m1qk76nmmnyyyghwqnli";
};
builder = ./builder.sh;
};
body = stdenv.mkDerivation {
name = raw.name;
builder = ./make-wrapper.sh;
inherit raw mesa;
inherit (xorg) libX11 libXext;
};
}
# http://mirror1.icculus.org/ut2004/ut2004-lnxpatch3204.tar.bz2
# 5f659552095b878a029b917d216d9664

View File

@ -1,13 +0,0 @@
source $stdenv/setup
mkdir -p $out/bin
cat > $out/bin/ut2004demo <<EOF
#! $SHELL -e
cd $raw/System
LD_LIBRARY_PATH=$libX11/lib:$libXext/lib\${LD_LIBRARY_PATH:+:}\$LD_LIBRARY_PATH ./ut2004-bin "\$@"
EOF
chmod +x $out/bin/ut2004demo

View File

@ -6360,6 +6360,8 @@ in
libcxx = llvmPackages.libcxx;
libcxxabi = llvmPackages.libcxxabi;
libstdcxx5 = callPackage ../development/libraries/libstdc++5 { };
libsigrok = callPackage ../development/tools/libsigrok { };
# old version:
libsigrok-0-3-0 = libsigrok.override {
@ -16197,7 +16199,9 @@ in
ue4demos = recurseIntoAttrs (callPackage ../games/ue4demos { });
ut2004demo = callPackage_i686 ../games/ut2004demo { };
ut2004Packages = callPackage ../games/ut2004 { };
ut2004demo = self.ut2004Packages.ut2004 [ self.ut2004Packages.ut2004-demo ];
vapor = callPackage ../games/vapor { love = love_0_8; };