Skip to content

Commit 96648a8

Browse files
committed
bzip2: Get rid of the custom builder.sh.
Everything the builder.sh did can be done with the generic builder which makes it easier to override attributes and also easier to read. The reason I've done this is because of #10820, which tries to override the preBuild hook, but the latter is hardcoded in the builder.sh of bzip2. I have compared the output of this against the previous version and the only things that were different were timestamps in libbz2.a. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
1 parent cc86857 commit 96648a8

2 files changed

Lines changed: 33 additions & 33 deletions

File tree

pkgs/tools/compression/bzip2/builder.sh

Lines changed: 0 additions & 24 deletions
This file was deleted.

pkgs/tools/compression/bzip2/default.nix

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
{ stdenv, fetchurl, linkStatic ? false }:
22

3-
let version = "1.0.6"; in
3+
let
4+
version = "1.0.6";
45

5-
stdenv.mkDerivation {
6-
name = "bzip2-${version}";
6+
sharedLibrary = !stdenv.isDarwin && !(stdenv ? isStatic)
7+
&& stdenv.system != "i686-cygwin" && !linkStatic;
78

8-
builder = ./builder.sh;
9+
in stdenv.mkDerivation {
10+
name = "bzip2-${version}";
911

1012
src = fetchurl {
1113
url = "http://www.bzip.org/${version}/bzip2-${version}.tar.gz";
@@ -23,14 +25,36 @@ stdenv.mkDerivation {
2325
'';
2426
};
2527

26-
sharedLibrary =
27-
!stdenv.isDarwin && !(stdenv ? isStatic) && stdenv.system != "i686-cygwin" && !linkStatic;
28+
preBuild = stdenv.lib.optionalString sharedLibrary ''
29+
make -f Makefile-libbz2_so
30+
'';
31+
32+
preInstall = stdenv.lib.optionalString sharedLibrary ''
33+
mkdir -p $out/lib
34+
mv libbz2.so* $out/lib
35+
( cd $out/lib &&
36+
ln -s libbz2.so.1.0.? libbz2.so &&
37+
ln -s libbz2.so.1.0.? libbz2.so.1
38+
)
39+
'';
40+
41+
installFlags = [ "PREFIX=$(out)" ];
42+
43+
postInstall = ''
44+
rm $out/bin/bunzip2* $out/bin/bzcat*
45+
ln -s bzip2 $out/bin/bunzip2
46+
ln -s bzip2 $out/bin/bzcat
47+
'';
2848

29-
patchPhase = stdenv.lib.optionalString stdenv.isDarwin "substituteInPlace Makefile --replace 'CC=gcc' 'CC=clang'";
49+
patchPhase = stdenv.lib.optionalString stdenv.isDarwin ''
50+
substituteInPlace Makefile --replace 'CC=gcc' 'CC=clang'
51+
'';
3052

31-
preConfigure = "substituteInPlace Makefile --replace '$(PREFIX)/man' '$(PREFIX)/share/man'";
53+
preConfigure = ''
54+
substituteInPlace Makefile --replace '$(PREFIX)/man' '$(PREFIX)/share/man'
55+
'';
3256

33-
makeFlags = if linkStatic then "LDFLAGS=-static" else "";
57+
makeFlags = stdenv.lib.optional linkStatic "LDFLAGS=-static";
3458

3559
inherit linkStatic;
3660

0 commit comments

Comments
 (0)