From ef1e3dad5e18f887a56ae06c02eff74ab5c33a40 Mon Sep 17 00:00:00 2001 From: Yifeng Li Date: Sun, 23 Apr 2023 16:43:02 +0000 Subject: app-arch/tar: adapt pkg_postinst for prefix bootstrapping This commit allows Portage to overwrite the binary executable "tar" with a symbolic link, this situation is encountered during Gentoo prefix bootstrap. If left unhandled, it causes the bootstrap to fail with the error message: ln: failed to create symbolic link '/Users/ec2-user/gentoo/tmp/bin/tar': File exists The original binary is renamed to tar.bak. [sam: This is analogous to sys-devel/bison's hack too.] Bug: https://bugs.gentoo.org/886123 Closes: https://bugs.gentoo.org/904887 Suggested-by: Sam James Signed-off-by: Yifeng Li Closes: https://github.com/gentoo/gentoo/pull/30723 Signed-off-by: Sam James --- app-arch/tar/tar-1.34-r2.ebuild | 7 +++++++ app-arch/tar/tar-1.34-r3.ebuild | 7 +++++++ 2 files changed, 14 insertions(+) (limited to 'app-arch') diff --git a/app-arch/tar/tar-1.34-r2.ebuild b/app-arch/tar/tar-1.34-r2.ebuild index 86fdc8e05e20..805941b1f61c 100644 --- a/app-arch/tar/tar-1.34-r2.ebuild +++ b/app-arch/tar/tar-1.34-r2.ebuild @@ -90,6 +90,13 @@ pkg_postinst() { # ensure to preserve the symlink before app-alternatives/tar # is installed if [[ ! -h ${EROOT}/bin/tar ]]; then + if [[ -e ${EROOT}/usr/bin/tar ]] ; then + # bug #904887 + ewarn "${EROOT}/usr/bin/tar exists but is not a symlink." + ewarn "This is expected during Prefix bootstrap and unsual otherwise." + ewarn "Moving away unexpected ${EROOT}/usr/bin/tar to .bak." + mv "${EROOT}/usr/bin/tar" "${EROOT}/usr/bin/tar.bak" || die + fi ln -s gtar "${EROOT}/bin/tar" || die fi } diff --git a/app-arch/tar/tar-1.34-r3.ebuild b/app-arch/tar/tar-1.34-r3.ebuild index f92891dceff1..da958a84470e 100644 --- a/app-arch/tar/tar-1.34-r3.ebuild +++ b/app-arch/tar/tar-1.34-r3.ebuild @@ -94,6 +94,13 @@ pkg_postinst() { # ensure to preserve the symlink before app-alternatives/tar # is installed if [[ ! -h ${EROOT}/bin/tar ]]; then + if [[ -e ${EROOT}/usr/bin/tar ]] ; then + # bug #904887 + ewarn "${EROOT}/usr/bin/tar exists but is not a symlink." + ewarn "This is expected during Prefix bootstrap and unsual otherwise." + ewarn "Moving away unexpected ${EROOT}/usr/bin/tar to .bak." + mv "${EROOT}/usr/bin/tar" "${EROOT}/usr/bin/tar.bak" || die + fi ln -s gtar "${EROOT}/bin/tar" || die fi } -- cgit v1.2.3-65-gdbad