add --break for requesting a debug shell

Similar to rd.break for dracut this allows a user to specify:

- --break or --break=*
    - to get a shell before each stage is run
- --break=stage.name
    - to get a shell each time the stage with that name is run
    - example: --break=org.osbuild.copy
- --break=stage.id
    - to get a shell each time the stage with that ID is run
    - get the ID for the stages for your manifest by running
      osbuild on the manifest with --inspect
    - example: --break=dc6e3a66fef3ebe7c815eb24d348215b9e5e2ed0cd808c15ebbe85fc73181a86

and get a bash shell where they can inspect the environment to debug
and develop OSBuild stages.
This commit is contained in:
Dusty Mabe 2024-01-08 23:19:44 -05:00 committed by Brian C. Lane
parent 962b7f4d4b
commit 83a14886d3
4 changed files with 26 additions and 8 deletions

View file

@ -95,6 +95,9 @@ def parse_arguments(sys_argv):
parser.add_argument("--version", action="version",
help="return the version of osbuild",
version="%(prog)s " + osbuild.__version__)
# nargs='?' const='*' means `--break` is equivalent to `--break=*`
parser.add_argument("--break", dest='debug_break', type=str, nargs='?', const='*',
help="open debug shell when executing stage. Accepts stage name or id or * (for all)")
return parser.parse_args(sys_argv[1:])
@ -163,6 +166,7 @@ def osbuild_cli():
object_store.maximum_size = args.cache_max_size
stage_timeout = args.stage_timeout
debug_break = args.debug_break
pipelines = manifest.depsolve(object_store, exports)
@ -173,6 +177,7 @@ def osbuild_cli():
pipelines,
monitor,
args.libdir,
debug_break,
stage_timeout=stage_timeout
)