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
|
2023-01-20 10:41:00 +00:00
|
|
|
, buildPackages
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2023-01-20 10:41:00 +00:00
|
|
|
let
|
|
|
|
autoreconfHook = buildPackages.autoreconfHook269;
|
|
|
|
in
|
2020-04-24 23:36:52 +00:00
|
|
|
assert xarSupport -> libxml2 != null;
|
2023-01-20 10:41:00 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "libarchive";
|
2023-01-20 10:41:00 +00:00
|
|
|
version = "3.6.2";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "libarchive";
|
|
|
|
repo = "libarchive";
|
2023-01-20 10:41:00 +00:00
|
|
|
rev = "v${finalAttrs.version}";
|
|
|
|
hash = "sha256-wQbA6vlXH8pnpY7LJLkjrRFEBpcaPR1SqxnK71UVwxg=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-01-20 10:41:00 +00:00
|
|
|
outputs = [ "out" "lib" "dev" ];
|
2022-04-27 09:35:20 +00:00
|
|
|
|
2023-01-20 10:41:00 +00:00
|
|
|
postPatch = let
|
|
|
|
skipTestPaths = [
|
2022-04-27 09:35:20 +00:00
|
|
|
# test won't work in nix sandbox
|
2023-01-20 10:41:00 +00:00
|
|
|
"libarchive/test/test_write_disk_perms.c"
|
|
|
|
# the filesystem does not necessarily have sparse capabilities
|
|
|
|
"libarchive/test/test_sparse_basic.c"
|
|
|
|
# the filesystem does not necessarily have hardlink capabilities
|
|
|
|
"libarchive/test/test_write_disk_hardlink.c"
|
2022-05-18 14:49:53 +00:00
|
|
|
# access-time-related tests flakey on some systems
|
2023-01-20 10:41:00 +00:00
|
|
|
"cpio/test/test_option_a.c"
|
|
|
|
"cpio/test/test_option_t.c"
|
|
|
|
];
|
|
|
|
removeTest = testPath: ''
|
|
|
|
substituteInPlace Makefile.am --replace "${testPath}" ""
|
|
|
|
rm "${testPath}"
|
|
|
|
'';
|
|
|
|
in ''
|
|
|
|
substituteInPlace Makefile.am --replace '/bin/pwd' "$(type -P pwd)"
|
2022-04-27 09:35:20 +00:00
|
|
|
|
2023-01-20 10:41:00 +00:00
|
|
|
${lib.concatStringsSep "\n" (map removeTest skipTestPaths)}
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
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
|
|
|
'';
|
2023-01-20 10:41:00 +00:00
|
|
|
changelog = "https://github.com/libarchive/libarchive/releases/tag/v${finalAttrs.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
|
|
|
};
|
2023-01-20 10:41:00 +00:00
|
|
|
})
|