summaryrefslogtreecommitdiffstats
path: root/pkgs
diff options
context:
space:
mode:
authorVladimír Čunát <vcunat@gmail.com>2015-04-18 19:32:52 +0200
committerVladimír Čunát <vcunat@gmail.com>2015-04-18 19:32:52 +0200
commita99e543c36e78edbbdda68f4269b37c5bcf2a4d0 (patch)
tree0431e6b40a2908b187593ffdaef3949569aa2c6a /pkgs
parentd484c392aaa4e17f48bd09bcb2e41030f76a920a (diff)
bzip2: split into multiple outputs, refactor
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/stdenv/common-path.nix2
-rw-r--r--pkgs/tools/compression/bzip2/builder.sh24
-rw-r--r--pkgs/tools/compression/bzip2/default.nix45
3 files changed, 33 insertions, 38 deletions
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
-
-stdenv.mkDerivation {
+let
+ version = "1.0.6";
+ inherit (stdenv.lib) optionalString;
+ sharedLibrary = with stdenv;
+ !( isDarwin || (stdenv ? isStatic) || system == "i686-cygwin" || linkStatic );
+in
+
+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 '/<sys\\stat\.h>/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 "";
-
- inherit linkStatic;
+ preBuild = optionalString sharedLibrary "make -f Makefile-libbz2_so";
+ makeFlags = optionalString linkStatic "LDFLAGS=-static";
+
+ 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";