When bootstrapping Gentoo Prefix on macOS 13.2 (Ventura) on an Apple M1 system, it will fail at stage3 due to tar a postinst failure. Reproducible: Always Steps to Reproduce: 1. export LATEST_TREE_YES=1 2. ${EPREFIX}/bootstrap-prefix.sh ${EPREFIX} stage1 This should proceed without any problem. 3. Change MAKEOPTS to "-j4" in etc/portage/make.conf/0100_bootstrap_prefix_make.conf (not sure if it's really necessary, I'm now trying to replicate it with single-threaded build). 4. ${EPREFIX}/bootstrap-prefix.sh ${EPREFIX} stage2 5. ${EPREFIX}/bootstrap-prefix.sh ${EPREFIX} stage3 Actual Results: Bootstrap eventually stops because of the installation failure of app-arch/tar-1.34-r3::gentoo_prefix. It doesn't stop immediately, but it will stop after 81 packages are merged. >>> Installing (21 of 81) app-arch/tar-1.34-r3::gentoo_prefix Warning: File compression unsupported zstd. Missing package: app-arch/zstd Warning: File compression unsupported zstd. Missing package: app-arch/zstd * checking 18 files for package collisions >>> Merging app-arch/tar-1.34-r3 to / --- /Users/ec2-user/gentoo/tmp/etc/ >>> /Users/ec2-user/gentoo/tmp/etc/rmt --- /Users/ec2-user/gentoo/tmp/bin/ >>> /Users/ec2-user/gentoo/tmp/bin/gtar --- /Users/ec2-user/gentoo/tmp/usr/ --- /Users/ec2-user/gentoo/tmp/usr/share/ --- /Users/ec2-user/gentoo/tmp/usr/share/doc/ >>> /Users/ec2-user/gentoo/tmp/usr/share/doc/tar-1.34-r3/ >>> /Users/ec2-user/gentoo/tmp/usr/share/doc/tar-1.34-r3/README.bz2 >>> /Users/ec2-user/gentoo/tmp/usr/share/doc/tar-1.34-r3/CHANGELOG.bz2 >>> /Users/ec2-user/gentoo/tmp/usr/share/doc/tar-1.34-r3/THANKS.bz2 >>> /Users/ec2-user/gentoo/tmp/usr/share/doc/tar-1.34-r3/AUTHORS.bz2 >>> /Users/ec2-user/gentoo/tmp/usr/share/doc/tar-1.34-r3/TODO.bz2 >>> /Users/ec2-user/gentoo/tmp/usr/share/doc/tar-1.34-r3/NEWS.bz2 --- /Users/ec2-user/gentoo/tmp/usr/share/info/ >>> /Users/ec2-user/gentoo/tmp/usr/share/info/tar.info-2.bz2 >>> /Users/ec2-user/gentoo/tmp/usr/share/info/tar.info-1.bz2 >>> /Users/ec2-user/gentoo/tmp/usr/share/info/tar.info.bz2 --- /Users/ec2-user/gentoo/tmp/usr/share/man/ --- /Users/ec2-user/gentoo/tmp/usr/share/man/man1/ >>> /Users/ec2-user/gentoo/tmp/usr/share/man/man1/gtar.1.bz2 --- /Users/ec2-user/gentoo/tmp/usr/share/man/man8/ --- /Users/ec2-user/gentoo/tmp/usr/sbin/ >>> /Users/ec2-user/gentoo/tmp/usr/sbin/restore-tar >>> /Users/ec2-user/gentoo/tmp/usr/sbin/backup.sh >>> /Users/ec2-user/gentoo/tmp/usr/sbin/dump-remind >>> /Users/ec2-user/gentoo/tmp/usr/sbin/backup-tar * QA Notice: Symbolic link /Users/ec2-user/gentoo/tmp/usr/share/man/man8/rmt.8 points to /Users/ec2-user/gentoo/tmp/usr/share/man/man8/grmt.8 which does not exist. >>> /Users/ec2-user/gentoo/tmp/usr/share/man/man8/rmt.8 -> grmt.8 * QA Notice: Symbolic link /Users/ec2-user/gentoo/tmp/usr/sbin/rmt points to /Users/ec2-user/gentoo/tmp/usr/sbin/grmt which does not exist. >>> /Users/ec2-user/gentoo/tmp/usr/sbin/rmt -> grmt ln: failed to create symbolic link '/Users/ec2-user/gentoo/tmp/bin/tar': File exists * ERROR: app-arch/tar-1.34-r3::gentoo_prefix failed (postinst phase): * (no error message) * * Call stack: * ebuild.sh, line 127: Called pkg_postinst * environment, line 472: Called die * The specific snippet of code: * ln -s gtar "${EROOT}/bin/tar" || die; * * If you need support, post the output of `emerge --info '=app-arch/tar-1.34-r3::gentoo_prefix'`, * the complete build log and the output of `emerge -pqv '=app-arch/tar-1.34-r3::gentoo_prefix'`. * The complete build log is located at '/Users/ec2-user/gentoo/tmp/var/tmp/portage/app-arch/tar-1.34-r3/temp/build.log'. * The ebuild environment file is located at '/Users/ec2-user/gentoo/tmp/var/tmp/portage/app-arch/tar-1.34-r3/temp/environment'. * Working directory: '/Users/ec2-user/gentoo/tmp/var/tmp/portage/app-arch/tar-1.34-r3/empty' * S: '/Users/ec2-user/gentoo/tmp/var/tmp/portage/app-arch/tar-1.34-r3/work/tar-1.34' * FAILED postinst: 1 Warning: File compression unsupported zstd. Missing package: app-arch/zstd >>> Failed to execute postinst for app-arch/tar-1.34-r3 Expected Results: Stage3 bootstrap should continue without a tar failure.
What does ls -al /Users/ec2-user/gentoo/tmp/bin/tar show? We probably want an -f there.
(In reply to Sam James from comment #1) > What does ls -al /Users/ec2-user/gentoo/tmp/bin/tar show? > > We probably want an -f there. ... or maybe not, see bug 886123.
(In reply to Sam James from comment #1) > What does ls -al /Users/ec2-user/gentoo/tmp/bin/tar show? > > We probably want an -f there. Before running stage3, it's a binary executable. I believe it's built during early stages: % ls -al /Users/ec2-user/gentoo-stage2ok/tmp/bin/tar -rwxr-xr-x 1 ec2-user staff 637376 Apr 23 11:09 /Users/ec2-user/gentoo-stage2ok/tmp/bin/tar After running stage3 it becomes a symbolic link: % ls -al /Users/ec2-user/gentoo-broken/tmp/bin/tar lrwxrwxrwx 1 ec2-user staff 4 Apr 23 14:15 /Users/ec2-user/gentoo-broken/tmp/bin/tar -> gtar What's strange about the bug is that somehow, the file was overwritten nevertheless in spite of the failure. If stage3 is restarted, tar no longer reports any error.
(In reply to Sam James from comment #2) > (In reply to Sam James from comment #1) > > What does ls -al /Users/ec2-user/gentoo/tmp/bin/tar show? > > > > We probably want an -f there. > > ... or maybe not, see bug 886123. Aha, it must be the root cause. Before app-alternatives/tar, during bootstrap stage3, tar would be simply a file conflict, which is overwritten by default. But it's now a symbolic link and you can't overwrite a file using a link without triggering this error.
Yeah, that sounds right. Fancy trying to copy the app-arch/tar logic?
(In reply to Sam James from comment #5) > Yeah, that sounds right. Fancy trying to copy the app-arch/tar logic? I just committed a fix to my private tree. I'll open a pull request to upstream to patch to Gentoo once it's tested.
I just tested my patch and confirmed that it works. I opened a Pull Request at https://github.com/gentoo/gentoo/pull/30723.
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ef1e3dad5e18f887a56ae06c02eff74ab5c33a40 commit ef1e3dad5e18f887a56ae06c02eff74ab5c33a40 Author: Yifeng Li <tomli@tomli.me> AuthorDate: 2023-04-23 16:43:02 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2023-04-23 19:12:59 +0000 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 <sam@gentoo.org> Signed-off-by: Yifeng Li <tomli@tomli.me> Closes: https://github.com/gentoo/gentoo/pull/30723 Signed-off-by: Sam James <sam@gentoo.org> app-arch/tar/tar-1.34-r2.ebuild | 7 +++++++ app-arch/tar/tar-1.34-r3.ebuild | 7 +++++++ 2 files changed, 14 insertions(+)