diff options
author | Dan McGee <dan@archlinux.org> | 2011-01-31 02:15:51 +0100 |
---|---|---|
committer | Thomas Bächler <thomas@archlinux.org> | 2011-01-31 21:44:27 +0100 |
commit | 65a523302462e738bd3c813bdae4d0a8a62990ac (patch) | |
tree | ea5ce01dec8ee033ddb4203cb6d924c98a12af8b /functions | |
parent | b55e66b8c135729d3aa12390848e64532c423b83 (diff) | |
download | mkinitcpio-65a523302462e738bd3c813bdae4d0a8a62990ac.tar.gz mkinitcpio-65a523302462e738bd3c813bdae4d0a8a62990ac.tar.xz |
Add new helper functions
Replace common behavior we had in some other places with
get_module_name, and add some basename/dirname replacements done in bash
to avoid the forks for the number of times we call these functions.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'functions')
-rw-r--r-- | functions | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -2,6 +2,28 @@ msg () { [ "${QUIET}" = "n" ] && echo $@; } err () { echo "ERROR: $@" >&2; } die () { echo "FATAL: $@" >&2; cleanup; exit 1; } +get_dirname () +{ + # strip any trailing slash first... + local dir="${1%/}" + # then get the directory portion + echo "${dir%/*}" +} + +get_basename () +{ + echo "${1##*/}" +} + +get_module_name () +{ + #cleanup - remove .ko, replace - with _ + local modname="${1%.gz}" + modname=$(get_basename "${modname%.ko}") + modname="${modname//-/_}" + echo "$modname" +} + auto_modules () { aliases="$(find /sys/devices/ -name modalias -exec cat {} +)" |