OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.1 KiB

  1. #!/bin/sh
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: package/.../mkinitramfs/files/50-kernel.sh
  6. # Copyright (C) 2007 - 2008 The OpenSDE Project
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; version 2 of the License. A copy of the
  13. # GNU General Public License can be found in the file COPYING.
  14. # --- SDE-COPYRIGHT-NOTE-END ---
  15. MODINFO=${MODINFO:-/sbin/modinfo}
  16. DEPMOD=${DEPMOD:-/sbin/depmod}
  17. set -e
  18. if [ -n "$moddir" ]; then
  19. # sanity checks
  20. for tool in $MODINFO $DEPMOD; do
  21. if [ ! -x "$tool" ]; then
  22. echo "ERROR: $tool is no available"
  23. exit 1
  24. fi
  25. done
  26. if [ "$running" ]; then
  27. echo "TODO: building on a running system, we can take the list of active modules."
  28. fi
  29. module_install() {
  30. local module= source= target=
  31. if [ -r "$1" ]; then
  32. # absolute path
  33. source="$1"
  34. module=${source##*/}; module=${module%.ko}
  35. else
  36. module="$1"
  37. source="$( find "$moddir/kernel" -name "$module.ko" | head -n 1 )"
  38. fi
  39. if [ -r "$source" ]; then
  40. target="lib/modules/$kernelver/${source#$moddir/}"
  41. if [ ! -f $target ]; then
  42. echo -n " $module"
  43. mkdir -p "${target%/*}"
  44. cp "$source" "$target"
  45. for dep in $( $MODINFO "$source" | grep "^depends:" | tr -s ' ' | cut -d' ' -f2 | tr ',' ' ' ); do
  46. module_install "$dep"
  47. done
  48. fi
  49. else
  50. modules_missing="$modules_missing $module"
  51. echo -n " [$module]"
  52. fi
  53. }
  54. echo -n "Installing modules:"
  55. modules_missing=
  56. if [ -n "$MKINITRD_MODULES" ]; then
  57. for module in $MKINITRD_MODULES; do
  58. module_install "$module"
  59. done
  60. fi
  61. # greedy^3
  62. find $moddir/kernel/drivers/{block,ata,ide,ieee1394,md,scsi,cdrom,usb,message} \
  63. $moddir/kernel/{lib,fs} \
  64. -type f | while read file; do
  65. module_install "$file"
  66. done
  67. echo
  68. $DEPMOD -ae -b "$tmpdir" -F "$sysmap" "$kernelver"
  69. [ -z "$modules_missing" ] || echo "Failed to find:$modules_missing"
  70. fi