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";