Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 881839 - scripts/bootstrap.sh: returns '1' if pruning of sys-devel/gcc fails on line 349 (affects catalyst stage2 run)
Summary: scripts/bootstrap.sh: returns '1' if pruning of sys-devel/gcc fails on line 3...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Release Team
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2022-11-18 23:22 UTC by Joshua Kinard
Modified: 2023-10-02 03:25 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
scripts/bootstrap.sh: don't fail on --prune of sys-devel/gcc (bootstrap_sh-dont-fail-on-gcc-prune.diff,596 bytes, patch)
2022-11-28 22:28 UTC, Joshua Kinard
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joshua Kinard gentoo-dev 2022-11-18 23:22:23 UTC
When running stage2 in catalyst, at the very end of the stage run, this error can happen:

> >>> sys-apps/texinfo-7.0 merged.
> 
>  * Messages for package sys-apps/baselayout-2.9:
> 
>  * After updating /etc/profile, please run
>  * env-update && . /etc/profile
>  * Please run env-update then log out and back in to
>  * update your path.
> -------------------------------------------------------------------------------
>  * Executing: emerge --oneshot -v --usepkg --buildpkg --prune sys-devel/gcc
> 
> Calculating dependencies... done!
>   sys-devel/gcc-12.2.0 pulled in by:
>     @system requires sys-devel/gcc
>     sys-libs/glibc-2.36-r5 requires >=sys-devel/gcc-6.2
> 
> >>> No packages selected for removal by prune
> >>> To ignore dependencies, use --nodeps
> 18 Nov 2022 04:46:50 EST: ERROR   : CatalystError: cmd(['/usr/share/catalyst/targets/stage2/stage2-controller.sh', 'run']) exited 1
> ERROR:catalyst:CatalystError: cmd(['/usr/share/catalyst/targets/stage2/stage2-controller.sh', 'run']) exited 1
> 18 Nov 2022 04:46:50 EST: NOTICE  : /nas/catalyst/tmp/n32/stage2-mips3_n32-20221112/var/tmp/portage is not a mount point. Skipping
> NOTICE:catalyst:/nas/catalyst/tmp/n32/stage2-mips3_n32-20221112/var/tmp/portage is not a mount point. Skipping
> 18 Nov 2022 04:46:50 EST: ERROR   : CatalystError: Stage build aborting due to error.
> ERROR:catalyst:CatalystError: Stage build aborting due to error.
> 18 Nov 2022 04:46:50 EST: ERROR   : Exception running action sequence run_local
> Traceback (most recent call last):
>   File "/usr/lib/python3.10/site-packages/catalyst/base/stagebase.py", line 1392, in run_local
>     cmd([self.settings['controller_file'], 'run'],
>   File "/usr/lib/python3.10/site-packages/catalyst/support.py", line 53, in cmd
>     raise CatalystError('cmd(%r) exited %s' % (args, ret),
> catalyst.support.CatalystError: cmd(['/usr/share/catalyst/targets/stage2/stage2-controller.sh', 'run']) exited 1


The trigger is scripts/bootstrap.sh running this command on line 349:

    # Make sure we get the old gcc unmerged ...
    ${V_ECHO} emerge ${STRAP_EMERGE_OPTS} --prune sys-devel/gcc || cleanup 1

The return code of '1' will cause the stage2-chroot.sh script in catalyst to bail out.  I am thinking that bootstrap.sh needs to be changed to not return '1' when the pruning of other sys-devel/gcc instances fails, since the intent is to remove all BUT the latest version (which is what emerge's manpage says about --prune).  If the stage2 chroot already has all of the other gcc's removed, that command is going to return '1' because of @system requiring at least one sys-devel/gcc to be merged.

I suggest making this change:

--- scripts/bootstrap.sh.orig	2022-11-18 18:13:44.762079000 -0500
+++ scripts/bootstrap.sh	2022-11-18 18:13:56.330250000 -0500
@@ -346,7 +346,7 @@ if [[ -n ${STRAP_RUN} ]] ; then
 	if [[ -x ${GCC_CONFIG} ]] && ${GCC_CONFIG} --get-current-profile &>/dev/null
 	then
 		# Make sure we get the old gcc unmerged ...
-		${V_ECHO} emerge ${STRAP_EMERGE_OPTS} --prune sys-devel/gcc || cleanup 1
+		${V_ECHO} emerge ${STRAP_EMERGE_OPTS} --prune sys-devel/gcc
 		# Make sure the profile and /lib/cpp and /usr/bin/cc are valid ...
 		${GCC_CONFIG} "$(${GCC_CONFIG} --get-current-profile)" &>/dev/null
 	fi

Another approach may be to run 'emerge --depclean --deep' instead of --prune.  I've witnessed that older gcc's will typically get removed by a --depclean, even when stepping up a major version.  That way, the "|| cleanup 1" bit can be retained to catch any failures by emerge.
Comment 1 Joshua Kinard gentoo-dev 2022-11-28 22:28:30 UTC
Created attachment 838047 [details, diff]
scripts/bootstrap.sh: don't fail on --prune of sys-devel/gcc

(In reply to Joshua Kinard from comment #0)
> Another approach may be to run 'emerge --depclean --deep' instead of
> --prune.  I've witnessed that older gcc's will typically get removed by a
> --depclean, even when stepping up a major version.  That way, the "||
> cleanup 1" bit can be retained to catch any failures by emerge.

I tried testing using '--depclean --deep' recently and it still fails, so it's not viable.  The only working solution, it seems, is to remove the "|| cleanup 1" bit from line #349.  Attached an actual patch for that.
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-09-29 09:45:12 UTC
Please commit this and just cite this bug with Closes:.

It's correct and it's because of the change in bug 851750.
Comment 3 Joshua Kinard gentoo-dev 2023-09-30 03:57:06 UTC
(In reply to Sam James from comment #2)
> Please commit this and just cite this bug with Closes:.
> 
> It's correct and it's because of the change in bug 851750.

I'll make a note to try and hit this tomorrow (Saturday; still Friday for me) or Sunday.  Thanks!
Comment 4 Larry the Git Cow gentoo-dev 2023-10-02 03:25:14 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=67495c6078f95162d424d1c0942ad55c33a02149

commit 67495c6078f95162d424d1c0942ad55c33a02149
Author:     Joshua Kinard <kumba@gentoo.org>
AuthorDate: 2023-10-02 03:18:37 +0000
Commit:     Joshua Kinard <kumba@gentoo.org>
CommitDate: 2023-10-02 03:18:37 +0000

    scripts/bootstrap.sh: Don't bail if 'emerge --prune' returns 1
    
    If 'emerge --prune' doesn't find any older gcc's to prune, it
    will return '1', which causes bootstrap.sh to run the cleanup
    method, and this results in catalyst aborting at the end of a
    stage2 build.  Removing the all to cleanup prevents this.
    Issue was added due to resolution of Bug #851750.
    
    Closes: https://bugs.gentoo.org/881839
    Signed-off-by: Joshua Kinard <kumba@gentoo.org>

 scripts/bootstrap.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)