Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions easybuild/tools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ def mk_full_default_path(name, prefix=DEFAULT_PREFIX):
'amdgcn_capabilities',
'backup_modules',
'banned_linked_shared_libs',
'breakpoints',
'checksum_priority',
'container_config',
'container_image_format',
Expand Down
22 changes: 22 additions & 0 deletions easybuild/tools/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,17 @@ def find_hook(label, hooks, pre_step_hook=False, post_step_hook=False):
return res


def _breakpoint():
"""Simple breakpoint hook that opens a bash shell."""
old_ps1 = os.environ.get('PS1', '')
old_promptcmd = os.environ.get('PROMPT_COMMAND', '')
os.environ['PROMPT_COMMAND'] = ''
os.environ['PS1'] = 'easybuild-breakpoint> '
os.system('bash --norc --noprofile')
os.environ['PS1'] = old_ps1
os.environ['PROMPT_COMMAND'] = old_promptcmd


def run_hook(label, hooks, pre_step_hook=False, post_step_hook=False, args=None, kwargs=None, msg=None):
"""
Run hook with specified label and return result of calling the hook or None.
Expand All @@ -231,6 +242,17 @@ def run_hook(label, hooks, pre_step_hook=False, post_step_hook=False, args=None,
:param args: arguments to pass to hook function
:param msg: custom message that is printed when hook is called
"""
breakpoints = build_option('breakpoints')
bk_hooks = {}
if breakpoints:
for bk in breakpoints:
if not bk.endswith(HOOK_SUFF):
bk += HOOK_SUFF
bk_hooks[bk] = lambda *a, **k: _breakpoint()
bp_hook = find_hook(label, bk_hooks, pre_step_hook=pre_step_hook, post_step_hook=post_step_hook)
if bp_hook:
bp_hook()

hook = find_hook(label, hooks, pre_step_hook=pre_step_hook, post_step_hook=post_step_hook)
res = None
if hook:
Expand Down
4 changes: 4 additions & 0 deletions easybuild/tools/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,10 @@ def config_options(self):
None, "store_true", False,),
'avail-repositories': ("Show all repository types (incl. non-usable)",
None, "store_true", False,),
'breakpoints': (
"Drop into an interactive shell on the specified steps (use same names as for hooks comma separated)",
'strlist', 'store', None
),
'buildpath': ("Temporary build path", None, 'store', mk_full_default_path('buildpath')),
'containerpath': ("Location where container recipe & image will be stored", None, 'store',
mk_full_default_path('containerpath')),
Expand Down