|
| 1 | +# Copyright 1999-2025 Gentoo Authors |
| 2 | +# Distributed under the terms of the GNU General Public License v2 |
| 3 | + |
| 4 | +EAPI=8 |
| 5 | + |
| 6 | +VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/tar.asc |
| 7 | +inherit multiprocessing verify-sig autotools |
| 8 | + |
| 9 | +DESCRIPTION="Use this to make tarballs :)" |
| 10 | +HOMEPAGE="https://www.gnu.org/software/tar/" |
| 11 | +SRC_URI=" |
| 12 | + mirror://gnu/tar/${P}.tar.xz |
| 13 | + https://alpha.gnu.org/gnu/tar/${P}.tar.xz |
| 14 | + verify-sig? ( |
| 15 | + mirror://gnu/tar/${P}.tar.xz.sig |
| 16 | + https://alpha.gnu.org/gnu/tar/${P}.tar.xz.sig |
| 17 | + ) |
| 18 | +" |
| 19 | + |
| 20 | +LICENSE="GPL-3+" |
| 21 | +SLOT="0" |
| 22 | +if [[ -z "$(ver_cut 3)" || "$(ver_cut 3)" -lt 90 ]] ; then |
| 23 | + 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" |
| 24 | +fi |
| 25 | +IUSE="acl minimal nls selinux xattr" |
| 26 | + |
| 27 | +RDEPEND=" |
| 28 | + acl? ( virtual/acl ) |
| 29 | + selinux? ( sys-libs/libselinux ) |
| 30 | +" |
| 31 | +DEPEND=" |
| 32 | + ${RDEPEND} |
| 33 | + xattr? ( elibc_glibc? ( sys-apps/attr ) ) |
| 34 | +" |
| 35 | +BDEPEND=" |
| 36 | + nls? ( sys-devel/gettext ) |
| 37 | + verify-sig? ( sec-keys/openpgp-keys-tar ) |
| 38 | +" |
| 39 | +PDEPEND=" |
| 40 | + app-alternatives/tar |
| 41 | +" |
| 42 | + |
| 43 | +PATCHES=( "${FILESDIR}"/${P}-libintl.patch ) |
| 44 | + |
| 45 | +src_prepare() { |
| 46 | + default |
| 47 | + eautoreconf |
| 48 | +} |
| 49 | + |
| 50 | +src_configure() { |
| 51 | + # -fanalyzer doesn't make sense for us in ebuilds, as it's for static analysis |
| 52 | + export gl_cv_warn_c__fanalyzer=no |
| 53 | + |
| 54 | + local myeconfargs=( |
| 55 | + --bindir="${EPREFIX}"/bin |
| 56 | + # Avoid -Werror |
| 57 | + --disable-gcc-warnings |
| 58 | + --enable-backup-scripts |
| 59 | + --libexecdir="${EPREFIX}"/usr/sbin |
| 60 | + $(use_with acl posix-acls) |
| 61 | + $(use_enable nls) |
| 62 | + $(use_with selinux) |
| 63 | + $(use_with xattr xattrs) |
| 64 | + |
| 65 | + # autoconf looks for gtar before tar (in configure scripts), hence |
| 66 | + # in Prefix it is important that it is there, otherwise, a gtar from |
| 67 | + # the host system (FreeBSD, Solaris, Darwin) will be found instead |
| 68 | + # of the Prefix provided (GNU) tar |
| 69 | + --program-prefix=g |
| 70 | + ) |
| 71 | + |
| 72 | + # Drop CONFIG_SHELL hack after 1.35: https://git.savannah.gnu.org/cgit/tar.git/commit/?id=7687bf4acc4dc4554538389383d7fb4c3e6521cd |
| 73 | + CONFIG_SHELL="${BROOT}"/bin/bash FORCE_UNSAFE_CONFIGURE=1 econf "${myeconfargs[@]}" |
| 74 | +} |
| 75 | + |
| 76 | +src_test() { |
| 77 | + # Drop after 1.35: https://git.savannah.gnu.org/cgit/tar.git/commit/?id=18f90676e4695ffcf13413e9fbb24cc0ae2ae9d5 |
| 78 | + local -x XZ_OPT= XZ_DEFAULTS= |
| 79 | + |
| 80 | + emake check TESTSUITEFLAGS="--jobs=$(get_makeopts_jobs)" |
| 81 | +} |
| 82 | + |
| 83 | +src_install() { |
| 84 | + default |
| 85 | + |
| 86 | + # A nasty yet required piece of baggage |
| 87 | + exeinto /etc |
| 88 | + doexe "${FILESDIR}"/rmt |
| 89 | + |
| 90 | + mv "${ED}"/usr/sbin/{gbackup,backup-tar} || die |
| 91 | + mv "${ED}"/usr/sbin/{grestore,restore-tar} || die |
| 92 | + mv "${ED}"/usr/sbin/{g,}backup.sh || die |
| 93 | + mv "${ED}"/usr/sbin/{g,}dump-remind || die |
| 94 | + |
| 95 | + if use minimal ; then |
| 96 | + find "${ED}"/etc "${ED}"/*bin/ "${ED}"/usr/*bin/ \ |
| 97 | + -type f -a '!' -name gtar \ |
| 98 | + -delete || die |
| 99 | + fi |
| 100 | + |
| 101 | + if ! use minimal; then |
| 102 | + dosym grmt /usr/sbin/rmt |
| 103 | + fi |
| 104 | + dosym grmt.8 /usr/share/man/man8/rmt.8 |
| 105 | +} |
| 106 | + |
| 107 | +pkg_postinst() { |
| 108 | + # Ensure to preserve the symlink before app-alternatives/tar |
| 109 | + # is installed |
| 110 | + if [[ ! -h ${EROOT}/bin/tar ]]; then |
| 111 | + if [[ -e ${EROOT}/usr/bin/tar ]] ; then |
| 112 | + # bug #904887 |
| 113 | + ewarn "${EROOT}/usr/bin/tar exists but is not a symlink." |
| 114 | + ewarn "This is expected during Prefix bootstrap and unusual otherwise." |
| 115 | + ewarn "Moving away unexpected ${EROOT}/usr/bin/tar to .bak." |
| 116 | + mv "${EROOT}/usr/bin/tar" "${EROOT}/usr/bin/tar.bak" || die |
| 117 | + fi |
| 118 | + ln -s gtar "${EROOT}/bin/tar" || die |
| 119 | + fi |
| 120 | +} |
0 commit comments