9001-udev.patch 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. $ curl https://github.com/archlinux/mkinitcpio/commit/9ee1333a5f3302d7ddb004cf0909c94b4cff60ba.diff
  2. diff --git a/functions b/functions
  3. index 9539a60..f95fb92 100644
  4. --- a/functions
  5. +++ b/functions
  6. @@ -625,6 +625,46 @@ add_binary() {
  7. return 0
  8. }
  9. +add_udev_rule() {
  10. + # Add an udev rules file to the initcpio image. Dependencies on binaries
  11. + # will be discovered and added.
  12. + # $1: path to rules file (or name of rules file)
  13. +
  14. + local rules="$1" rule= key= value= binary=
  15. +
  16. + if [[ ${rules:0:1} != '/' ]]; then
  17. + rules=$(PATH=/usr/lib/udev/rules.d:/lib/udev/rules.d type -P "$rules")
  18. + fi
  19. + if [[ -z $rules ]]; then
  20. + # complain about not found rules
  21. + return 1
  22. + fi
  23. +
  24. + add_file "$rules" /usr/lib/udev/rules.d/"${rules##*/}"
  25. +
  26. + while IFS=, read -ra rule; do
  27. + # skip empty lines, comments
  28. + [[ -z $rule || $rule = @(+([[:space:]])|#*) ]] && continue
  29. +
  30. + for pair in "${rule[@]}"; do
  31. + IFS=' =' read -r key value <<< "$pair"
  32. + case $key in
  33. + RUN@({program}|+)|IMPORT{program}|ENV{REMOVE_CMD})
  34. + # strip quotes
  35. + binary=${value//[\"\']/}
  36. + # just take the first word as the binary name
  37. + binary=${binary%% *}
  38. + [[ ${binary:0:1} == '$' ]] && continue
  39. + if [[ ${binary:0:1} != '/' ]]; then
  40. + binary=$(PATH=/usr/lib/udev:/lib/udev type -P "$binary")
  41. + fi
  42. + add_binary "$binary"
  43. + ;;
  44. + esac
  45. + done
  46. + done <"$rules"
  47. +}
  48. +
  49. parse_config() {
  50. # parse key global variables set by the config file.