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