Makefile: improve uninstall error handling

Introduce helper functions to handle uninstall errors gracefully.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga
2021-03-19 15:25:24 +01:00
parent e58dae02ac
commit 880cfadde9
4 changed files with 50 additions and 24 deletions

View File

@@ -15,6 +15,13 @@ obj-y += cas_disk/
# line; invoke the kernel build system.
else
include ../tools/helpers.mk
define remove-module
@if (lsmod | grep -q ${1}); then rmmod ${1}; \
else echo "WARNING: Module ${1} is not loaded"; fi
endef
OCFDIR=$(PWD)/../ocf
PWD=$(shell pwd)
KERNEL_VERSION ?= "$(shell uname -r)"
@@ -57,11 +64,11 @@ install_files:
uninstall:
@echo "Uninstalling Open-CAS modules"
@$(RMMOD) $(CACHE_MODULE)
@$(RMMOD) $(DISK_MODULE)
$(call remove-module,$(CACHE_MODULE))
$(call remove-module,$(DISK_MODULE))
@rm $(DESTDIR)$(MODULES_DIR)/$(CACHE_MODULE).ko
@rm $(DESTDIR)$(MODULES_DIR)/$(DISK_MODULE).ko
$(call remove-file,$(DESTDIR)$(MODULES_DIR)/$(CACHE_MODULE).ko)
$(call remove-file,$(DESTDIR)$(MODULES_DIR)/$(DISK_MODULE).ko)
@$(DEPMOD)