From a99e543c36e78edbbdda68f4269b37c5bcf2a4d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Sat, 18 Apr 2015 19:32:52 +0200 Subject: [PATCH] bzip2: split into multiple outputs, refactor --- pkgs/stdenv/common-path.nix | 2 +- pkgs/tools/compression/bzip2/builder.sh | 24 -------------- pkgs/tools/compression/bzip2/default.nix | 41 +++++++++++++++++------- 3 files changed, 31 insertions(+), 36 deletions(-) delete mode 100644 pkgs/tools/compression/bzip2/builder.sh diff --git a/pkgs/stdenv/common-path.nix b/pkgs/stdenv/common-path.nix index 63c9f14b15c4..da468d56a2cd 100644 --- a/pkgs/stdenv/common-path.nix +++ b/pkgs/stdenv/common-path.nix @@ -7,7 +7,7 @@ pkgs.gawk pkgs.gnutar pkgs.gzip - pkgs.bzip2 + pkgs.bzip2.bin pkgs.gnumake pkgs.bash pkgs.patch diff --git a/pkgs/tools/compression/bzip2/builder.sh b/pkgs/tools/compression/bzip2/builder.sh deleted file mode 100644 index a598dfcf808c..000000000000 --- a/pkgs/tools/compression/bzip2/builder.sh +++ /dev/null @@ -1,24 +0,0 @@ -source $stdenv/setup -installFlags="PREFIX=$out" - -if test -n "$sharedLibrary"; then - - preBuild() { - make -f Makefile-libbz2_so - } - - preInstall() { - mkdir -p $out/lib - mv libbz2.so* $out/lib - (cd $out/lib && ln -s libbz2.so.1.0.? libbz2.so && ln -s libbz2.so.1.0.? libbz2.so.1); - } - -fi - -postInstall() { - rm $out/bin/bunzip2* $out/bin/bzcat* - ln -s bzip2 $out/bin/bunzip2 - ln -s bzip2 $out/bin/bzcat -} - -genericBuild diff --git a/pkgs/tools/compression/bzip2/default.nix b/pkgs/tools/compression/bzip2/default.nix index 74da91431a43..da6695ee1da9 100644 --- a/pkgs/tools/compression/bzip2/default.nix +++ b/pkgs/tools/compression/bzip2/default.nix @@ -1,17 +1,25 @@ { stdenv, fetchurl, linkStatic ? false }: -let version = "1.0.6"; in +let + version = "1.0.6"; + inherit (stdenv.lib) optionalString; + sharedLibrary = with stdenv; + !( isDarwin || (stdenv ? isStatic) || system == "i686-cygwin" || linkStatic ); +in -stdenv.mkDerivation { +stdenv.mkDerivation rec { name = "bzip2-${version}"; - builder = ./builder.sh; - src = fetchurl { url = "http://www.bzip.org/${version}/bzip2-${version}.tar.gz"; sha256 = "1kfrc7f0ja9fdn6j1y6yir6li818npy6217hvr3wzmnmzhs8z152"; }; + patchPhase = optionalString stdenv.isDarwin + "substituteInPlace Makefile --replace 'CC=gcc' 'CC=clang'"; + + outputs = [ "dev" "bin" "static" ] ++ stdenv.lib.optional sharedLibrary "out"; + crossAttrs = { patchPhase = '' sed -i -e '//s|\\|/|' bzip2.c @@ -23,16 +31,27 @@ stdenv.mkDerivation { ''; }; - sharedLibrary = - !stdenv.isDarwin && !(stdenv ? isStatic) && stdenv.system != "i686-cygwin" && !linkStatic; - - patchPhase = stdenv.lib.optionalString stdenv.isDarwin "substituteInPlace Makefile --replace 'CC=gcc' 'CC=clang'"; - preConfigure = "substituteInPlace Makefile --replace '$(PREFIX)/man' '$(PREFIX)/share/man'"; - makeFlags = if linkStatic then "LDFLAGS=-static" else ""; + preBuild = optionalString sharedLibrary "make -f Makefile-libbz2_so"; + makeFlags = optionalString linkStatic "LDFLAGS=-static"; - inherit linkStatic; + installFlags = "PREFIX=$(bin)"; + + postInstall = optionalString sharedLibrary '' + mkdir -p $out/lib + mv libbz2.so* $out/lib + ( cd $out/lib && ln -s libbz2.so.1.*.* libbz2.so && ln -s libbz2.so.1.*.* libbz2.so.1 ) + '' + '' + mkdir -p "$static" + mv "$bin/lib" "$static/" + ( + cd "$bin/bin" + rm {bunzip2,bzcat}* + ln -s bzip2 bunzip2 + ln -s bzip2 bzcat + ) + ''; meta = { homepage = "http://www.bzip.org";