[arch-projects] [mkinitcpio] [RFC] add_module(): silently ignore built-ins
Dave Reisner
d at falconindy.com
Mon Sep 17 10:38:33 EDT 2012
On Mon, Sep 17, 2012 at 10:10:36AM -0400, Dave Reisner wrote:
> I like the idea, but the lookup is a bit heavy and there's no caching. I threw
> together the below unpolished diff, which is a bit snappier and gets the job
> done.
Replying to myself ftw... I commited a pair of patches to my dev repo
which convert the whole ADDED_MODULES array to a hash and then just
"prime" this hash with the contents of the builtin file. It's quite a
nice improvement overall:
http://code.falconindy.com/cgit/mkinitcpio.git/commit/?id=1f1085e
http://code.falconindy.com/cgit/mkinitcpio.git/commit/?id=5626743
d
> diff --git a/functions b/functions
> index 8a270fd..4839f85 100644
> --- a/functions
> +++ b/functions
> @@ -312,6 +312,10 @@ add_module() {
>
> module=${1%.ko*}
>
> + if (( ${builtins[$module]} )); then
> + return 0
> + fi
> +
> # skip expensive stuff if this module has already been added
> in_array "${module//-/_}" "${ADDED_MODULES[@]}" && return
>
> diff --git a/mkinitcpio b/mkinitcpio
> index 5bed94e..61ab328 100755
> --- a/mkinitcpio
> +++ b/mkinitcpio
> @@ -343,6 +343,11 @@ declare -i builderrors=0
> set -o functrace
> trap '(( $? )) && [[ $FUNCNAME = add_* ]] && (( ++builderrors ))' RETURN
>
> +declare -A builtins
> +while IFS=/ read -ra path; do
> + builtins["${path[-1]%.ko}"]=1
> +done <"$MODULEDIR/modules.builtin"
> +
> for hook in "${hooks[@]}"; do
> run_build_hook "$hook" || (( ++builderrors ))
> done
>
>
> On Mon, Sep 17, 2012 at 07:38:23AM -0600, Matthew Monaco wrote:
> > From: Matthew Monaco <matthew.monaco at 0x01b.net>
> >
> > ---
> > functions | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/functions b/functions
> > index eee09ec..6368815 100644
> > --- a/functions
> > +++ b/functions
> > @@ -315,6 +315,10 @@ add_module() {
> > # skip expensive stuff if this module has already been added
> > in_array "${module//-/_}" "${ADDED_MODULES[@]}" && return
> >
> > + if grep -q "/$module.ko$" "$MODULEDIR/modules.builtin" 2>/dev/null; then
> > + return 0
> > + fi
> > +
> > while IFS=':= ' read -r -d '' field value; do
> > case "$field" in
> > filename)
> > --
> > 1.7.12
> >
More information about the arch-projects
mailing list