[PATCH 2/2] build: add Uninstall for host build

Florian Eckert fe at dev.tdt.de
Mon Apr 4 06:20:54 PDT 2022


Currently there is no possibility for host package to cleanly remove the
installed files in staging.
There is the possibility to call an uninstall make target, but if this
is not implemented, and so nothing happens.

For debugging, it makes sense to know what is being installed. With this
change, the install process is called twice.
Once to create a .host-install file and once to install the package files
into the staging directory. If the tool is removed, the .host-install file
is used to remove all files from the staging dirctories.

This only works for the generic autotools install and uninstall target.

Signed-off-by: Florian Eckert <fe at dev.tdt.de>
---
 include/host-build.mk | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/include/host-build.mk b/include/host-build.mk
index b31bf93b30..d0f1a3eda5 100644
--- a/include/host-build.mk
+++ b/include/host-build.mk
@@ -113,13 +113,37 @@ endef
 
 define Host/Install/Default
 	@echo '*** Calling Host/Install/Default ($(PKG_NAME)) ***'
-	$(call Host/Compile/Default,install)
+	+$(HOST_MAKE_VARS) \
+	$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
+		DESTDIR="$(HOST_INSTALL_DIR)" \
+		$(HOST_MAKE_FLAGS) \
+		install
+	cd $(HOST_INSTALL_DIR) && \
+		find . | sed 's|^.||' > $(HOST_BUILD_DIR)/.host-install && \
+		rm -rf $(HOST_INSTALL_DIR)
+	+$(HOST_MAKE_VARS) \
+	$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) \
+		$(HOST_MAKE_FLAGS) \
+		install
 endef
 
 define Host/Install
 	$(call Host/Install/Default)
 endef
 
+define Host/Uninstall/Default
+	@echo '*** Calling Host/Uninstall/Default ($(PKG_NAME)) ***'
+	if [ -f "$(HOST_BUILD_DIR)/.host-install" ]; then \
+		$(XARGS) $(RM) < $(HOST_BUILD_DIR)/.host-install; \
+		$(FIND) $(STAGING_DIR_HOST) -type d -empty -print -delete; \
+		$(FIND) $(STAGING_DIR_HOSTPKG) -type d -empty -print -delete; \
+	fi
+endef
+
+define Host/Uninstall
+	$(call Host/Uninstall/Default)
+endef
+
 ifneq ($(if $(HOST_QUILT),,$(CONFIG_AUTOREBUILD)),)
   define HostHost/Autoclean
     $(call rdep,${CURDIR} $(PKG_FILE_DEPENDS),$(HOST_STAMP_PREPARED))
-- 
2.30.2




More information about the openwrt-devel mailing list