Page MenuHomeFreeBSD

debug.sh take advantage of hooks.sh
ClosedPublic

Authored by sjg on Sep 5 2024, 10:29 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Dec 3, 11:56 AM
Unknown Object (File)
Tue, Dec 3, 11:55 AM
Unknown Object (File)
Sun, Nov 24, 8:00 AM
Unknown Object (File)
Fri, Nov 22, 5:23 AM
Unknown Object (File)
Thu, Nov 21, 6:44 AM
Unknown Object (File)
Nov 11 2024, 9:25 AM
Unknown Object (File)
Nov 11 2024, 8:15 AM
Unknown Object (File)
Nov 7 2024, 7:08 PM
Subscribers
None

Details

Summary

Allow Debug{On,Off} to run associated hooks.
This makes it feasible to collect extra debug info at runtime
without needing to modify any potentially verified and hence immutable
scripts.

Like debug.sh, hooks.sh is extremely handy and used extensively
in many parts of Junos and its build environment.
It is provided here in the hope that others may benefit.

We do not dot hooks.sh by default to reduce overhead, but it can
but done from rc.conf et al using

$_HOOKS_SH . /libexec/hooks.sh

to avoid including more than once.

Sponsored by: Juniper Networks, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sjg requested review of this revision.Sep 5 2024, 10:29 PM
sjg created this revision.
libexec/rc/debug.sh
138

Don't you need a dummy "hooks_run" somewhere in the case where dot hooks.sh was not done?

213

Since you're using $local, should this script not sanity check $local somewhere? Something similar to the following perhaps?

case "$local" in
local|:);;
*) local= ;;
esac

libexec/rc/hooks.sh
57

This block doesn't quite look like BSD-2-Clause license.

libexec/rc/debug.sh
138

That what checking for $_HOOKS_SH does, I was trying to keep the overhead down, as you know this stuff gets called a *lot*

213

Yes that's probably a good idea

libexec/rc/hooks.sh
57

Its not, but it is IMO morally equivalent ;-)

Test for $local rather than $isPOSIX_SHELL

sjg marked 2 inline comments as done.Sep 6 2024, 4:59 PM

_debugShell ensure _TTY is set

This revision is now accepted and ready to land.Sep 10 2024, 5:18 PM
This revision was automatically updated to reflect the committed changes.