2022-04-27 09:35:20 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, acl
|
|
|
|
, attr
|
|
|
|
, autoreconfHook
|
|
|
|
, bzip2
|
|
|
|
, e2fsprogs
|
|
|
|
, lzo
|
|
|
|
, openssl
|
|
|
|
, pkg-config
|
|
|
|
, sharutils
|
|
|
|
, xz
|
|
|
|
, zlib
|
|
|
|
, zstd
|
|
|
|
# Optional but increases closure only negligibly. Also, while libxml2 builds
|
|
|
|
# fine on windows, libarchive has trouble linking windows things it depends on
|
|
|
|
# for some reason.
|
|
|
|
, xarSupport ? stdenv.hostPlatform.isUnix, libxml2
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
# for passthru.tests
|
|
|
|
, cmake
|
|
|
|
, nix
|
|
|
|
, samba
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
assert xarSupport -> libxml2 != null;
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "libarchive";
|
2022-04-27 09:35:20 +00:00
|
|
|
version = "3.6.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "libarchive";
|
|
|
|
repo = "libarchive";
|
|
|
|
rev = "v${version}";
|
2022-04-27 09:35:20 +00:00
|
|
|
hash = "sha256-G4wL5DDbX0FqaA4cnOlVLZ25ObN8dNsRtxyas29tpDA=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace Makefile.am --replace '/bin/pwd' "$(type -P pwd)"
|
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
declare -a skip_test_paths=(
|
2022-04-27 09:35:20 +00:00
|
|
|
# test won't work in nix sandbox
|
2022-05-18 14:49:53 +00:00
|
|
|
'libarchive/test/test_write_disk_perms.c'
|
2022-04-27 09:35:20 +00:00
|
|
|
# can't be sure builder will have sparse-capable fs
|
2022-05-18 14:49:53 +00:00
|
|
|
'libarchive/test/test_sparse_basic.c'
|
2022-04-27 09:35:20 +00:00
|
|
|
# can't even be sure builder will have hardlink-capable fs
|
2022-05-18 14:49:53 +00:00
|
|
|
'libarchive/test/test_write_disk_hardlink.c'
|
|
|
|
# access-time-related tests flakey on some systems
|
|
|
|
'cpio/test/test_option_a.c'
|
|
|
|
'cpio/test/test_option_t.c'
|
2022-04-27 09:35:20 +00:00
|
|
|
)
|
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
for test_path in "''${skip_test_paths[@]}" ; do
|
|
|
|
substituteInPlace Makefile.am --replace "$test_path" ""
|
|
|
|
rm "$test_path"
|
2022-04-27 09:35:20 +00:00
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
outputs = [ "out" "lib" "dev" ];
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
autoreconfHook
|
|
|
|
pkg-config
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
bzip2
|
|
|
|
lzo
|
|
|
|
openssl
|
|
|
|
xz
|
|
|
|
zlib
|
|
|
|
zstd
|
|
|
|
] ++ lib.optional stdenv.hostPlatform.isUnix sharutils
|
|
|
|
++ lib.optionals stdenv.isLinux [ acl attr e2fsprogs ]
|
2021-02-05 17:12:51 +00:00
|
|
|
++ lib.optional xarSupport libxml2;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
# Without this, pkg-config-based dependencies are unhappy
|
|
|
|
propagatedBuildInputs = lib.optionals stdenv.isLinux [ attr acl ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
configureFlags = lib.optional (!xarSupport) "--without-xml2";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
preBuild = lib.optionalString stdenv.isCygwin ''
|
2020-04-24 23:36:52 +00:00
|
|
|
echo "#include <windows.h>" >> config.h
|
2022-04-27 09:35:20 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
# https://github.com/libarchive/libarchive/issues/1475
|
|
|
|
doCheck = !stdenv.hostPlatform.isMusl;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
preFixup = ''
|
|
|
|
sed -i $lib/lib/libarchive.la \
|
2022-04-03 18:54:34 +00:00
|
|
|
-e 's|-lcrypto|-L${lib.getLib openssl}/lib -lcrypto|' \
|
2020-04-24 23:36:52 +00:00
|
|
|
-e 's|-llzo2|-L${lzo}/lib -llzo2|'
|
|
|
|
'';
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
meta = with lib; {
|
|
|
|
homepage = "http://libarchive.org";
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Multi-format archive and compression library";
|
|
|
|
longDescription = ''
|
2022-04-27 09:35:20 +00:00
|
|
|
The libarchive project develops a portable, efficient C library that can
|
|
|
|
read and write streaming archives in a variety of formats. It also
|
|
|
|
includes implementations of the common tar, cpio, and zcat command-line
|
|
|
|
tools that use the libarchive library.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
2020-12-25 13:55:36 +00:00
|
|
|
changelog = "https://github.com/libarchive/libarchive/releases/tag/v${version}";
|
2022-04-27 09:35:20 +00:00
|
|
|
license = licenses.bsd3;
|
|
|
|
maintainers = with maintainers; [ jcumming AndersonTorres ];
|
|
|
|
platforms = platforms.all;
|
|
|
|
};
|
|
|
|
|
|
|
|
passthru.tests = {
|
|
|
|
inherit cmake nix samba;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|