Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gentoo-build: Add argument --fail-to-shell #89

Merged
merged 1 commit into from
Mar 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions binary_gentoo/internal/cli/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ def parse_command_line(argv):
dest='tag_docker_image',
help='create a Docker image from the resulting container')

parser.add_argument('--fail-to-shell',
dest='fail_to_shell',
action='store_true',
help='drop into an in-container Bash shell on failure')

parser.add_argument(
'emerge_target',
metavar='CP|CPV|=CPV|@SET',
Expand Down Expand Up @@ -338,6 +343,11 @@ def build(config):
f'{emerge_quoted_flat} {rebuild_or_not} {install_or_not} {shlex.quote(config.emerge_target)}' # noqa: E501
)

if config.fail_to_shell:
success_chain_flat = ' && '.join(step_commands)
step_commands = [f'{{ {{ {success_chain_flat} ; }} || {{ bash -i ; }} ; }}']
del success_chain_flat

if container_name is not None:
# Cleanup symlinks that were created in previous steps, otherwise subsequent
# builds with --tag-docker-image will fail when the same symlinks are re-created
Expand Down