Merge pull request #743 from robertbaldyga/makefile-fix-uninstall
Fix Makefile error handling
This commit is contained in:
commit
94dc9048c7
10
Makefile
10
Makefile
@ -27,16 +27,16 @@ endif
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
archives:
|
archives:
|
||||||
@utils/pckgen $(PWD) tar zip
|
@tools/pckgen $(PWD) tar zip
|
||||||
|
|
||||||
rpm:
|
rpm:
|
||||||
@utils/pckgen $(PWD) rpm --debug
|
@tools/pckgen $(PWD) rpm --debug
|
||||||
|
|
||||||
srpm:
|
srpm:
|
||||||
@utils/pckgen $(PWD) srpm --debug
|
@tools/pckgen $(PWD) srpm --debug
|
||||||
|
|
||||||
deb:
|
deb:
|
||||||
@utils/pckgen $(PWD) deb
|
@tools/pckgen $(PWD) deb
|
||||||
|
|
||||||
dsc:
|
dsc:
|
||||||
@utils/pckgen $(PWD) dsc
|
@tools/pckgen $(PWD) dsc
|
||||||
|
@ -3,9 +3,10 @@
|
|||||||
# 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
|
||||||
UTILS_DIR:=$(PWD)/../utils
|
|
||||||
METADATA_DIR:=$(PWD)/../.metadata
|
METADATA_DIR:=$(PWD)/../.metadata
|
||||||
BINARY_PATH = /sbin
|
BINARY_PATH = /sbin
|
||||||
|
|
||||||
@ -135,28 +136,12 @@ install_files:
|
|||||||
@mkdir -p $(DESTDIR)$(BINARY_PATH)
|
@mkdir -p $(DESTDIR)$(BINARY_PATH)
|
||||||
@install -m 755 $(TARGET) $(DESTDIR)$(BINARY_PATH)/$(TARGET)
|
@install -m 755 $(TARGET) $(DESTDIR)$(BINARY_PATH)/$(TARGET)
|
||||||
@mkdir -p $(DESTDIR)/usr/share/man/man8
|
@mkdir -p $(DESTDIR)/usr/share/man/man8
|
||||||
@install -m 644 $(UTILS_DIR)/$(TARGET).8 $(DESTDIR)/usr/share/man/man8/$(TARGET).8
|
@install -m 644 $(TARGET).8 $(DESTDIR)/usr/share/man/man8/$(TARGET).8
|
||||||
|
|
||||||
@install -m 755 -d $(DESTDIR)/etc/opencas
|
|
||||||
@install -m 644 $(UTILS_DIR)/opencas.conf $(DESTDIR)/etc/opencas/opencas.conf
|
|
||||||
@install -m 444 $(UTILS_DIR)/ioclass-config.csv $(DESTDIR)/etc/opencas/ioclass-config.csv
|
|
||||||
@install -m 755 -d $(DESTDIR)/var/lib/opencas
|
|
||||||
@install -m 644 $(METADATA_DIR)/cas_version $(DESTDIR)/var/lib/opencas/cas_version
|
|
||||||
|
|
||||||
@mkdir -p $(DESTDIR)/usr/share/man/man5
|
@mkdir -p $(DESTDIR)/usr/share/man/man5
|
||||||
@install -m 644 $(UTILS_DIR)/opencas.conf.5 $(DESTDIR)/usr/share/man/man5/opencas.conf.5
|
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
@rm $(DESTDIR)/etc/opencas/opencas.conf
|
|
||||||
@rm $(DESTDIR)/etc/opencas/ioclass-config.csv
|
|
||||||
@rm -rf $(DESTDIR)/etc/opencas
|
|
||||||
@rm $(DESTDIR)/var/lib/opencas/cas_version
|
|
||||||
@rm -rf $(DESTDIR)/var/lib/opencas
|
|
||||||
|
|
||||||
@rm $(DESTDIR)/usr/share/man/man5/opencas.conf.5
|
|
||||||
|
|
||||||
.PHONY: clean distclean all sync build install uninstall
|
.PHONY: clean distclean all sync build install uninstall
|
||||||
|
2
configure
vendored
2
configure
vendored
@ -79,7 +79,7 @@ fi
|
|||||||
|
|
||||||
# Run version generator with 'build' flag to
|
# Run version generator with 'build' flag to
|
||||||
# indicate that we are in the build process
|
# indicate that we are in the build process
|
||||||
(cd utils && ./cas_version_gen build)
|
(cd tools && ./cas_version_gen build)
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Error: failed to obtain CAS version" >&2
|
echo "Error: failed to obtain CAS version" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -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
|
||||||
|
|
@ -515,7 +515,7 @@ DEB_BUILD_DIR="$TEMP_DIR/debuild"
|
|||||||
# Version file location:
|
# Version file location:
|
||||||
VERSION_FILE="$SOURCES_DIR/.metadata/cas_version"
|
VERSION_FILE="$SOURCES_DIR/.metadata/cas_version"
|
||||||
# CAS version generator location:
|
# CAS version generator location:
|
||||||
CAS_VERSION_GEN="$SOURCES_DIR/utils/cas_version_gen"
|
CAS_VERSION_GEN="$SOURCES_DIR/tools/cas_version_gen"
|
||||||
|
|
||||||
check_version
|
check_version
|
||||||
|
|
@ -3,8 +3,12 @@
|
|||||||
# 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
|
||||||
|
UTILS_DIR:=$(PWD)/../utils
|
||||||
UDEV:=$(shell which udevadm)
|
UDEV:=$(shell which udevadm)
|
||||||
SYSTEMCTL := $(shell which systemctl)
|
SYSTEMCTL := $(shell which systemctl)
|
||||||
PYTHON3 := $(shell which python3)
|
PYTHON3 := $(shell which python3)
|
||||||
@ -30,6 +34,14 @@ else
|
|||||||
install_files:
|
install_files:
|
||||||
@echo "Installing Open-CAS utils"
|
@echo "Installing Open-CAS utils"
|
||||||
|
|
||||||
|
@install -m 755 -d $(DESTDIR)/etc/opencas
|
||||||
|
@install -m 644 $(UTILS_DIR)/opencas.conf $(DESTDIR)/etc/opencas/opencas.conf
|
||||||
|
@install -m 444 $(UTILS_DIR)/ioclass-config.csv $(DESTDIR)/etc/opencas/ioclass-config.csv
|
||||||
|
@install -m 755 -d $(DESTDIR)/var/lib/opencas
|
||||||
|
@install -m 644 $(METADATA_DIR)/cas_version $(DESTDIR)/var/lib/opencas/cas_version
|
||||||
|
@mkdir -p $(DESTDIR)/usr/share/man/man5
|
||||||
|
@install -m 644 $(UTILS_DIR)/opencas.conf.5 $(DESTDIR)/usr/share/man/man5/opencas.conf.5
|
||||||
|
|
||||||
@install -m 755 -d $(DESTDIR)$(CASCTL_DIR)
|
@install -m 755 -d $(DESTDIR)$(CASCTL_DIR)
|
||||||
@install -m 644 opencas.py $(DESTDIR)$(CASCTL_DIR)/opencas.py
|
@install -m 644 opencas.py $(DESTDIR)$(CASCTL_DIR)/opencas.py
|
||||||
@install -m 755 casctl $(DESTDIR)$(CASCTL_DIR)/casctl
|
@install -m 755 casctl $(DESTDIR)$(CASCTL_DIR)/casctl
|
||||||
@ -58,28 +70,36 @@ install_files:
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
@rm $(DESTDIR)$(CASCTL_DIR)/opencas.py
|
@echo "Uninstalling Open-CAS utils"
|
||||||
@rm $(DESTDIR)$(CASCTL_DIR)/casctl
|
|
||||||
@rm $(DESTDIR)$(CASCTL_DIR)/open-cas-loader
|
|
||||||
@rm -rf $(DESTDIR)$(CASCTL_DIR)
|
|
||||||
|
|
||||||
@rm $(DESTDIR)/etc/dracut.conf.d/opencas.conf
|
$(call remove-file,$(DESTDIR)/etc/opencas/opencas.conf)
|
||||||
|
$(call remove-file,$(DESTDIR)/etc/opencas/ioclass-config.csv)
|
||||||
|
$(call remove-directory,$(DESTDIR)/etc/opencas)
|
||||||
|
$(call remove-file,$(DESTDIR)/var/lib/opencas/cas_version)
|
||||||
|
$(call remove-directory,$(DESTDIR)/var/lib/opencas)
|
||||||
|
$(call remove-file,$(DESTDIR)/usr/share/man/man5/opencas.conf.5)
|
||||||
|
|
||||||
@rm $(DESTDIR)/sbin/casctl
|
$(call remove-file,$(DESTDIR)$(CASCTL_DIR)/opencas.py)
|
||||||
|
$(call remove-file,$(DESTDIR)$(CASCTL_DIR)/casctl)
|
||||||
|
$(call remove-file,$(DESTDIR)$(CASCTL_DIR)/open-cas-loader)
|
||||||
|
$(call remove-directory,$(DESTDIR)$(CASCTL_DIR))
|
||||||
|
|
||||||
@rm $(DESTDIR)/usr/share/man/man8/casctl.8
|
$(call remove-file,$(DESTDIR)/etc/dracut.conf.d/opencas.conf)
|
||||||
|
|
||||||
@rm $(DESTDIR)$(UDEVRULES_DIR)/60-persistent-storage-cas-load.rules
|
$(call remove-file,$(DESTDIR)/sbin/casctl)
|
||||||
@rm $(DESTDIR)$(UDEVRULES_DIR)/60-persistent-storage-cas.rules
|
|
||||||
|
$(call remove-file,$(DESTDIR)/usr/share/man/man8/casctl.8)
|
||||||
|
|
||||||
|
$(call remove-file,$(DESTDIR)$(UDEVRULES_DIR)/60-persistent-storage-cas-load.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