summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile15
-rwxr-xr-xuninstall-modules-sh36
2 files changed, 41 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index be7ad6d..1768927 100644
--- a/Makefile
+++ b/Makefile
@@ -530,30 +530,25 @@ install-udev: devices
uninstall-hotplug:
$(MAKE) -C firmware hotplug-uninstall DESTDIR=$(DESTDIR)
+BASENAMES=$(sort $(shell for x in $(ALL_MODULES); do basename $x; done))
uninstall-modules:
ifeq ($(BUILDVER),linux24)
else
- for x in $(ALL_MODULES); do \
+ @./uninstall-modules-sh $(DESTDIR)/lib/modules/$(KVERS) $(BASENAMES)
+ @for x in $(ALL_MODULES); do \
rm -f $(DESTDIR)/lib/modules/$(KVERS)/extra/$$x ; \
rm -f $(DESTDIR)/lib/modules/$(KVERS)/misc/$$x ; \
rm -f $(DESTDIR)/lib/modules/$(KVERS)/zaptel/$$x ; \
done;
endif
+BASENAMES=$(sort $(shell for mod in $(ALL_MODULES); do basename $$mod; done))
+
install-modules: $(INSTALL_MODULES) uninstall-modules
ifeq ($(BUILDVER),linux24)
$(INSTALL) -d $(DESTDIR)$(MOD_DIR)
$(INSTALL) -m 644 $(INSTALL_MODULES) $(DESTDIR)$(MOD_DIR)
else
- @# Delete any existing drivers before installing the new ones. This
- @# prevents problems when upgrading from a previous version of zaptel
- @# where the drivers may have been in a different location. In this
- @# case, when depmod is run, the old drivers may be found and used
- @# before the new drivers.
- @for mod in $(INSTALL_MODULES); do \
- rm -f `cat $(DESTDIR)/lib/modules/$(KVERS)/modules.dep | \
- cut -d : -f 1 | grep -m 1 $$mod`; \
- done;
$(KMAKE_INST)
ifneq (,$(wildcard datamods/syncppp.ko))
$(MAKE) -C datamods install
diff --git a/uninstall-modules-sh b/uninstall-modules-sh
new file mode 100755
index 0000000..d70255c
--- /dev/null
+++ b/uninstall-modules-sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+# uninstall-modules-sh
+#
+# Remove all the modules passed in on the command line from the modules
+# directory. This script is called by the makefile.
+#
+# USAGE: uninstall-modules-sh <modules dir> modules to delete ...
+
+KERNEL_MODULES_DIR=$1
+shift
+MODULES=$@
+
+function usage {
+ echo "$0: Used to delete kernel modules from the modules directory."
+}
+
+if [ -z "$KERNEL_MODULES_DIR" ]; then
+ echo "Missing kernel module directory."
+ usage
+ exit 1;
+fi
+
+if [ -z "$MODULES" ]; then
+ echo "Missing one or more modules to delete."
+ usage
+ exit 1;
+fi
+for mod in $MODULES; do
+ for file in `cat $KERNEL_MODULES_DIR/modules.dep | cut -d : -f 1 | grep $mod`; do
+ if [ -e "$file" ]; then
+ echo "Deleting $file."
+ rm -f $file
+ fi
+ done
+done
+exit 0