|
| 1 | +# Copyright 1999-2025 Gentoo Authors |
| 2 | +# Distributed under the terms of the GNU General Public License v2 |
| 3 | + |
| 4 | +EAPI=8 |
| 5 | +inherit libtool multilib-minimal toolchain-funcs verify-sig |
| 6 | + |
| 7 | +DESCRIPTION="Multi-format archive and compression library" |
| 8 | +HOMEPAGE=" |
| 9 | + https://www.libarchive.org/ |
| 10 | + https://github.com/libarchive/libarchive/ |
| 11 | +" |
| 12 | +SRC_URI=" |
| 13 | + https://www.libarchive.de/downloads/${P}.tar.xz |
| 14 | + verify-sig? ( https://www.libarchive.de/downloads/${P}.tar.xz.asc ) |
| 15 | +" |
| 16 | + |
| 17 | +LICENSE="BSD BSD-2 BSD-4 public-domain" |
| 18 | +SLOT="0/13" |
| 19 | +KEYWORDS="~alpha amd64 arm arm64 ~hppa ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos ~x64-macos ~x64-solaris" |
| 20 | +IUSE=" |
| 21 | + acl blake2 +bzip2 +e2fsprogs expat +iconv lz4 +lzma lzo nettle |
| 22 | + static-libs test xattr +zstd |
| 23 | +" |
| 24 | +RESTRICT="!test? ( test )" |
| 25 | + |
| 26 | +RDEPEND=" |
| 27 | + sys-libs/zlib:=[${MULTILIB_USEDEP}] |
| 28 | + acl? ( virtual/acl:=[${MULTILIB_USEDEP}] ) |
| 29 | + blake2? ( app-crypt/libb2:=[${MULTILIB_USEDEP}] ) |
| 30 | + bzip2? ( app-arch/bzip2:=[${MULTILIB_USEDEP}] ) |
| 31 | + expat? ( dev-libs/expat:=[${MULTILIB_USEDEP}] ) |
| 32 | + !expat? ( dev-libs/libxml2:=[${MULTILIB_USEDEP}] ) |
| 33 | + iconv? ( virtual/libiconv:=[${MULTILIB_USEDEP}] ) |
| 34 | + dev-libs/openssl:=[${MULTILIB_USEDEP}] |
| 35 | + lz4? ( >=app-arch/lz4-0_p131:=[${MULTILIB_USEDEP}] ) |
| 36 | + lzma? ( >=app-arch/xz-utils-5.2.5-r1:=[${MULTILIB_USEDEP}] ) |
| 37 | + lzo? ( >=dev-libs/lzo-2:=[${MULTILIB_USEDEP}] ) |
| 38 | + nettle? ( dev-libs/nettle:=[${MULTILIB_USEDEP}] ) |
| 39 | + zstd? ( app-arch/zstd:=[${MULTILIB_USEDEP}] ) |
| 40 | +" |
| 41 | +DEPEND="${RDEPEND} |
| 42 | + kernel_linux? ( |
| 43 | + virtual/os-headers |
| 44 | + e2fsprogs? ( sys-fs/e2fsprogs[${MULTILIB_USEDEP}] ) |
| 45 | + ) |
| 46 | + test? ( |
| 47 | + app-arch/lrzip |
| 48 | + app-arch/lz4 |
| 49 | + app-arch/lzip |
| 50 | + app-arch/lzop |
| 51 | + app-arch/xz-utils |
| 52 | + app-arch/zstd |
| 53 | + lzma? ( app-arch/xz-utils[extra-filters(+)] ) |
| 54 | + ) |
| 55 | +" |
| 56 | +BDEPEND=" |
| 57 | + verify-sig? ( >=sec-keys/openpgp-keys-libarchive-20221209 ) |
| 58 | + elibc_musl? ( sys-libs/queue-standalone ) |
| 59 | +" |
| 60 | + |
| 61 | +VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/libarchive.org.asc |
| 62 | + |
| 63 | +# false positives (checks for libc-defined hash functions) |
| 64 | +QA_CONFIG_IMPL_DECL_SKIP=( |
| 65 | + SHA256_Init SHA256_Update SHA256_Final |
| 66 | + SHA384_Init SHA384_Update SHA384_Final |
| 67 | + SHA512_Init SHA512_Update SHA512_Final |
| 68 | +) |
| 69 | + |
| 70 | +PATCHES=( |
| 71 | + # https://github.com/libarchive/libarchive/issues/2069 |
| 72 | + # (we can simply update the command since we don't support old lrzip) |
| 73 | + "${FILESDIR}/${PN}-3.7.2-lrzip.patch" |
| 74 | +) |
| 75 | + |
| 76 | +src_prepare() { |
| 77 | + default |
| 78 | + |
| 79 | + # Needed for flags to be respected w/ LTO |
| 80 | + elibtoolize |
| 81 | +} |
| 82 | + |
| 83 | +multilib_src_configure() { |
| 84 | + export ac_cv_header_ext2fs_ext2_fs_h=$(usex e2fsprogs) #354923 |
| 85 | + |
| 86 | + local myconf=( |
| 87 | + $(use_enable acl) |
| 88 | + $(use_enable static-libs static) |
| 89 | + $(use_enable xattr) |
| 90 | + $(use_with blake2 libb2) |
| 91 | + $(use_with bzip2 bz2lib) |
| 92 | + $(use_with expat) |
| 93 | + $(use_with !expat xml2) |
| 94 | + $(use_with iconv) |
| 95 | + $(use_with lz4) |
| 96 | + $(use_with lzma) |
| 97 | + $(use_with lzo lzo2) |
| 98 | + $(use_with nettle) |
| 99 | + --with-zlib |
| 100 | + $(use_with zstd) |
| 101 | + |
| 102 | + # Windows-specific |
| 103 | + --without-cng |
| 104 | + ) |
| 105 | + if multilib_is_native_abi ; then |
| 106 | + myconf+=( |
| 107 | + --enable-bsdcat="$(tc-is-static-only && echo static || echo shared)" |
| 108 | + --enable-bsdcpio="$(tc-is-static-only && echo static || echo shared)" |
| 109 | + --enable-bsdtar="$(tc-is-static-only && echo static || echo shared)" |
| 110 | + --enable-bsdunzip="$(tc-is-static-only && echo static || echo shared)" |
| 111 | + ) |
| 112 | + else |
| 113 | + myconf+=( |
| 114 | + --disable-bsdcat |
| 115 | + --disable-bsdcpio |
| 116 | + --disable-bsdtar |
| 117 | + --disable-bsdunzip |
| 118 | + ) |
| 119 | + fi |
| 120 | + |
| 121 | + ECONF_SOURCE="${S}" econf "${myconf[@]}" |
| 122 | +} |
| 123 | + |
| 124 | +multilib_src_compile() { |
| 125 | + if multilib_is_native_abi ; then |
| 126 | + emake |
| 127 | + else |
| 128 | + emake libarchive.la |
| 129 | + fi |
| 130 | +} |
| 131 | + |
| 132 | +src_test() { |
| 133 | + mkdir -p "${T}"/bin || die |
| 134 | + # tests fail when lbzip2[symlink] is used in place of ref bunzip2 |
| 135 | + ln -s "${BROOT}/bin/bunzip2" "${T}"/bin || die |
| 136 | + # workaround lrzip broken on 32-bit arches with >= 10 threads |
| 137 | + # https://bugs.gentoo.org/927766 |
| 138 | + cat > "${T}"/bin/lrzip <<-EOF || die |
| 139 | + #!/bin/sh |
| 140 | + exec "$(type -P lrzip)" -p1 "\${@}" |
| 141 | + EOF |
| 142 | + chmod +x "${T}/bin/lrzip" || die |
| 143 | + local -x PATH=${T}/bin:${PATH} |
| 144 | + multilib-minimal_src_test |
| 145 | +} |
| 146 | + |
| 147 | +multilib_src_test() { |
| 148 | + # sandbox is breaking long symlink behavior |
| 149 | + local -x SANDBOX_ON=0 |
| 150 | + local -x LD_PRELOAD= |
| 151 | + # some locales trigger different output that breaks tests |
| 152 | + local -x LC_ALL=C.UTF-8 |
| 153 | + emake check |
| 154 | +} |
| 155 | + |
| 156 | +multilib_src_install() { |
| 157 | + if multilib_is_native_abi ; then |
| 158 | + emake DESTDIR="${D}" install |
| 159 | + else |
| 160 | + local install_targets=( |
| 161 | + install-includeHEADERS |
| 162 | + install-libLTLIBRARIES |
| 163 | + install-pkgconfigDATA |
| 164 | + ) |
| 165 | + emake DESTDIR="${D}" "${install_targets[@]}" |
| 166 | + fi |
| 167 | + |
| 168 | + # Libs.private: should be used from libarchive.pc instead |
| 169 | + find "${ED}" -type f -name "*.la" -delete || die |
| 170 | + # https://github.com/libarchive/libarchive/issues/1766 |
| 171 | + sed -e '/Requires\.private/s:iconv::' \ |
| 172 | + -i "${ED}/usr/$(get_libdir)/pkgconfig/libarchive.pc" || die |
| 173 | +} |
0 commit comments