From 0e29fcdfefe49037e62657cad4ed24d69afc84ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20de=20Kok?= Date: Fri, 24 Jul 2020 12:45:37 +0200 Subject: [PATCH] liblinear: 2.30 -> 2.40 Also improve the derivation a bit: - Use fetchFromGitHub in place of fetchurl. - Replace buildPhase by buildFlags. - Create multiple outputs. - Replace mkdir/cp by install. --- .../libraries/liblinear/default.nix | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/pkgs/development/libraries/liblinear/default.nix b/pkgs/development/libraries/liblinear/default.nix index af09b1241de6..09f3aacca63e 100644 --- a/pkgs/development/libraries/liblinear/default.nix +++ b/pkgs/development/libraries/liblinear/default.nix @@ -1,35 +1,37 @@ -{ stdenv, fetchurl, fixDarwinDylibNames }: +{ stdenv, fetchFromGitHub, fixDarwinDylibNames }: -stdenv.mkDerivation rec { +let + soVersion = "4"; +in stdenv.mkDerivation rec { pname = "liblinear"; - version = "2.30"; + version = "2.40"; - src = fetchurl { - url = "https://www.csie.ntu.edu.tw/~cjlin/liblinear/liblinear-${version}.tar.gz"; - sha256 = "1b66jpg9fdwsq7r52fccr8z7nqcivrin5d8zg2f134ygqqwp0748"; + src = fetchFromGitHub { + owner = "cjlin1"; + repo = "liblinear"; + rev = "v${builtins.replaceStrings ["."] [""] version}"; + sha256 = "041fby9vc7nvj0gls5zd9mhw7yqazm530bmln38mfz7wd06z1d6b"; }; - buildPhase = '' - make - make lib - ''; + outputs = [ "bin" "dev" "out" ]; + + nativeBuildInputs = stdenv.lib.optionals stdenv.isDarwin [ fixDarwinDylibNames ]; + + buildFlags = [ "lib" "predict" "train" ]; installPhase = '' - mkdir -p $out/lib $out/bin $out/include ${if stdenv.isDarwin then '' - cp liblinear.so.3 $out/lib/liblinear.3.dylib - ln -s $out/lib/liblinear.3.dylib $out/lib/liblinear.dylib + install -D liblinear.so.${soVersion} $out/lib/liblinear.${soVersion}.dylib + ln -s $out/lib/liblinear.${soVersion}.dylib $out/lib/liblinear.dylib '' else '' - cp liblinear.so.3 $out/lib/liblinear.so.3 - ln -s $out/lib/liblinear.so.3 $out/lib/liblinear.so + install -Dt $out/lib liblinear.so.${soVersion} + ln -s $out/lib/liblinear.so.${soVersion} $out/lib/liblinear.so ''} - cp train $out/bin/liblinear-train - cp predict $out/bin/liblinear-predict - cp linear.h $out/include + install -D train $bin/bin/liblinear-train + install -D predict $bin/bin/liblinear-predict + install -Dm444 -t $dev/include linear.h ''; - nativeBuildInputs = stdenv.lib.optional stdenv.isDarwin [ fixDarwinDylibNames ]; - meta = with stdenv.lib; { description = "A library for large linear classification"; homepage = "https://www.csie.ntu.edu.tw/~cjlin/liblinear/";