3c560c6
#! /bin/bash
3c560c6
#
3c560c6
# Called as filter-modules.sh list-of-modules Arch
3c560c6
3c560c6
# This script filters the modules into the kernel-core and kernel-modules
3c560c6
# subpackages.  We list out subsystems/subdirs to prune from the installed
3c560c6
# module directory.  What is left is put into the kernel-core package.  What is
3c560c6
# pruned is contained in the kernel-modules package.
3c560c6
#
3c560c6
# This file contains the default subsys/subdirs to prune from all architectures.
3c560c6
# If an architecture needs to differ, we source a per-arch filter-<arch>.sh file
3c560c6
# that contains the set of override lists to be used instead.  If a module or
3c560c6
# subsys should be in kernel-modules on all arches, please change the defaults
3c560c6
# listed here.
3c560c6
3c560c6
# Set the default dirs/modules to filter out
3c560c6
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"
3c560c6
3c560c6
chardrvs="mwave pcmcia"
3c560c6
3c560c6
netdrvs="appletalk can dsa hamradio ieee802154 irda ppp slip usb wireless"
3c560c6
3c560c6
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"
3c560c6
3c560c6
inputdrvs="gameport tablet touchscreen"
3c560c6
3c560c6
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"
3c560c6
3c560c6
usbdrvs="atm image misc serial wusbcore"
3c560c6
3c560c6
fsdrvs="affs befs coda cramfs dlm ecryptfs hfs hfsplus jfs jffs2 minix ncpfs nilfs2 ocfs2 reiserfs romfs squashfs sysv ubifs ufs"
3c560c6
3c560c6
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"
3c560c6
3c560c6
drmdrvs="amd ast bridge gma500 i2c i915 mgag200 nouveau panel radeon"
3c560c6
3c560c6
iiodrvs="accel adc afe common dac gyro health humidity light magnetometer multiplexer orientation potentiometer potentiostat pressure temperature"
3c560c6
3c560c6
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"
3c560c6
3c560c6
# Grab the arch-specific filter list overrides
3c560c6
source ./filter-$2.sh
3c560c6
3c560c6
filter_dir() {
3c560c6
	filelist=$1
3c560c6
	dir=$2
3c560c6
3c560c6
	grep -v -e "${dir}/" ${filelist} > ${filelist}.tmp
3c560c6
3c560c6
	if [ $? -ne 0 ]
3c560c6
	then
3c560c6
		echo "Couldn't remove ${dir}.  Skipping."
3c560c6
	else
3c560c6
		grep -e "${dir}/" ${filelist} >> k-d.list
3c560c6
		mv ${filelist}.tmp $filelist
3c560c6
	fi
3c560c6
	
3c560c6
	return 0
3c560c6
}
3c560c6
3c560c6
filter_ko() {
3c560c6
	filelist=$1
3c560c6
	mod=$2
3c560c6
3c560c6
	grep -v -e "${mod}.ko" ${filelist} > ${filelist}.tmp
3c560c6
3c560c6
	if [ $? -ne 0 ]
3c560c6
	then
3c560c6
		echo "Couldn't remove ${mod}.ko  Skipping."
3c560c6
	else
3c560c6
		grep -e "${mod}.ko" ${filelist} >> k-d.list
3c560c6
		mv ${filelist}.tmp $filelist
3c560c6
	fi
3c560c6
	
3c560c6
	return 0
3c560c6
}
3c560c6
3c560c6
# Filter the drivers/ subsystems
3c560c6
for subsys in ${driverdirs}
3c560c6
do
3c560c6
	filter_dir $1 drivers/${subsys}
3c560c6
done
3c560c6
3c560c6
# Filter the networking drivers
3c560c6
for netdrv in ${netdrvs}
3c560c6
do
3c560c6
	filter_dir $1 drivers/net/${netdrv}
3c560c6
done
3c560c6
3c560c6
# Filter the char drivers
3c560c6
for char in ${chardrvs}
3c560c6
do
3c560c6
	filter_dir $1 drivers/char/${input}
3c560c6
done
3c560c6
3c560c6
# Filter the ethernet drivers
3c560c6
for eth in ${ethdrvs}
3c560c6
do
3c560c6
	filter_dir $1 drivers/net/ethernet/${eth}
3c560c6
done
3c560c6
3c560c6
# SCSI
3c560c6
for scsi in ${scsidrvs}
3c560c6
do
3c560c6
	filter_dir $1 drivers/scsi/${scsi}
3c560c6
done
3c560c6
3c560c6
# Input
3c560c6
for input in ${inputdrvs}
3c560c6
do
3c560c6
	filter_dir $1 drivers/input/${input}
3c560c6
done
3c560c6
3c560c6
# USB
3c560c6
for usb in ${usbdrvs}
3c560c6
do
3c560c6
	filter_dir $1 drivers/usb/${usb}
3c560c6
done
3c560c6
3c560c6
# Filesystems
3c560c6
for fs in ${fsdrvs}
3c560c6
do
3c560c6
	filter_dir $1 fs/${fs}
3c560c6
done
3c560c6
3c560c6
# Network protocols
3c560c6
for prot in ${netprots}
3c560c6
do
3c560c6
	filter_dir $1 kernel/net/${prot}
3c560c6
done
3c560c6
3c560c6
# DRM
3c560c6
for drm in ${drmdrvs}
3c560c6
do
3c560c6
	filter_dir $1 drivers/gpu/drm/${drm}
3c560c6
done
3c560c6
3c560c6
# Just kill sound.
3c560c6
filter_dir $1 kernel/sound
3c560c6
3c560c6
# Now go through and filter any single .ko files that might have deps on the
3c560c6
# things we filtered above
3c560c6
for mod in ${singlemods}
3c560c6
do
3c560c6
        filter_ko $1 ${mod}
3c560c6
done
3c560c6
3c560c6
# Go through our generated drivers list and remove the .ko files.  We'll
3c560c6
# restore them later.
3c560c6
for mod in `cat k-d.list`
3c560c6
do
3c560c6
	rm -rf $mod
3c560c6
done