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

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

135 lines
3.7 KiB
Nix
Raw Normal View History

2022-04-14 04:50:44 +00:00
{ lib
, stdenv
, fetchFromGitHub
, fetchpatch
2022-04-14 04:50:44 +00:00
, 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 04:50:44 +00:00
# for passthru.tests
, cmake
, nix
, samba
, buildPackages
}:
let
autoreconfHook = buildPackages.autoreconfHook269;
in
assert xarSupport -> libxml2 != null;
(stdenv.mkDerivation (finalAttrs: {
pname = "libarchive";
2022-12-13 20:17:53 +00:00
version = "3.6.2";
src = fetchFromGitHub {
owner = "libarchive";
repo = "libarchive";
rev = "v${finalAttrs.version}";
2022-12-13 20:17:53 +00:00
hash = "sha256-wQbA6vlXH8pnpY7LJLkjrRFEBpcaPR1SqxnK71UVwxg=";
};
outputs = [ "out" "lib" "dev" ];
2022-04-17 11:07:41 +00:00
postPatch = let
skipTestPaths = [
2022-04-17 11:07:41 +00:00
# test won't work in nix sandbox
"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"
# access-time-related tests flakey on some systems
"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-17 11:07:41 +00:00
${lib.concatStringsSep "\n" (map removeTest skipTestPaths)}
'';
2016-09-19 12:33:25 +00:00
2022-04-14 04:50:44 +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 ]
++ 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 04:50:44 +00:00
preBuild = lib.optionalString stdenv.isCygwin ''
2014-10-29 22:45:15 +00:00
echo "#include <windows.h>" >> config.h
2022-04-14 04:50:44 +00:00
'';
2014-10-29 22:45:15 +00:00
2022-04-17 11:07:41 +00:00
# https://github.com/libarchive/libarchive/issues/1475
doCheck = !stdenv.hostPlatform.isMusl;
2015-07-28 13:22:40 +00:00
preFixup = ''
2016-09-19 12:33:25 +00: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 12:06:23 +00:00
-e 's|-llzo2|-L${lzo}/lib -llzo2|'
2015-07-28 13:22:40 +00:00
'';
2018-06-04 12:48:39 +00:00
enableParallelBuilding = true;
2022-04-14 04:50:44 +00:00
meta = with lib; {
homepage = "http://libarchive.org";
2012-10-21 05:17:14 +00:00
description = "Multi-format archive and compression library";
longDescription = ''
2022-04-14 04:50:44 +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.
2012-10-21 05:17:14 +00:00
'';
changelog = "https://github.com/libarchive/libarchive/releases/tag/v${finalAttrs.version}";
2022-04-14 04:50:44 +00:00
license = licenses.bsd3;
maintainers = with maintainers; [ jcumming AndersonTorres ];
platforms = platforms.all;
};
passthru.tests = {
inherit cmake nix samba;
};
})).overrideAttrs(previousAttrs:
assert previousAttrs.version == "3.6.2";
lib.optionalAttrs stdenv.hostPlatform.isStatic {
patches = [
# fixes static linking; upstream in releases after 3.6.2
# https://github.com/libarchive/libarchive/pull/1825 merged upstream
(fetchpatch {
name = "001-only-add-iconv-to-pc-file-if-needed.patch";
url = "https://github.com/libarchive/libarchive/commit/1f35c466aaa9444335a1b854b0b7223b0d2346c2.patch";
hash = "sha256-lb+zwWSH6/MLUIROvu9I/hUjSbb2jOWO755WC/r+lbY=";
})
];
})