filter-modules.sh.fedora 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. #! /bin/bash
  2. #
  3. # Called as filter-modules.sh list-of-modules Arch
  4. # This script filters the modules into the kernel-core and kernel-modules
  5. # subpackages. We list out subsystems/subdirs to prune from the installed
  6. # module directory. What is left is put into the kernel-core package. What is
  7. # pruned is contained in the kernel-modules package.
  8. #
  9. # This file contains the default subsys/subdirs to prune from all architectures.
  10. # If an architecture needs to differ, we source a per-arch filter-<arch>.sh file
  11. # that contains the set of override lists to be used instead. If a module or
  12. # subsys should be in kernel-modules on all arches, please change the defaults
  13. # listed here.
  14. # Overrides is individual modules which need to remain in kernel-core due to deps.
  15. overrides="cec"
  16. # Set the default dirs/modules to filter out
  17. driverdirs="atm auxdisplay bcma bluetooth firewire fpga infiniband leds media memstick mfd mmc mtd nfc ntb pcmcia platform power ssb soundwire staging tty uio w1"
  18. chardrvs="mwave pcmcia"
  19. netdrvs="appletalk can dsa hamradio ieee802154 ppp slip usb wireless"
  20. ethdrvs="3com adaptec alteon amd aquantia atheros broadcom cadence calxeda chelsio cisco dec dlink emulex marvell mellanox neterion nvidia packetengines qlogic rdc sfc silan sis smsc stmicro sun tehuti ti wiznet xircom"
  21. cryptdrvs="bcm caam cavium chelsio hisilicon marvell qat"
  22. iiodrvs="accel light pressure proximity"
  23. iiocommondrvs="cros_ec_sensors"
  24. inputdrvs="gameport tablet touchscreen"
  25. hiddrvs="surface-hid"
  26. scsidrvs="aacraid aic7xxx be2iscsi bfa bnx2i bnx2fc csiostor cxgbi esas2r fcoe fnic isci libsas lpfc megaraid mpt3sas mvsas pm8001 qla2xxx qla4xxx sym53c8xx_2 ufs qedf"
  27. usbdrvs="atm image misc serial"
  28. fsdrvs="affs befs coda cramfs dlm ecryptfs hfs hfsplus jfs jffs2 minix nilfs2 ocfs2 reiserfs romfs sysv ubifs ufs"
  29. netprots="6lowpan appletalk atm ax25 batman-adv bluetooth can dsa ieee802154 l2tp mac80211 mac802154 mpls netrom nfc rds rfkill rose sctp smc wireless"
  30. drmdrvs="amd ast bridge gma500 i2c i915 mgag200 nouveau panel radeon"
  31. singlemods="ntb_netdev iscsi_ibft iscsi_boot_sysfs megaraid pmcraid qedi qla1280 9pnet_rdma rpcrdma nvmet-rdma nvme-rdma hid-picolcd hid-prodikeys hwpoison-inject target_core_user sbp_target cxgbit chcr parport_serial regmap-sdw regmap-sdw-mbq arizona-micsupp hid-asus iTCO_wdt rnbd-client rnbd-server mlx5_vdpa spi-altera-dfl nct6775 hid-playstation hid-nintendo asus_wmi_sensors asus_wmi_ec_sensors mlx5-vfio-pci video int3406_thermal apple_bl ptp_dfl_tod intel-m10-bmc-hwmon intel_rapl_tpmi pds_vdpa hp-wmi-sensors pds-vfio-pci"
  32. # Grab the arch-specific filter list overrides
  33. source ./filter-$2.sh
  34. filter_dir() {
  35. filelist=$1
  36. dir=$2
  37. grep -v -e "${dir}/" ${filelist} > ${filelist}.tmp
  38. if [ $? -ne 0 ]
  39. then
  40. echo "Couldn't remove ${dir}. Skipping."
  41. else
  42. grep -e "${dir}/" ${filelist} >> k-d.list
  43. mv ${filelist}.tmp $filelist
  44. fi
  45. return 0
  46. }
  47. filter_ko() {
  48. filelist=$1
  49. mod=$2
  50. grep -v -e "${mod}.ko" ${filelist} > ${filelist}.tmp
  51. if [ $? -ne 0 ]
  52. then
  53. echo "Couldn't remove ${mod}.ko Skipping."
  54. else
  55. grep -e "${mod}.ko" ${filelist} >> k-d.list
  56. mv ${filelist}.tmp $filelist
  57. fi
  58. return 0
  59. }
  60. # Filter the drivers/ subsystems
  61. for subsys in ${driverdirs}
  62. do
  63. filter_dir $1 drivers/${subsys}
  64. done
  65. # Filter the networking drivers
  66. for netdrv in ${netdrvs}
  67. do
  68. filter_dir $1 drivers/net/${netdrv}
  69. done
  70. # Filter the char drivers
  71. for char in ${chardrvs}
  72. do
  73. filter_dir $1 drivers/char/${char}
  74. done
  75. # Filter the ethernet drivers
  76. for eth in ${ethdrvs}
  77. do
  78. filter_dir $1 drivers/net/ethernet/${eth}
  79. done
  80. # Filter the crypto drivers
  81. for crypt in ${cryptdrvs}
  82. do
  83. filter_dir $1 drivers/crypto/${crypt}
  84. done
  85. # SCSI
  86. for scsi in ${scsidrvs}
  87. do
  88. filter_dir $1 drivers/scsi/${scsi}
  89. done
  90. # IIO
  91. for iio in ${iiodrvs}
  92. do
  93. filter_dir $1 drivers/iio/${iio}
  94. done
  95. # IIO Common
  96. for iio in ${iiocommondrvs}
  97. do
  98. filter_dir $1 drivers/iio/common/${iio}
  99. done
  100. # Input
  101. for input in ${inputdrvs}
  102. do
  103. filter_dir $1 drivers/input/${input}
  104. done
  105. # hid
  106. for hid in ${hiddrvs}
  107. do
  108. filter_dir $1 drivers/hid/${hid}
  109. done
  110. # USB
  111. for usb in ${usbdrvs}
  112. do
  113. filter_dir $1 drivers/usb/${usb}
  114. done
  115. # Filesystems
  116. for fs in ${fsdrvs}
  117. do
  118. filter_dir $1 fs/${fs}
  119. done
  120. # Network protocols
  121. for prot in ${netprots}
  122. do
  123. filter_dir $1 kernel/net/${prot}
  124. done
  125. # DRM
  126. for drm in ${drmdrvs}
  127. do
  128. filter_dir $1 drivers/gpu/drm/${drm}
  129. done
  130. # Just kill sound.
  131. filter_dir $1 kernel/sound
  132. filter_dir $1 kernel/drivers/soundwire
  133. # Now go through and filter any single .ko files that might have deps on the
  134. # things we filtered above
  135. for mod in ${singlemods}
  136. do
  137. filter_ko $1 ${mod}
  138. done
  139. # Now process the override list to bring those modules back into core
  140. for mod in ${overrides}
  141. do
  142. grep -v -e "/${mod}.ko" k-d.list > k-d.list.tmp
  143. if [ $? -ne 0 ]
  144. then
  145. echo "Couldn't save ${mod}.ko Skipping."
  146. else
  147. grep -e "/${mod}.ko" k-d.list >> $filelist
  148. mv k-d.list.tmp k-d.list
  149. fi
  150. done
  151. # Go through our generated drivers list and remove the .ko files. We'll
  152. # restore them later.
  153. for mod in `cat k-d.list`
  154. do
  155. rm -rf $mod
  156. done