Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 165 lines 4.4 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 acl, 6 attr, 7 autoreconfHook, 8 bzip2, 9 fetchpatch, 10 glibcLocalesUtf8, 11 lzo, 12 openssl, 13 pkg-config, 14 xz, 15 zlib, 16 zstd, 17 # Optional but increases closure only negligibly. Also, while libxml2 builds 18 # fine on windows, libarchive has trouble linking windows things it depends on 19 # for some reason. 20 xarSupport ? stdenv.hostPlatform.isUnix, 21 libxml2, 22 23 # for passthru.tests 24 cmake, 25 nix, 26 samba, 27 28 # for passthru.lore 29 binlore, 30}: 31 32assert xarSupport -> libxml2 != null; 33stdenv.mkDerivation (finalAttrs: { 34 pname = "libarchive"; 35 version = "3.8.1"; 36 37 src = fetchFromGitHub { 38 owner = "libarchive"; 39 repo = "libarchive"; 40 rev = "v${finalAttrs.version}"; 41 hash = "sha256-KN5SvQ+/g/OOa+hntMX3D8p5IEWO0smke5WK+DwrOH0="; 42 }; 43 44 patches = [ 45 # https://github.com/libarchive/libarchive/pull/2689 46 # Remove after next release. 47 (fetchpatch { 48 url = "https://github.com/libarchive/libarchive/commit/489d0b8e2f1fafd3b7ebf98f389ca67462c34651.patch?full_index=1"; 49 hash = "sha256-r+tSJ+WA0VKCjg+8MfS5/RqcB+aAMZ2dK0YUh+U1q78="; 50 }) 51 ]; 52 53 outputs = [ 54 "out" 55 "lib" 56 "dev" 57 ]; 58 59 postPatch = 60 let 61 skipTestPaths = [ 62 # test won't work in nix sandbox 63 "libarchive/test/test_write_disk_perms.c" 64 # the filesystem does not necessarily have sparse capabilities 65 "libarchive/test/test_sparse_basic.c" 66 # the filesystem does not necessarily have hardlink capabilities 67 "libarchive/test/test_write_disk_hardlink.c" 68 # access-time-related tests flakey on some systems 69 "libarchive/test/test_read_disk_directory_traversals.c" 70 "cpio/test/test_option_a.c" 71 "cpio/test/test_option_t.c" 72 ] 73 ++ lib.optionals (stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isLinux) [ 74 # only on some aarch64-linux systems? 75 "cpio/test/test_basic.c" 76 "cpio/test/test_format_newc.c" 77 ]; 78 removeTest = testPath: '' 79 substituteInPlace Makefile.am --replace-fail "${testPath}" "" 80 rm "${testPath}" 81 ''; 82 in 83 '' 84 substituteInPlace Makefile.am --replace-fail '/bin/pwd' "$(type -P pwd)" 85 86 ${lib.concatStringsSep "\n" (map removeTest skipTestPaths)} 87 ''; 88 89 nativeBuildInputs = [ 90 autoreconfHook 91 glibcLocalesUtf8 # test_I test requires an UTF-8 locale 92 pkg-config 93 ]; 94 95 buildInputs = [ 96 bzip2 97 lzo 98 openssl 99 xz 100 zlib 101 zstd 102 ] 103 ++ lib.optionals stdenv.hostPlatform.isLinux [ 104 acl 105 attr 106 ] 107 ++ lib.optional xarSupport libxml2; 108 109 # Without this, pkg-config-based dependencies are unhappy 110 propagatedBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [ 111 attr 112 acl 113 ]; 114 115 hardeningDisable = [ "strictflexarrays3" ]; 116 117 configureFlags = lib.optional (!xarSupport) "--without-xml2"; 118 119 preBuild = lib.optionalString stdenv.hostPlatform.isCygwin '' 120 echo "#include <windows.h>" >> config.h 121 ''; 122 123 # https://github.com/libarchive/libarchive/issues/1475 124 doCheck = !stdenv.hostPlatform.isMusl; 125 126 preCheck = '' 127 # Need an UTF-8 locale for test_I test. 128 export LANG=en_US.UTF-8 129 ''; 130 131 preFixup = '' 132 sed -i $lib/lib/libarchive.la \ 133 -e 's|-lcrypto|-L${lib.getLib openssl}/lib -lcrypto|' \ 134 -e 's|-llzo2|-L${lzo}/lib -llzo2|' 135 ''; 136 137 enableParallelBuilding = true; 138 139 meta = with lib; { 140 homepage = "http://libarchive.org"; 141 description = "Multi-format archive and compression library"; 142 longDescription = '' 143 The libarchive project develops a portable, efficient C library that can 144 read and write streaming archives in a variety of formats. It also 145 includes implementations of the common tar, cpio, and zcat command-line 146 tools that use the libarchive library. 147 ''; 148 changelog = "https://github.com/libarchive/libarchive/releases/tag/v${finalAttrs.version}"; 149 license = licenses.bsd3; 150 maintainers = with maintainers; [ jcumming ]; 151 platforms = platforms.all; 152 inherit (acl.meta) badPlatforms; 153 }; 154 155 passthru.tests = { 156 inherit cmake nix samba; 157 }; 158 159 # bsdtar is detected as "cannot" because its exec is internal to 160 # calls it makes into libarchive itself. If binlore gains support 161 # for detecting another layer down into libraries, this can be cut. 162 passthru.binlore.out = binlore.synthesize finalAttrs.finalPackage '' 163 execer can bin/bsdtar 164 ''; 165})