Differences between version 2 and predecessor to the previous major change of KnowledgeBase/FreeBSD/srcsysmod_kmod.sh.
Other diffs: Previous Revision, Previous Author
Newer page: | version 2 | Last edited on Monday, 9 August 2010 7:27:49 | by CyberLeo | Revert |
Older page: | version 1 | Last edited on Sunday, 31 January 2010 1:33:44 | by CyberLeo | Revert |
@@ -6,11 +6,15 @@
(
cd /usr/src/sys/modules
find . -type f -name 'Makefile' | sed -e 's#^\./##' | xargs dirname | sort | while read dir
do
+ # Slower but more precise
+ #kmod="$(make -C "./${dir}" -V KMOD)"
+ # Faster, but might be incorrect if the makefile does voodoo
makefile="${dir}/Makefile"
- kmod="$(cat "${makefile}" | egrep '^KMOD' |
sed -e "s/^KMOD[ ${tab}]*=[ ${tab}]*//" )"
+ kmod="$(sed -e "/^KMOD/"\!"d;
s/^KMOD[ ${tab}]*=[ ${tab}]*//" "${makefile}
")"
+ # Format and display the results
[ "${kmod}" ] && echo "${dir}${tab}${kmod}"
done
)
}
</code>
version 2
I suggest redirecting the results into a cachefile, because the extraction is pretty slow.
srcsysmod_kmod() { tab="$(printf "\t")" ( cd /usr/src/sys/modules find . -type f -name 'Makefile' | sed -e 's#^\./##' | xargs dirname | sort | while read dir do # Slower but more precise #kmod="$(make -C "./${dir}" -V KMOD)" # Faster, but might be incorrect if the makefile does voodoo makefile="${dir}/Makefile" kmod="$(sed -e "/^KMOD/"\!"d; s/^KMOD[ ${tab}]*=[ ${tab}]*//" "${makefile}")" # Format and display the results [ "${kmod}" ] && echo "${dir}${tab}${kmod}" done ) }