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