summary refs log tree commit diff
diff options
context:
space:
mode:
authorTimo Kaufmann <timokau@zoho.com>2018-10-05 16:05:24 +0200
committerGitHub <noreply@github.com>2018-10-05 16:05:24 +0200
commita00b7de165ddcd017afae9f6ce90b2312e4d89f0 (patch)
tree6528ff486ae4a7085747399be39481d3df71e5a8
parent9db397351a833cddfed0d3cefa320e6fe7607823 (diff)
parent65589faa2f4c6e922e51d41d6487de0ca4a7d143 (diff)
downloadnixlib-a00b7de165ddcd017afae9f6ce90b2312e4d89f0.tar
nixlib-a00b7de165ddcd017afae9f6ce90b2312e4d89f0.tar.gz
nixlib-a00b7de165ddcd017afae9f6ce90b2312e4d89f0.tar.bz2
nixlib-a00b7de165ddcd017afae9f6ce90b2312e4d89f0.tar.lz
nixlib-a00b7de165ddcd017afae9f6ce90b2312e4d89f0.tar.xz
nixlib-a00b7de165ddcd017afae9f6ce90b2312e4d89f0.tar.zst
nixlib-a00b7de165ddcd017afae9f6ce90b2312e4d89f0.zip
Merge pull request #47915 from timokau/zn_poly-update
zn_poly: 0.9 -> 0.9.1
-rw-r--r--pkgs/development/libraries/science/math/zn_poly/default.nix41
1 files changed, 32 insertions, 9 deletions
diff --git a/pkgs/development/libraries/science/math/zn_poly/default.nix b/pkgs/development/libraries/science/math/zn_poly/default.nix
index 19d63d89834e..ad4d4c017376 100644
--- a/pkgs/development/libraries/science/math/zn_poly/default.nix
+++ b/pkgs/development/libraries/science/math/zn_poly/default.nix
@@ -1,17 +1,25 @@
 { stdenv
-, fetchurl
+, lib
+, fetchFromGitLab
+, fetchpatch
 , gmp
 , python2
+, tune ? false # tune to hardware, impure
 }:
 
 stdenv.mkDerivation rec {
-  version = "0.9";
+  version = "0.9.1";
   pname = "zn_poly";
   name = "${pname}-${version}";
 
-  src = fetchurl {
-    url = "http://web.maths.unsw.edu.au/~davidharvey/code/zn_poly/releases/zn_poly-${version}.tar.gz";
-    sha256 = "1kxl25av7i3v68k32hw5bayrfcvmahmqvs97mlh9g238gj4qb851";
+  # sage has picked up the maintenance (bug fixes and building, not development)
+  # from the original, now unmaintained project which can be found at
+  # http://web.maths.unsw.edu.au/~davidharvey/code/zn_poly/
+  src = fetchFromGitLab {
+    owner = "sagemath";
+    repo = "zn_poly";
+    rev = version;
+    sha256 = "0ra5vy585bqq7g3317iw6fp44iqgqvds3j0l1va6mswimypq4vxb";
   };
 
   buildInputs = [
@@ -22,27 +30,42 @@ stdenv.mkDerivation rec {
     python2 # needed by ./configure to create the makefile
   ];
 
-  libname = "libzn_poly${stdenv.targetPlatform.extensions.sharedLibrary}";
+  # name of library file ("libzn_poly.so")
+  libbasename = "libzn_poly";
+  libext = "${stdenv.targetPlatform.extensions.sharedLibrary}";
 
   makeFlags = [ "CC=cc" ];
 
   # Tuning (either autotuning or with hand-written paramters) is possible
   # but not implemented here.
   # It seems buggy anyways (see homepage).
-  buildFlags = [ "all" libname ];
+  buildFlags = [ "all" "${libbasename}${libext}" ];
 
+  configureFlags = lib.optionals (!tune) [
+    "--disable-tuning"
+  ];
+
+  patches = [
+    # fix format-security by not passing variables directly to printf
+    # https://gitlab.com/sagemath/zn_poly/merge_requests/1
+    (fetchpatch {
+      name = "format-security.patch";
+      url = "https://gitlab.com/timokau/zn_poly/commit/1950900a80ec898d342b8bcafa148c8027649766.patch";
+      sha256 = "1gks9chvsfpc6sg5h3nqqfia4cgvph7jmj9dw67k7dk7kv9y0rk1";
+    })
+  ];
 
   # `make install` fails to install some header files and the lib file.
   installPhase = ''
     mkdir -p "$out/include/zn_poly"
     mkdir -p "$out/lib"
-    cp "${libname}" "$out/lib"
+    cp "${libbasename}"*"${libext}" "$out/lib"
     cp include/*.h "$out/include/zn_poly"
   '';
 
   doCheck = true;
 
-  meta = with stdenv.lib; {
+  meta = with lib; {
     homepage = http://web.maths.unsw.edu.au/~davidharvey/code/zn_poly/;
     description = "Polynomial arithmetic over Z/nZ";
     license = with licenses; [ gpl3 ];