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