filter-modules.sh.rhel 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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 isst_if_common isst_tpmi_core isst_tpmi intel_vsec intel_vsec_tpmi"
  16. # Set the default dirs/modules to filter out
  17. driverdirs="atm auxdisplay bcma bluetooth firewire fmc iio infiniband isdn leds media memstick mfd mmc mtd nfc ntb pcmcia platform power ssb staging tty uio uwb w1"
  18. chardrvs="mwave pcmcia"
  19. netdrvs="appletalk can dsa hamradio ieee802154 irda ppp slip usb wireless"
  20. ethdrvs="3com adaptec alteon amd aquantia atheros broadcom cadence calxeda chelsio cisco dec dlink emulex icplus marvell neterion nvidia oki-semi packetengines qlogic rdc renesas sfc silan sis smsc stmicro sun tehuti ti wiznet xircom"
  21. cryptdrvs="bcm caam cavium chelsio hisilicon marvell qat"
  22. inputdrvs="gameport tablet touchscreen"
  23. scsidrvs="aacraid aic7xxx aic94xx be2iscsi bfa bnx2i bnx2fc csiostor cxgbi esas2r fcoe fnic hisi_sas isci libsas lpfc megaraid mpt2sas mpt3sas mvsas pm8001 qla2xxx qla4xxx sym53c8xx_2 ufs qedf"
  24. usbdrvs="atm image misc serial wusbcore"
  25. fsdrvs="affs befs coda cramfs ecryptfs hfs hfsplus jfs minix ncpfs nilfs2 ocfs2 reiserfs romfs smb squashfs sysv ubifs ufs"
  26. netprots="6lowpan appletalk atm ax25 batman-adv bluetooth can dccp dsa ieee802154 irda l2tp mac80211 mac802154 mpls netrom nfc rds rfkill rose sctp smc wireless"
  27. drmdrvs="amd ast gma500 i2c i915 mgag200 nouveau radeon via "
  28. singlemods="ntb_netdev iscsi_ibft iscsi_boot_sysfs megaraid pmcraid qedi qla1280 9pnet_rdma rpcrdma nvmet-rdma nvme-rdma hid-picolcd hid-prodikeys hwa-hc hwpoison-inject hid-sensor-hub target_core_user sbp_target cxgbit iw_cxgb3 iw_cxgb4 cxgb3i cxgb3i cxgb3i_ddp cxgb4i chcr chtls parport_serial ism regmap-sdw regmap-sdw-mbq arizona-micsupp hid-asus nct6775 ntc_thermistor video apple_bl kasan_test intel-m10-bmc-hwmon"
  29. # Grab the arch-specific filter list overrides
  30. source ./filter-$2.sh
  31. filter_dir() {
  32. filelist=$1
  33. dir=$2
  34. grep -v -e "${dir}/" ${filelist} > ${filelist}.tmp
  35. if [ $? -ne 0 ]
  36. then
  37. echo "Couldn't remove ${dir}. Skipping."
  38. else
  39. grep -e "${dir}/" ${filelist} >> k-d.list
  40. mv ${filelist}.tmp $filelist
  41. fi
  42. return 0
  43. }
  44. filter_ko() {
  45. filelist=$1
  46. mod=$2
  47. grep -v -e "${mod}.ko" ${filelist} > ${filelist}.tmp
  48. if [ $? -ne 0 ]
  49. then
  50. echo "Couldn't remove ${mod}.ko Skipping."
  51. else
  52. grep -e "${mod}.ko" ${filelist} >> k-d.list
  53. mv ${filelist}.tmp $filelist
  54. fi
  55. return 0
  56. }
  57. # Filter the drivers/ subsystems
  58. for subsys in ${driverdirs}
  59. do
  60. filter_dir $1 drivers/${subsys}
  61. done
  62. # Filter the networking drivers
  63. for netdrv in ${netdrvs}
  64. do
  65. filter_dir $1 drivers/net/${netdrv}
  66. done
  67. # Filter the char drivers
  68. for char in ${chardrvs}
  69. do
  70. filter_dir $1 drivers/char/${char}
  71. done
  72. # Filter the ethernet drivers
  73. for eth in ${ethdrvs}
  74. do
  75. filter_dir $1 drivers/net/ethernet/${eth}
  76. done
  77. # Filter the crypto drivers
  78. for crypt in ${cryptdrvs}
  79. do
  80. filter_dir $1 drivers/crypto/${crypt}
  81. done
  82. # SCSI
  83. for scsi in ${scsidrvs}
  84. do
  85. filter_dir $1 drivers/scsi/${scsi}
  86. done
  87. # Input
  88. for input in ${inputdrvs}
  89. do
  90. filter_dir $1 drivers/input/${input}
  91. done
  92. # USB
  93. for usb in ${usbdrvs}
  94. do
  95. filter_dir $1 drivers/usb/${usb}
  96. done
  97. # Filesystems
  98. for fs in ${fsdrvs}
  99. do
  100. filter_dir $1 fs/${fs}
  101. done
  102. # Network protocols
  103. for prot in ${netprots}
  104. do
  105. filter_dir $1 kernel/net/${prot}
  106. done
  107. # DRM
  108. for drm in ${drmdrvs}
  109. do
  110. filter_dir $1 drivers/gpu/drm/${drm}
  111. done
  112. # Just kill sound.
  113. filter_dir $1 kernel/sound
  114. filter_dir $1 kernel/drivers/soundwire
  115. # Now go through and filter any single .ko files that might have deps on the
  116. # things we filtered above
  117. for mod in ${singlemods}
  118. do
  119. filter_ko $1 ${mod}
  120. done
  121. # Now process the override list to bring those modules back into core
  122. for mod in ${overrides}
  123. do
  124. grep -v -e "/${mod}.ko" k-d.list > k-d.list.tmp
  125. if [ $? -ne 0 ]
  126. then
  127. echo "Couldn't save ${mod}.ko Skipping."
  128. else
  129. grep -e "/${mod}.ko" k-d.list >> $filelist
  130. mv k-d.list.tmp k-d.list
  131. fi
  132. done
  133. # Go through our generated drivers list and remove the .ko files. We'll
  134. # restore them later.
  135. for mod in `cat k-d.list`
  136. do
  137. rm -rf $mod
  138. done