94ce4e
#! /bin/bash
94ce4e
#
94ce4e
# Called as filter-modules.sh list-of-modules Arch
94ce4e
aa7351
# This script filters the modules into the kernel-core and kernel-modules
94ce4e
# subpackages.  We list out subsystems/subdirs to prune from the installed
94ce4e
# module directory.  What is left is put into the kernel-core package.  What is
aa7351
# pruned is contained in the kernel-modules package.
94ce4e
#
94ce4e
# This file contains the default subsys/subdirs to prune from all architectures.
94ce4e
# If an architecture needs to differ, we source a per-arch filter-<arch>.sh file
94ce4e
# that contains the set of override lists to be used instead.  If a module or
aa7351
# subsys should be in kernel-modules on all arches, please change the defaults
94ce4e
# listed here.
94ce4e
94ce4e
# Set the default dirs/modules to filter out
e9bc1e
driverdirs="atm auxdisplay bcma bluetooth firewire fmc fpga infiniband isdn leds media memstick mfd mmc mtd nfc ntb pcmcia platform power ssb soundwire staging tty uio uwb w1"
aa2efe
aa2efe
chardrvs="mwave pcmcia"
94ce4e
c3cd2b
netdrvs="appletalk can dsa hamradio ieee802154 irda ppp slip usb wireless"
94ce4e
967884
ethdrvs="3com adaptec alteon amd aquantia atheros broadcom cadence calxeda chelsio cisco dec dlink emulex icplus marvell mellanox neterion nvidia oki-semi packetengines qlogic rdc renesas sfc silan sis smsc stmicro sun tehuti ti wiznet xircom"
94ce4e
e3f2f9
inputdrvs="gameport tablet touchscreen"
e3f2f9
e9bc1e
scsidrvs="aacraid advansys aic7xxx aic94xx be2iscsi bfa bnx2i bnx2fc csiostor cxgbi esas2r fcoe fnic isci libsas lpfc megaraid mpt2sas mpt3sas mvsas pm8001 qla2xxx qla4xxx sym53c8xx_2 ufs qedf wd719x"
94ce4e
d1dc8a
usbdrvs="atm image misc serial wusbcore"
94ce4e
b9a77b
fsdrvs="affs befs coda cramfs dlm ecryptfs hfs hfsplus jfs jffs2 minix ncpfs nilfs2 ocfs2 reiserfs romfs squashfs sysv ubifs ufs"
94ce4e
6cb6bc
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"
94ce4e
e9bc1e
drmdrvs="amd ast bridge gma500 i2c i915 mgag200 nouveau panel radeon"
94ce4e
e9bc1e
iiodrvs="accel adc afe common dac gyro health humidity light magnetometer multiplexer orientation potentiometer potentiostat pressure temperature"
e9bc1e
6619fa
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 target_core_user sbp_target cxgbit iw_cxgb3 iw_cxgb4 cxgb3i cxgb3i cxgb3i_ddp cxgb4i chcr chtls parport_serial regmap-sdw hid-asus"
94ce4e
94ce4e
# Grab the arch-specific filter list overrides
94ce4e
source ./filter-$2.sh
94ce4e
94ce4e
filter_dir() {
94ce4e
	filelist=$1
94ce4e
	dir=$2
94ce4e
94ce4e
	grep -v -e "${dir}/" ${filelist} > ${filelist}.tmp
94ce4e
94ce4e
	if [ $? -ne 0 ]
94ce4e
	then
94ce4e
		echo "Couldn't remove ${dir}.  Skipping."
94ce4e
	else
94ce4e
		grep -e "${dir}/" ${filelist} >> k-d.list
94ce4e
		mv ${filelist}.tmp $filelist
94ce4e
	fi
94ce4e
	
94ce4e
	return 0
94ce4e
}
94ce4e
94ce4e
filter_ko() {
94ce4e
	filelist=$1
94ce4e
	mod=$2
94ce4e
94ce4e
	grep -v -e "${mod}.ko" ${filelist} > ${filelist}.tmp
94ce4e
94ce4e
	if [ $? -ne 0 ]
94ce4e
	then
94ce4e
		echo "Couldn't remove ${mod}.ko  Skipping."
94ce4e
	else
94ce4e
		grep -e "${mod}.ko" ${filelist} >> k-d.list
94ce4e
		mv ${filelist}.tmp $filelist
94ce4e
	fi
94ce4e
	
94ce4e
	return 0
94ce4e
}
94ce4e
94ce4e
# Filter the drivers/ subsystems
94ce4e
for subsys in ${driverdirs}
94ce4e
do
94ce4e
	filter_dir $1 drivers/${subsys}
94ce4e
done
94ce4e
94ce4e
# Filter the networking drivers
94ce4e
for netdrv in ${netdrvs}
94ce4e
do
94ce4e
	filter_dir $1 drivers/net/${netdrv}
94ce4e
done
94ce4e
aa2efe
# Filter the char drivers
aa2efe
for char in ${chardrvs}
aa2efe
do
aa2efe
	filter_dir $1 drivers/char/${input}
aa2efe
done
aa2efe
94ce4e
# Filter the ethernet drivers
94ce4e
for eth in ${ethdrvs}
94ce4e
do
94ce4e
	filter_dir $1 drivers/net/ethernet/${eth}
94ce4e
done
94ce4e
94ce4e
# SCSI
94ce4e
for scsi in ${scsidrvs}
94ce4e
do
94ce4e
	filter_dir $1 drivers/scsi/${scsi}
94ce4e
done
94ce4e
e3f2f9
# Input
e3f2f9
for input in ${inputdrvs}
e3f2f9
do
e3f2f9
	filter_dir $1 drivers/input/${input}
e3f2f9
done
e3f2f9
94ce4e
# USB
94ce4e
for usb in ${usbdrvs}
94ce4e
do
94ce4e
	filter_dir $1 drivers/usb/${usb}
94ce4e
done
94ce4e
94ce4e
# Filesystems
94ce4e
for fs in ${fsdrvs}
94ce4e
do
94ce4e
	filter_dir $1 fs/${fs}
94ce4e
done
94ce4e
94ce4e
# Network protocols
94ce4e
for prot in ${netprots}
94ce4e
do
94ce4e
	filter_dir $1 kernel/net/${prot}
94ce4e
done
94ce4e
94ce4e
# DRM
94ce4e
for drm in ${drmdrvs}
94ce4e
do
94ce4e
	filter_dir $1 drivers/gpu/drm/${drm}
94ce4e
done
94ce4e
94ce4e
# Just kill sound.
94ce4e
filter_dir $1 kernel/sound
94ce4e
94ce4e
# Now go through and filter any single .ko files that might have deps on the
94ce4e
# things we filtered above
94ce4e
for mod in ${singlemods}
94ce4e
do
94ce4e
        filter_ko $1 ${mod}
94ce4e
done
94ce4e
94ce4e
# Go through our generated drivers list and remove the .ko files.  We'll
94ce4e
# restore them later.
94ce4e
for mod in `cat k-d.list`
94ce4e
do
94ce4e
	rm -rf $mod
94ce4e
done