2022-04-27 09:35:20 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, acl
|
|
|
|
, attr
|
|
|
|
, autoreconfHook
|
|
|
|
, bzip2
|
|
|
|
, e2fsprogs
|
2024-05-15 15:35:15 +00:00
|
|
|
, glibcLocalesUtf8
|
2022-04-27 09:35:20 +00:00
|
|
|
, 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;
|
2023-10-09 19:29:22 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "libarchive";
|
2024-05-15 15:35:15 +00:00
|
|
|
version = "3.7.4";
|
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}";
|
2024-05-15 15:35:15 +00:00
|
|
|
hash = "sha256-czNKXHoEn1x4deNErnqp/NZfCglF1CxNoLtZ8tcl394=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
outputs = [ "out" "lib" "dev" ];
|
|
|
|
|
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"
|
2024-04-21 15:54:59 +00:00
|
|
|
] ++ lib.optionals (stdenv.isAarch64 && stdenv.isLinux) [
|
|
|
|
# only on some aarch64-linux systems?
|
|
|
|
"cpio/test/test_basic.c"
|
|
|
|
"cpio/test/test_format_newc.c"
|
2023-01-20 10:41:00 +00:00
|
|
|
];
|
|
|
|
removeTest = testPath: ''
|
2024-05-15 15:35:15 +00:00
|
|
|
substituteInPlace Makefile.am --replace-fail "${testPath}" ""
|
2023-01-20 10:41:00 +00:00
|
|
|
rm "${testPath}"
|
|
|
|
'';
|
|
|
|
in ''
|
2024-05-15 15:35:15 +00:00
|
|
|
substituteInPlace Makefile.am --replace-fail '/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
|
2024-05-15 15:35:15 +00:00
|
|
|
glibcLocalesUtf8 # test_I test requires an UTF-8 locale
|
2022-04-27 09:35:20 +00:00
|
|
|
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
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
preCheck = ''
|
|
|
|
# Need an UTF-8 locale for test_I test.
|
|
|
|
export LANG=en_US.UTF-8
|
|
|
|
'';
|
|
|
|
|
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-10-09 19:29:22 +00:00
|
|
|
})
|