[arch-dev-public] [PATCH] Implement a hook-system that allows to add custom code to the initscripts at certain places
A function add_hook can be called from functions.d to register a hook function. The existing hooks are based on suggestions from Michael Towers (larch) and on the implementation of initscripts-extras-fbsplash which currently uses the strings passed to stat_busy and stat_done for this. More hooks can be added if requested. The implementation uses associative arrays and will thus only work with bash 4 or later. The changes have been commited to initscripts.git, but have not yet been extensively tested, only basic functionality tests have been performed: http://projects.archlinux.org/?p=initscripts.git;a=commitdiff;h=cfabb85924f3... This should make life easier for larch (not exactly sure what they need it for) and will make initscripts-extras-fbsplash much cleaner to implement. Don't hesitate to request more hooks here. A description of the existing hooks is in rc.d/functions.
Thomas Bächler schrieb:
A function add_hook can be called from functions.d to register a hook function. The existing hooks are based on suggestions from Michael Towers (larch) and on the implementation of initscripts-extras-fbsplash which currently uses the strings passed to stat_busy and stat_done for this. More hooks can be added if requested.
Forgot to mention this in the commit and the first mail: the hook function names should be prefixed by something to make them unique, for example: add_hook premount larch_premount If larch would decide to add a "premount" hook.
On Tue, Aug 25, 2009 at 6:03 AM, Thomas Bächler<thomas@archlinux.org> wrote:
A function add_hook can be called from functions.d to register a hook function. The existing hooks are based on suggestions from Michael Towers (larch) and on the implementation of initscripts-extras-fbsplash which currently uses the strings passed to stat_busy and stat_done for this. More hooks can be added if requested.
The implementation uses associative arrays and will thus only work with bash 4 or later.
The changes have been commited to initscripts.git, but have not yet been extensively tested, only basic functionality tests have been performed: http://projects.archlinux.org/?p=initscripts.git;a=commitdiff;h=cfabb85924f3...
This should make life easier for larch (not exactly sure what they need it for) and will make initscripts-extras-fbsplash much cleaner to implement. Don't hesitate to request more hooks here.
A description of the existing hooks is in rc.d/functions.
I read through this, and was a little bit hesitant on this functionality. But then I gave in. Something about it feels weird to me, but if we just get it in there, it can be improved incrementally. Would it be useful to look into the stages/names that debian uses for their hooks system? Check their initramfs tools for their naming (there's a lot).
Aaron Griffin schrieb:
I read through this, and was a little bit hesitant on this functionality.
But then I gave in. Something about it feels weird to me, but if we just get it in there, it can be improved incrementally.
What exactly feels weird? It's the best solution I could come up with that a) doesn't add any new stuff (like new directories, files, concepts, we just use functions.d) b) works when multiple packages want to plug into the same hook The original suggestion from Michael is here: --- a/functions +++ b/functions @@ -229,6 +229,15 @@ ck_status() { fi } +# 'Hooks' are optional code snippets supplied in files in +# directory /etc/rc.d/hooks.d. The single argument +# is the hook's filename. If a hook doesn't exist +# nothing happens ... +hook() { + if [ -f /etc/rc.d/hooks.d/$1 ]; then + . /etc/rc.d/hooks.d/$1 + fi +} #Source additional functions at the end to allow overrides for f in /etc/rc.d/functions.d/*; do I don't like that one at all, as it fulfills none of the above requirements. Then I added one that just defines a bunch of hook_whatever() functions, but then one package could override another package's hook.
Would it be useful to look into the stages/names that debian uses for their hooks system? Check their initramfs tools for their naming (there's a lot).
Hmm, are you talking about naming of the hooks? I would accept any change proposal on those.
On Tue, Aug 25, 2009 at 10:38 AM, Thomas Bächler<thomas@archlinux.org> wrote:
Aaron Griffin schrieb:
I read through this, and was a little bit hesitant on this functionality.
But then I gave in. Something about it feels weird to me, but if we just get it in there, it can be improved incrementally.
What exactly feels weird? It's the best solution I could come up with that a) doesn't add any new stuff (like new directories, files, concepts, we just use functions.d) b) works when multiple packages want to plug into the same hook
Oh no, I agree. It's a good implementation of the concept. We've been slinging this one around for some time. Still, my Spidey Sense is tingling a bit. I *think* it might be due to the free-form names, but I'm not sure. Like I said, if I figure it out later, we can always tweak things
Aaron Griffin schrieb:
Oh no, I agree. It's a good implementation of the concept. We've been slinging this one around for some time.
Still, my Spidey Sense is tingling a bit. I *think* it might be due to the free-form names, but I'm not sure. Like I said, if I figure it out later, we can always tweak things
Once we push this to the repositories, I would be very uncomfortable changing the names, so if they cause your tingling, change them fast :) Once larch and initscripts-extras-fbsplash depend on them, I don't want to break them all the time.
On Tue, Aug 25, 2009 at 14:03, Thomas Bächler<thomas@archlinux.org> wrote:
A function add_hook can be called from functions.d to register a hook function. The existing hooks are based on suggestions from Michael Towers (larch) and on the implementation of initscripts-extras-fbsplash which currently uses the strings passed to stat_busy and stat_done for this. More hooks can be added if requested.
The implementation uses associative arrays and will thus only work with bash 4 or later.
The changes have been commited to initscripts.git, but have not yet been extensively tested, only basic functionality tests have been performed: http://projects.archlinux.org/?p=initscripts.git;a=commitdiff;h=cfabb85924f3...
This should make life easier for larch (not exactly sure what they need it for) and will make initscripts-extras-fbsplash much cleaner to implement. Don't hesitate to request more hooks here.
A description of the existing hooks is in rc.d/functions.
I don't know much about how larch is going to use this, but it is certainly the way to go for splash stuff. Long time ago when I did some work on splash-related stuff I had a splash branch that added a couple of new stat_* calls in some extra places (similar to where Thomas' run_hooks are). These stat_* calls were supposed to be dummy functions in rc.d/functions and redefined in functions.d/* which was kind of ugly. Thomas' proposal looks like a more correct way IMO. -- Roman Kyrylych (Роман Кирилич)
participants (3)
-
Aaron Griffin
-
Roman Kyrylych
-
Thomas Bächler