Skip to content

Commit

Permalink
app-arch/tar: adapt pkg_postinst for prefix bootstrapping
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Yifeng Li <[email protected]>
Closes: gentoo#30723
Signed-off-by: Sam James <[email protected]>
  • Loading branch information
biergaizi authored and thesamesam committed Apr 23, 2023
1 parent 7b275b0 commit ef1e3da
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app-arch/tar/tar-1.34-r2.ebuild
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
7 changes: 7 additions & 0 deletions app-arch/tar/tar-1.34-r3.ebuild
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit ef1e3da

Please sign in to comment.