Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib
2, stdenv
3, fetchFromGitLab
4, fetchpatch
5, nix-update-script
6
7, autoreconfHook
8, pkg-config
9, sphinx
10
11, libdeflate
12, libjpeg
13, xz
14, zlib
15
16 # for passthru.tests
17, libgeotiff
18, python3Packages
19, imagemagick
20, graphicsmagick
21, gdal
22, openimageio
23, freeimage
24}:
25
26stdenv.mkDerivation rec {
27 pname = "libtiff";
28 version = "4.5.0";
29
30 src = fetchFromGitLab {
31 owner = "libtiff";
32 repo = "libtiff";
33 rev = "v${version}";
34 hash = "sha256-KG6rB940JMjFUTAgtkzg+Zh75gylPY6Q7/4gEbL0Hcs=";
35 };
36
37 patches = [
38 # FreeImage needs this patch
39 ./headers.patch
40 # libc++abi 11 has an `#include <version>`, this picks up files name
41 # `version` in the project's include paths
42 ./rename-version.patch
43 (fetchpatch {
44 name = "CVE-2022-48281.patch";
45 url = "https://gitlab.com/libtiff/libtiff/-/commit/d1b6b9c1b3cae2d9e37754506c1ad8f4f7b646b5.diff";
46 sha256 = "sha256-FWUlyJyHXac6fuM5f9PG33kcF5Bm4fyFmYnaDal46iM=";
47 })
48 (fetchpatch {
49 name = "CVE-2023-0800.CVE-2023-0801.CVE-2023-0802.CVE-2023-0803.CVE-2023-0804.patch";
50 url = "https://gitlab.com/libtiff/libtiff/-/commit/33aee1275d9d1384791d2206776eb8152d397f00.patch";
51 sha256 = "sha256-wNSa1D9EWObTs331utjIKgo9p9PUWqTM54qG+1Hhm1A=";
52 })
53 (fetchpatch {
54 name = "CVE-2023-0795.CVE-2023-0796.CVE-2023-0797.CVE-2023-0798.CVE-2023-0799.prerequisite-0.patch";
55 url = "https://gitlab.com/libtiff/libtiff/-/commit/9c22495e5eeeae9e00a1596720c969656bb8d678.patch";
56 sha256 = "sha256-NTs+dCUweKddQDzJLqbdIdvNbaSweGG0cSVt57tntoI=";
57 })
58 (fetchpatch {
59 name = "CVE-2023-0795.CVE-2023-0796.CVE-2023-0797.CVE-2023-0798.CVE-2023-0799.prerequisite-1.patch";
60 url = "https://gitlab.com/libtiff/libtiff/-/commit/d63de61b1ec3385f6383ef9a1f453e4b8b11d536.patch";
61 includes = [ "tools/tiffcrop.c" ];
62 sha256 = "sha256-VHg5aAcHKwRkDFDyC1rLjCjj1rMzcq/2SUR/r1fQubQ=";
63 })
64 (fetchpatch {
65 name = "CVE-2023-0795.CVE-2023-0796.CVE-2023-0797.CVE-2023-0798.CVE-2023-0799.patch";
66 url = "https://gitlab.com/libtiff/libtiff/-/commit/afaabc3e50d4e5d80a94143f7e3c997e7e410f68.patch";
67 sha256 = "sha256-9+oXKVJEeaIuMBdtvhNlUBNpw9uzg31s+zxt4GJo6Lo=";
68 })
69 ];
70
71 postPatch = ''
72 mv VERSION VERSION.txt
73 '';
74
75 outputs = [ "bin" "dev" "dev_private" "out" "man" "doc" ];
76
77 postFixup = ''
78 moveToOutput include/tif_config.h $dev_private
79 moveToOutput include/tif_dir.h $dev_private
80 moveToOutput include/tif_hash_set.h $dev_private
81 moveToOutput include/tiffiop.h $dev_private
82 '';
83
84 # If you want to change to a different build system, please make
85 # sure cross-compilation works first!
86 nativeBuildInputs = [ autoreconfHook pkg-config sphinx ];
87
88 # TODO: opengl support (bogus configure detection)
89 propagatedBuildInputs = [
90 libdeflate
91 libjpeg
92 xz
93 zlib
94 ];
95
96 enableParallelBuilding = true;
97
98 doCheck = true;
99
100 passthru = {
101 tests = {
102 inherit libgeotiff imagemagick graphicsmagick gdal openimageio freeimage;
103 inherit (python3Packages) pillow imread;
104 };
105 updateScript = nix-update-script { };
106 };
107
108 meta = with lib; {
109 description = "Library and utilities for working with the TIFF image file format";
110 homepage = "https://libtiff.gitlab.io/libtiff";
111 changelog = "https://libtiff.gitlab.io/libtiff/v${version}.html";
112 maintainers = with maintainers; [ qyliss ];
113 license = licenses.libtiff;
114 platforms = platforms.unix;
115 };
116}