17 # Optional but increases closure only negligibly. Also, while libxml2 builds
18 # fine on windows, libarchive has trouble linking windows things it depends on
20 , xarSupport ? stdenv.hostPlatform.isUnix, libxml2
31 assert xarSupport -> libxml2 != null;
32 stdenv.mkDerivation (finalAttrs: {
36 src = fetchFromGitHub {
39 rev = "v${finalAttrs.version}";
40 hash = "sha256-maV2+Whi4aDG1VLAYpOTxluO9I0zNiZ8fA3w7epGlDg=";
43 outputs = [ "out" "lib" "dev" ];
47 # test won't work in nix sandbox
48 "libarchive/test/test_write_disk_perms.c"
49 # the filesystem does not necessarily have sparse capabilities
50 "libarchive/test/test_sparse_basic.c"
51 # the filesystem does not necessarily have hardlink capabilities
52 "libarchive/test/test_write_disk_hardlink.c"
53 # access-time-related tests flakey on some systems
54 "cpio/test/test_option_a.c"
55 "cpio/test/test_option_t.c"
56 ] ++ lib.optionals (stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isLinux) [
57 # only on some aarch64-linux systems?
58 "cpio/test/test_basic.c"
59 "cpio/test/test_format_newc.c"
61 removeTest = testPath: ''
62 substituteInPlace Makefile.am --replace-fail "${testPath}" ""
66 substituteInPlace Makefile.am --replace-fail '/bin/pwd' "$(type -P pwd)"
68 ${lib.concatStringsSep "\n" (map removeTest skipTestPaths)}
73 glibcLocalesUtf8 # test_I test requires an UTF-8 locale
84 ] ++ lib.optional stdenv.hostPlatform.isUnix sharutils
85 ++ lib.optionals stdenv.hostPlatform.isLinux [ acl attr e2fsprogs ]
86 ++ lib.optional xarSupport libxml2;
88 # Without this, pkg-config-based dependencies are unhappy
89 propagatedBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [ attr acl ];
91 configureFlags = lib.optional (!xarSupport) "--without-xml2";
93 preBuild = lib.optionalString stdenv.hostPlatform.isCygwin ''
94 echo "#include <windows.h>" >> config.h
97 # https://github.com/libarchive/libarchive/issues/1475
98 doCheck = !stdenv.hostPlatform.isMusl;
101 # Need an UTF-8 locale for test_I test.
102 export LANG=en_US.UTF-8
106 sed -i $lib/lib/libarchive.la \
107 -e 's|-lcrypto|-L${lib.getLib openssl}/lib -lcrypto|' \
108 -e 's|-llzo2|-L${lzo}/lib -llzo2|'
111 enableParallelBuilding = true;
114 homepage = "http://libarchive.org";
115 description = "Multi-format archive and compression library";
117 The libarchive project develops a portable, efficient C library that can
118 read and write streaming archives in a variety of formats. It also
119 includes implementations of the common tar, cpio, and zcat command-line
120 tools that use the libarchive library.
122 changelog = "https://github.com/libarchive/libarchive/releases/tag/v${finalAttrs.version}";
123 license = licenses.bsd3;
124 maintainers = with maintainers; [ jcumming AndersonTorres ];
125 platforms = platforms.all;
126 inherit (acl.meta) badPlatforms;
130 inherit cmake nix samba;
133 # bsdtar is detected as "cannot" because its exec is internal to
134 # calls it makes into libarchive itself. If binlore gains support
135 # for detecting another layer down into libraries, this can be cut.
136 passthru.binlore.out = binlore.synthesize finalAttrs.finalPackage ''
137 execer can bin/bsdtar