1{ lib, stdenv, fetchurl
2, linkStatic ? with stdenv.hostPlatform; isStatic || isCygwin
3, autoreconfHook
4}:
5
6# Note: this package is used for bootstrapping fetchurl, and thus
7# cannot use fetchpatch! All mutable patches (generated by GitHub or
8# cgit) that are needed here should be included directly in Nixpkgs as
9# files.
10
11stdenv.mkDerivation rec {
12 pname = "bzip2";
13 version = "1.0.8";
14
15 src = fetchurl {
16 url = "https://sourceware.org/pub/bzip2/bzip2-${version}.tar.gz";
17 sha256 = "sha256-q1oDF27hBtPw+pDjgdpHjdrkBZGBU8yiSOaCzQxKImk=";
18 };
19
20 patchFlags = ["-p0"];
21
22 patches = [
23 (fetchurl {
24 url = "https://ftp.suse.com/pub/people/sbrabec/bzip2/for_downstream/bzip2-1.0.6.2-autoconfiscated.patch";
25 sha256 = "sha256-QMufl6ffJVVVVZespvkCbFpB6++R1lnq1687jEsUjr0=";
26 })
27 ];
28 # Fix up hardcoded version from the above patch, e.g. seen in bzip2.pc or libbz2.so.1.0.N
29 postPatch = ''
30 patch <<-EOF
31 --- configure.ac
32 +++ configure.ac
33 @@ -3,3 +3,3 @@
34 -AC_INIT([bzip2], [1.0.6], [Julian Seward <jseward@bzip.org>])
35 +AC_INIT([bzip2], [${version}], [Julian Seward <jseward@bzip.org>])
36 BZIP2_LT_CURRENT=1
37 -BZIP2_LT_REVISION=6
38 +BZIP2_LT_REVISION=${lib.versions.patch version}
39 EOF
40 '';
41
42 strictDeps = true;
43 nativeBuildInputs = [ autoreconfHook ];
44
45 outputs = [ "bin" "dev" "out" "man" ];
46
47 configureFlags =
48 lib.optionals linkStatic [ "--enable-static" "--disable-shared" ];
49
50 enableParallelBuilding = true;
51
52 postInstall = ''
53 ln -s $out/lib/libbz2.so.1.0.* $out/lib/libbz2.so.1.0
54 '';
55
56 meta = with lib; {
57 description = "High-quality data compression program";
58 homepage = "https://www.sourceware.org/bzip2";
59 changelog = "https://sourceware.org/git/?p=bzip2.git;a=blob;f=CHANGES;hb=HEAD";
60 license = licenses.bsdOriginal;
61 platforms = platforms.all;
62 maintainers = with maintainers; [ mic92 ];
63 };
64}