btw cosmetic changes to inst_rules --- dracut-functions | 29 +++++++++++++++++++++++------ 1 files changed, 23 insertions(+), 6 deletions(-) diff --git a/dracut-functions b/dracut-functions index 0caf0d6..6da36ad 100755 --- a/dracut-functions +++ b/dracut-functions @@ -319,11 +319,27 @@ inst_symlink() { inst "$realsrc" && ln -s "$realsrc" "$target" } -# find a udev rule in the usual places. +# find a udev rule in the usual places and try to be smart (just a bit). +# See example: +# find_rule default.rules +# find_rule udev-default.rules +# find_rule 50-udev-default.rules +# All of them will return: /lib/udev/rules.d/50-udev-default.rules find_rule() { + local rule + [[ -f $1 ]] && { echo "$1"; return 0; } for r in . /lib/udev/rules.d /etc/udev/rules.d $dracutbasedir/rules.d; do - [[ -f $r/$1 ]] && { echo "$r/$1"; return 0; } + if ls $r/*$1 &>/dev/null; then + if [[ -f $r/$1 ]]; then + echo "$r/$1" + return 0 + else + rule=$(ls "$r"/??"-$1" 2>/dev/null || \ + ls "$r"/??"-udev-$1" 2>/dev/null) + [[ -f $rule ]] && echo $rule && return 0 + fi + fi done return 1 } @@ -331,13 +347,14 @@ find_rule() { # udev rules always get installed in the same place, so # create a function to install them to make life simpler. inst_rules() { - local target=/etc/udev/rules.d + local target=/etc/udev/rules.d rule found + inst_dir "/lib/udev/rules.d" inst_dir "$target" for rule in "$@"; do - rule1=$(find_rule "$rule") && \ - inst_simple "$rule1" "$target/${rule1##*/}" \ - || dinfo "Skipping udev rule: $rule" + found=$(find_rule "$rule") && \ + inst_simple "$found" "$target/${found##*/}" \ + || dinfo "Skipping udev rule: $rule" done } -- 1.7.1
Attachment:
signature.asc
Description: PGP signature