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:
parent
e58dae02ac
commit
880cfadde9
@ -3,6 +3,8 @@
|
|||||||
# SPDX-License-Identifier: BSD-3-Clause-Clear
|
# SPDX-License-Identifier: BSD-3-Clause-Clear
|
||||||
#
|
#
|
||||||
|
|
||||||
|
include ../tools/helpers.mk
|
||||||
|
|
||||||
PWD:=$(shell pwd)
|
PWD:=$(shell pwd)
|
||||||
MODULESDIR:=$(PWD)/../modules
|
MODULESDIR:=$(PWD)/../modules
|
||||||
METADATA_DIR:=$(PWD)/../.metadata
|
METADATA_DIR:=$(PWD)/../.metadata
|
||||||
@ -139,7 +141,7 @@ install_files:
|
|||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
@echo "Uninstalling casadm"
|
@echo "Uninstalling casadm"
|
||||||
@rm $(DESTDIR)$(BINARY_PATH)/$(TARGET)
|
$(call remove-file,$(DESTDIR)$(BINARY_PATH)/$(TARGET))
|
||||||
@rm $(DESTDIR)/usr/share/man/man8/$(TARGET).8
|
$(call remove-file,$(DESTDIR)/usr/share/man/man8/$(TARGET).8)
|
||||||
|
|
||||||
.PHONY: clean distclean all sync build install uninstall
|
.PHONY: clean distclean all sync build install uninstall
|
||||||
|
@ -15,6 +15,13 @@ obj-y += cas_disk/
|
|||||||
# line; invoke the kernel build system.
|
# line; invoke the kernel build system.
|
||||||
else
|
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
|
OCFDIR=$(PWD)/../ocf
|
||||||
PWD=$(shell pwd)
|
PWD=$(shell pwd)
|
||||||
KERNEL_VERSION ?= "$(shell uname -r)"
|
KERNEL_VERSION ?= "$(shell uname -r)"
|
||||||
@ -57,11 +64,11 @@ install_files:
|
|||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
@echo "Uninstalling Open-CAS modules"
|
@echo "Uninstalling Open-CAS modules"
|
||||||
@$(RMMOD) $(CACHE_MODULE)
|
$(call remove-module,$(CACHE_MODULE))
|
||||||
@$(RMMOD) $(DISK_MODULE)
|
$(call remove-module,$(DISK_MODULE))
|
||||||
|
|
||||||
@rm $(DESTDIR)$(MODULES_DIR)/$(CACHE_MODULE).ko
|
$(call remove-file,$(DESTDIR)$(MODULES_DIR)/$(CACHE_MODULE).ko)
|
||||||
@rm $(DESTDIR)$(MODULES_DIR)/$(DISK_MODULE).ko
|
$(call remove-file,$(DESTDIR)$(MODULES_DIR)/$(DISK_MODULE).ko)
|
||||||
|
|
||||||
@$(DEPMOD)
|
@$(DEPMOD)
|
||||||
|
|
||||||
|
15
tools/helpers.mk
Normal file
15
tools/helpers.mk
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#
|
||||||
|
# Copyright(c) 2021 Intel Corporation
|
||||||
|
# SPDX-License-Identifier: BSD-3-Clause-Clear
|
||||||
|
#
|
||||||
|
|
||||||
|
define remove-file
|
||||||
|
@if [ -f ${1} ] || [ -L ${1} ]; then rm -rf ${1}; \
|
||||||
|
else echo "WARNING: Cannot find file ${1}"; fi
|
||||||
|
endef
|
||||||
|
|
||||||
|
define remove-directory
|
||||||
|
@if [ -d ${1} ]; then rm -rf ${1}; \
|
||||||
|
else echo "WARNING: Cannot find directory ${1}"; fi
|
||||||
|
endef
|
||||||
|
|
@ -3,6 +3,8 @@
|
|||||||
# SPDX-License-Identifier: BSD-3-Clause-Clear
|
# SPDX-License-Identifier: BSD-3-Clause-Clear
|
||||||
#
|
#
|
||||||
|
|
||||||
|
include ../tools/helpers.mk
|
||||||
|
|
||||||
CASCTL_DIR = /lib/opencas
|
CASCTL_DIR = /lib/opencas
|
||||||
UDEVRULES_DIR = /lib/udev/rules.d
|
UDEVRULES_DIR = /lib/udev/rules.d
|
||||||
METADATA_DIR:=$(PWD)/../.metadata
|
METADATA_DIR:=$(PWD)/../.metadata
|
||||||
@ -70,34 +72,34 @@ endif
|
|||||||
uninstall:
|
uninstall:
|
||||||
@echo "Uninstalling Open-CAS utils"
|
@echo "Uninstalling Open-CAS utils"
|
||||||
|
|
||||||
@rm $(DESTDIR)/etc/opencas/opencas.conf
|
$(call remove-file,$(DESTDIR)/etc/opencas/opencas.conf)
|
||||||
@rm $(DESTDIR)/etc/opencas/ioclass-config.csv
|
$(call remove-file,$(DESTDIR)/etc/opencas/ioclass-config.csv)
|
||||||
@rm -rf $(DESTDIR)/etc/opencas
|
$(call remove-directory,$(DESTDIR)/etc/opencas)
|
||||||
@rm $(DESTDIR)/var/lib/opencas/cas_version
|
$(call remove-file,$(DESTDIR)/var/lib/opencas/cas_version)
|
||||||
@rm -rf $(DESTDIR)/var/lib/opencas
|
$(call remove-directory,$(DESTDIR)/var/lib/opencas)
|
||||||
@rm $(DESTDIR)/usr/share/man/man5/opencas.conf.5
|
$(call remove-file,$(DESTDIR)/usr/share/man/man5/opencas.conf.5)
|
||||||
|
|
||||||
@rm $(DESTDIR)$(CASCTL_DIR)/opencas.py
|
$(call remove-file,$(DESTDIR)$(CASCTL_DIR)/opencas.py)
|
||||||
@rm $(DESTDIR)$(CASCTL_DIR)/casctl
|
$(call remove-file,$(DESTDIR)$(CASCTL_DIR)/casctl)
|
||||||
@rm $(DESTDIR)$(CASCTL_DIR)/open-cas-loader
|
$(call remove-file,$(DESTDIR)$(CASCTL_DIR)/open-cas-loader)
|
||||||
@rm -rf $(DESTDIR)$(CASCTL_DIR)
|
$(call remove-directory,$(DESTDIR)$(CASCTL_DIR))
|
||||||
|
|
||||||
@rm $(DESTDIR)/etc/dracut.conf.d/opencas.conf
|
$(call remove-file,$(DESTDIR)/etc/dracut.conf.d/opencas.conf)
|
||||||
|
|
||||||
@rm $(DESTDIR)/sbin/casctl
|
$(call remove-file,$(DESTDIR)/sbin/casctl)
|
||||||
|
|
||||||
@rm $(DESTDIR)/usr/share/man/man8/casctl.8
|
$(call remove-file,$(DESTDIR)/usr/share/man/man8/casctl.8)
|
||||||
|
|
||||||
@rm $(DESTDIR)$(UDEVRULES_DIR)/60-persistent-storage-cas-load.rules
|
$(call remove-file,$(DESTDIR)$(UDEVRULES_DIR)/60-persistent-storage-cas-load.rules)
|
||||||
@rm $(DESTDIR)$(UDEVRULES_DIR)/60-persistent-storage-cas.rules
|
$(call remove-file,$(DESTDIR)$(UDEVRULES_DIR)/60-persistent-storage-cas.rules)
|
||||||
@$(UDEV) control --reload-rules
|
@$(UDEV) control --reload-rules
|
||||||
|
|
||||||
@$(SYSTEMCTL) -q disable open-cas-shutdown
|
@$(SYSTEMCTL) -q disable open-cas-shutdown
|
||||||
@$(SYSTEMCTL) -q disable open-cas
|
@$(SYSTEMCTL) -q disable open-cas
|
||||||
@$(SYSTEMCTL) daemon-reload
|
@$(SYSTEMCTL) daemon-reload
|
||||||
|
|
||||||
@rm $(DESTDIR)$(SYSTEMD_DIR)/open-cas-shutdown.service
|
$(call remove-file,$(DESTDIR)$(SYSTEMD_DIR)/open-cas-shutdown.service)
|
||||||
@rm $(DESTDIR)$(SYSTEMD_DIR)/open-cas.service
|
$(call remove-file,$(DESTDIR)$(SYSTEMD_DIR)/open-cas.service)
|
||||||
@rm $(DESTDIR)$(SYSTEMD_DIR)/../system-shutdown/open-cas.shutdown
|
$(call remove-file,$(DESTDIR)$(SYSTEMD_DIR)/../system-shutdown/open-cas.shutdown)
|
||||||
|
|
||||||
.PHONY: install uninstall clean distclean
|
.PHONY: install uninstall clean distclean
|
||||||
|
Loading…
Reference in New Issue
Block a user