nixpkgs/pkgs/development/libraries/libarchive/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

118 lines
3.0 KiB
Nix
Raw Normal View History

2022-04-14 05:50:44 +01: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
2022-04-14 05:50:44 +01:00
# for passthru.tests
, cmake
, nix
, samba
}:
assert xarSupport -> libxml2 != null;
stdenv.mkDerivation rec {
pname = "libarchive";
2022-04-14 04:35:01 +01:00
version = "3.6.1";
src = fetchFromGitHub {
owner = "libarchive";
repo = "libarchive";
rev = "v${version}";
2022-04-14 04:35:01 +01:00
hash = "sha256-G4wL5DDbX0FqaA4cnOlVLZ25ObN8dNsRtxyas29tpDA=";
};
2022-04-17 12:07:41 +01:00
postPatch = ''
substituteInPlace Makefile.am --replace '/bin/pwd' "$(type -P pwd)"
declare -a skip_test_paths=(
2022-04-17 12:07:41 +01:00
# test won't work in nix sandbox
'libarchive/test/test_write_disk_perms.c'
2022-04-17 12:07:41 +01:00
# can't be sure builder will have sparse-capable fs
'libarchive/test/test_sparse_basic.c'
# can't even be sure builder will have hardlink-capable fs
'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-17 12:07:41 +01:00
)
for test_path in "''${skip_test_paths[@]}" ; do
substituteInPlace Makefile.am --replace "$test_path" ""
rm "$test_path"
2022-04-17 12:07:41 +01:00
done
'';
2016-09-19 13:33:25 +01:00
outputs = [ "out" "lib" "dev" ];
2022-04-14 05:50:44 +01: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 ]
++ lib.optional xarSupport libxml2;
# Without this, pkg-config-based dependencies are unhappy
propagatedBuildInputs = lib.optionals stdenv.isLinux [ attr acl ];
configureFlags = lib.optional (!xarSupport) "--without-xml2";
2022-04-14 05:50:44 +01:00
preBuild = lib.optionalString stdenv.isCygwin ''
2014-10-29 22:45:15 +00:00
echo "#include <windows.h>" >> config.h
2022-04-14 05:50:44 +01:00
'';
2014-10-29 22:45:15 +00:00
2022-04-17 12:07:41 +01:00
# https://github.com/libarchive/libarchive/issues/1475
doCheck = !stdenv.hostPlatform.isMusl;
2015-07-28 14:22:40 +01:00
preFixup = ''
2016-09-19 13:33:25 +01:00
sed -i $lib/lib/libarchive.la \
treewide: use lib.getLib for OpenSSL libraries At some point, I'd like to make another attempt at 71f1f4884b5 ("openssl: stop static binaries referencing libs"), which was reverted in 195c7da07df. One problem with my previous attempt is that I moved OpenSSL's libraries to a lib output, but many dependent packages were hardcoding the out output as the location of the libraries. This patch fixes every such case I could find in the tree. It won't have any effect immediately, but will mean these packages will automatically use an OpenSSL lib output if it is reintroduced in future. This patch should cause very few rebuilds, because it shouldn't make any change at all to most packages I'm touching. The few rebuilds that are introduced come from when I've changed a package builder not to use variable names like openssl.out in scripts / substitution patterns, which would be confusing since they don't hardcode the output any more. I started by making the following global replacements: ${pkgs.openssl.out}/lib -> ${lib.getLib pkgs.openssl}/lib ${openssl.out}/lib -> ${lib.getLib openssl}/lib Then I removed the ".out" suffix when part of the argument to lib.makeLibraryPath, since that function uses lib.getLib internally. Then I fixed up cases where openssl was part of the -L flag to the compiler/linker, since that unambigously is referring to libraries. Then I manually investigated and fixed the following packages: - pycurl - citrix-workspace - ppp - wraith - unbound - gambit - acl2 I'm reasonably confindent in my fixes for all of them. For acl2, since the openssl library paths are manually provided above anyway, I don't think openssl is required separately as a build input at all. Removing it doesn't make a difference to the output size, the file list, or the closure. I've tested evaluation with the OfBorg meta checks, to protect against introducing evaluation failures.
2022-03-25 15:33:21 +00:00
-e 's|-lcrypto|-L${lib.getLib openssl}/lib -lcrypto|' \
2015-09-25 13:06:23 +01:00
-e 's|-llzo2|-L${lzo}/lib -llzo2|'
2015-07-28 14:22:40 +01:00
'';
2018-06-04 13:48:39 +01:00
enableParallelBuilding = true;
2022-04-14 05:50:44 +01:00
meta = with lib; {
homepage = "http://libarchive.org";
2012-10-21 06:17:14 +01:00
description = "Multi-format archive and compression library";
longDescription = ''
2022-04-14 05:50:44 +01: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.
2012-10-21 06:17:14 +01:00
'';
2020-12-02 17:19:06 +00:00
changelog = "https://github.com/libarchive/libarchive/releases/tag/v${version}";
2022-04-14 05:50:44 +01:00
license = licenses.bsd3;
maintainers = with maintainers; [ jcumming AndersonTorres ];
platforms = platforms.all;
};
passthru.tests = {
inherit cmake nix samba;
};
}