[svn-commits] kpfleming: linux/trunk r4570 - in /linux/trunk: ./ build_tools/
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Tue Jul 8 13:32:02 CDT 2008
Author: kpfleming
Date: Tue Jul 8 13:32:02 2008
New Revision: 4570
URL: http://svn.digium.com/view/dahdi?view=rev&rev=4570
Log:
make the uninstall-modules target actually work (except when DESTDIR is supplied), and automatically uninstall any Zaptel modules present for the KVERS kernel during installation of DAHDI
Modified:
linux/trunk/Makefile
linux/trunk/build_tools/uninstall-modules
Modified: linux/trunk/Makefile
URL: http://svn.digium.com/view/dahdi/linux/trunk/Makefile?view=diff&rev=4570&r1=4569&r2=4570
==============================================================================
--- linux/trunk/Makefile (original)
+++ linux/trunk/Makefile Tue Jul 8 13:32:02 2008
@@ -152,9 +152,23 @@
$(MAKE) -C drivers/dahdi/firmware hotplug-uninstall DESTDIR=$(DESTDIR)
uninstall-modules:
- @build_tools/uninstall-modules $(DESTDIR)/lib/modules/$(KVERS)
-
-install-modules: modules #uninstall-modules
+ifdef DESTDIR
+ echo "Uninstalling modules is not supported with a custom DESTDIR."
+ exit 1
+else
+ echo -n "Removing DAHDI modules for kernel $(KVERS), please wait..."
+ @build_tools/uninstall-modules dahdi $(KVERS)
+ echo "done."
+endif
+
+install-modules: modules
+ifndef DESTDIR
+ @if modinfo zaptel 2>&1 > /dev/null; then \
+ echo -n "Removing Zaptel modules for kernel $(KVERS), please wait..."; \
+ build_tools/uninstall-modules zaptel $(KVERS); \
+ echo "done."; \
+ fi
+endif
$(KMAKE) INSTALL_MOD_PATH=$(DESTDIR) INSTALL_MOD_DIR=dahdi modules_install
[ `id -u` = 0 ] && /sbin/depmod -a $(KVERS) || :
Modified: linux/trunk/build_tools/uninstall-modules
URL: http://svn.digium.com/view/dahdi/linux/trunk/build_tools/uninstall-modules?view=diff&rev=4570&r1=4569&r2=4570
==============================================================================
--- linux/trunk/build_tools/uninstall-modules (original)
+++ linux/trunk/build_tools/uninstall-modules Tue Jul 8 13:32:02 2008
@@ -1,41 +1,61 @@
#!/bin/sh
-# uninstall-modules
+
+# This script takes two arguments: a top-level module name, and a kernel version string
#
-# Remove all the modules passed in on the command line from the modules
-# directory. This script is called by the makefile.
+# It will search the entire /lib/modules directory tree for the given kernel version,
+# and find all modules that are dependent (even indirectly) on the specified module.
+# After producing that list, it will remove all those modules.
-KERNEL_MODULES_DIR=$1
-shift
-MODULES="$*"
+base="${1}"
+deptree="${base}"
+rmlist=""
+founddep=1
-usage() {
- echo "$0: Used to delete kernel modules from the modules directory."
- echo ""
- echo "Usage:"
- echo " $0 MODULES_BASE_DIR mod1 [mod2 [...]]"
- echo ""
- echo " MODULES_BASE_DIR - typically /lib/modules/KVERS"
- echo " modN - (optionally partial) module name to remove."
+checkmod() {
+ SAVEIFS="${IFS}"
+ IFS=","
+ modname=`basename ${1}`
+ modname=${modname%.ko}
+ if test "${modname}" = "${base}"; then
+ rmlist="${rmlist} ${1}"
+ IFS="${SAVEIFS}"
+ return
+ fi
+ for dep in `modinfo -F depends ${1}`; do
+ for mod in ${deptree}; do
+ if test "${dep}" = "${mod}"; then
+ addit=1
+ for checkmod in ${deptree}; do
+ if test "${checkmod}" = "${modname}"; then
+ addit=0
+ break
+ fi
+ done
+ if test "${addit}" = "1"; then
+ deptree="${deptree},${modname%.ko}"
+ rmlist="${rmlist} ${1}"
+ founddep=1
+ fi
+ fi
+ done
+ done
+ IFS="${SAVEIFS}"
}
-if [ -z "$KERNEL_MODULES_DIR" ]; then
- echo "Missing kernel module directory."
- usage
- exit 1;
+
+while test "${founddep}" = "1"; do
+ founddep=0
+ find /lib/modules/${2} -name \*.ko -print > /tmp/modlist
+ exec 9<&0 < /tmp/modlist
+ while read mod; do
+ checkmod ${mod}
+ done
+ exec 0<&9 9<&-
+ rm /tmp/modlist
+done
+
+if test -n "${rmlist}"; then
+ for mod in ${rmlist}; do
+ rm -f ${mod}
+ done
fi
-
-if [ -z "$MODULES" ]; then
- echo "Missing one or more modules to delete."
- usage
- exit 1;
-fi
-for mod in $MODULES; do
- BASE=`basename $mod`
- for file in `cat $KERNEL_MODULES_DIR/modules.dep | cut -d : -f 1 | grep "$BASE$"`; do
- if [ -e "$file" ]; then
- #echo "Deleting $file."
- rm -f $file
- fi
- done
-done
-exit 0
More information about the svn-commits
mailing list