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
94ce4e
driverdirs="atm auxdisplay bcma bluetooth fmc iio infiniband isdn leds media memstick message mfd mmc mtd nfc ntb pcmcia platform power ssb staging uio uwb"
94ce4e
94ce4e
netdrvs="appletalk dsa hamradio ieee802154 irda ppp slip usb wireless"
94ce4e
94ce4e
ethdrvs="3com adaptec alteon amd 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
94ce4e
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"
94ce4e
94ce4e
ttydrvs="ipwireless"
94ce4e
94ce4e
usbdrvs="atm wusbcore"
94ce4e
ccd294
fsdrvs="affs befs coda cramfs dlm ecryptfs hfs hfsplus jfs minix ncpfs nilfs2 ocfs2 reiserfs romfs squashfs sysv ubifs udf ufs"
94ce4e
94ce4e
netprots="appletalk atm ax25 batman-adv bluetooth dccp dsa ieee802154 irda l2tp mac80211 mac802154 netrom nfc rds rfkill rose sctp wireless"
94ce4e
94ce4e
drmdrvs="ast gma500 mgag200 via nouveau"
94ce4e
94ce4e
singlemods="ntb_netdev iscsi_ibft iscsi_boot_sysfs iscsi_tcp megaraid pmcraid qla1280 9pnet_rdma svcrdma xprtrdma hid-picolcd hid-prodikeys hwa-hc hwpoison-inject hid-sensor-hub"
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
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
94ce4e
# TTY
94ce4e
for tty in ${ttydrvs}
94ce4e
do
94ce4e
	filter_dir $1 drivers/tty/${tty}
94ce4e
done
94ce4e
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