about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/libfaketime
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/libfaketime')
-rw-r--r--nixpkgs/pkgs/development/libraries/libfaketime/0001-Remove-unsupported-clang-flags.patch13
-rw-r--r--nixpkgs/pkgs/development/libraries/libfaketime/default.nix50
-rw-r--r--nixpkgs/pkgs/development/libraries/libfaketime/nix-store-date.patch29
3 files changed, 92 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/libfaketime/0001-Remove-unsupported-clang-flags.patch b/nixpkgs/pkgs/development/libraries/libfaketime/0001-Remove-unsupported-clang-flags.patch
new file mode 100644
index 000000000000..7dfad4978005
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/libfaketime/0001-Remove-unsupported-clang-flags.patch
@@ -0,0 +1,13 @@
+diff --git a/src/Makefile b/src/Makefile
+index 2af4804..bcff809 100644
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -80,7 +80,7 @@ PREFIX ?= /usr/local
+ LIBDIRNAME ?= /lib/faketime
+ PLATFORM ?=$(shell uname)
+ 
+-CFLAGS += -std=gnu99 -Wall -Wextra -Werror -Wno-nonnull-compare -DFAKE_PTHREAD -DFAKE_STAT -DFAKE_UTIME -DFAKE_SLEEP -DFAKE_TIMERS -DFAKE_INTERNAL_CALLS -fPIC -DPREFIX='"'$(PREFIX)'"' -DLIBDIRNAME='"'$(LIBDIRNAME)'"' $(FAKETIME_COMPILE_CFLAGS)
++CFLAGS += -std=gnu99 -Wall -Wextra -DFAKE_PTHREAD -DFAKE_STAT -DFAKE_UTIME -DFAKE_SLEEP -DFAKE_TIMERS -DFAKE_INTERNAL_CALLS -fPIC -DPREFIX='"'$(PREFIX)'"' -DLIBDIRNAME='"'$(LIBDIRNAME)'"' $(FAKETIME_COMPILE_CFLAGS)
+ ifeq ($(PLATFORM),SunOS)
+ CFLAGS += -D__EXTENSIONS__ -D_XOPEN_SOURCE=600
+ endif
diff --git a/nixpkgs/pkgs/development/libraries/libfaketime/default.nix b/nixpkgs/pkgs/development/libraries/libfaketime/default.nix
new file mode 100644
index 000000000000..f44702582f27
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/libfaketime/default.nix
@@ -0,0 +1,50 @@
+{ lib, stdenv, fetchFromGitHub, fetchpatch, perl, coreutils }:
+
+stdenv.mkDerivation rec {
+  pname = "libfaketime";
+  version = "0.9.10";
+
+  src = fetchFromGitHub {
+    owner = "wolfcw";
+    repo = "libfaketime";
+    rev = "v${version}";
+    sha256 = "sha256-DYRuQmIhQu0CNEboBAtHOr/NnWxoXecuPMSR/UQ/VIQ=";
+  };
+
+  patches = [
+    ./nix-store-date.patch
+    (fetchpatch {
+      name = "0001-libfaketime.c-wrap-timespec_get-in-TIME_UTC-macro.patch";
+      url = "https://github.com/wolfcw/libfaketime/commit/e0e6b79568d36a8fd2b3c41f7214769221182128.patch";
+      sha256 = "sha256-KwwP76v0DXNW73p/YBvwUOPdKMAcVdbQSKexD/uFOYo=";
+    })
+  ] ++ (lib.optionals stdenv.cc.isClang [
+    # https://github.com/wolfcw/libfaketime/issues/277
+    ./0001-Remove-unsupported-clang-flags.patch
+  ]);
+
+  postPatch = ''
+    patchShebangs test src
+    for a in test/functests/test_exclude_mono.sh src/faketime.c ; do
+      substituteInPlace $a \
+        --replace /bin/bash ${stdenv.shell}
+    done
+    substituteInPlace src/faketime.c --replace @DATE_CMD@ ${coreutils}/bin/date
+  '';
+
+  PREFIX = placeholder "out";
+  LIBDIRNAME = "/lib";
+
+  env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-error=cast-function-type -Wno-error=format-truncation";
+
+  nativeCheckInputs = [ perl ];
+
+  meta = with lib; {
+    description = "Report faked system time to programs without having to change the system-wide time";
+    homepage = "https://github.com/wolfcw/libfaketime/";
+    license = licenses.gpl2;
+    platforms = platforms.all;
+    maintainers = [ maintainers.bjornfor ];
+    mainProgram = "faketime";
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/libfaketime/nix-store-date.patch b/nixpkgs/pkgs/development/libraries/libfaketime/nix-store-date.patch
new file mode 100644
index 000000000000..e93a7ec76507
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/libfaketime/nix-store-date.patch
@@ -0,0 +1,29 @@
+From abd7dd05b440e3dc9621a1579e4afb0267897d9c Mon Sep 17 00:00:00 2001
+From: Finn Behrens <me@kloenk.de>
+Date: Fri, 5 Mar 2021 21:58:57 +0100
+Subject: [PATCH] use nix date path
+
+---
+ src/faketime.c | 6 +-----
+ 1 file changed, 1 insertion(+), 5 deletions(-)
+
+diff --git a/src/faketime.c b/src/faketime.c
+index af618f2..48e47da 100644
+--- a/src/faketime.c
++++ b/src/faketime.c
+@@ -50,11 +50,7 @@
+ 
+ const char version[] = "0.9.10";
+ 
+-#if (defined __APPLE__) || (defined __sun)
+-static const char *date_cmd = "gdate";
+-#else
+-static const char *date_cmd = "date";
+-#endif
++static const char *date_cmd = "@DATE_CMD@";
+ 
+ #define PATH_BUFSIZE 4096
+ 
+-- 
+2.24.3 (Apple Git-128)
+