]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
build: Fix for failing 'make uninstall'
authorPhil Sutter <phil@nwl.cc>
Tue, 9 Jun 2020 10:40:24 +0000 (12:40 +0200)
committerPhil Sutter <phil@nwl.cc>
Tue, 9 Jun 2020 17:36:37 +0000 (19:36 +0200)
Support for uninstalling is severely broken:

- extensions/GNUmakefile.in defines an 'install' target but lacks a
  respective 'uninstall' one, causing 'make uninstall' abort with an
  error message.

- iptables/Makefile.am defines an 'install-exec-hook' to create the
  binary symlinks which are left in place after 'make uninstall'.

Fix these problems by defining respective targets containing code copied
from automake-generated uninstall targets.

While being at it, add a few more uninstall-hooks removing custom
directories created by 'make install' if they are empty afterwards.

Reported-by: Richard Guy Briggs <rgb@redhat.com>
Signed-off-by: Phil Sutter <phil@nwl.cc>
Tested-by: Richard Guy Briggs <rgb@redhat.com>
extensions/GNUmakefile.in
include/Makefile.am
iptables/Makefile.am
utils/Makefile.am

index 0842a55354e4bfc63b83b6fc2bd731dfc317afc7..956ccb38b2ab93e5fc9538e861b9d17da9958882 100644 (file)
@@ -79,7 +79,7 @@ targets_install :=
 
 .SECONDARY:
 
-.PHONY: all install clean distclean FORCE
+.PHONY: all install uninstall clean distclean FORCE
 
 all: ${targets}
 
@@ -92,6 +92,19 @@ install: ${targets_install} ${symlinks_install}
                cp -P ${symlinks_install} "${DESTDIR}${xtlibdir}/"; \
        fi;
 
+uninstall:
+       dir=${DESTDIR}${xtlibdir}; { \
+               test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; \
+       } || { \
+               test -z "${targets_install}" || ( \
+                       cd "$$dir" && rm -f ${targets_install} \
+               ); \
+               test -z "${symlinks_install}" || ( \
+                       cd "$$dir" && rm -f ${symlinks_install} \
+               ); \
+               rmdir -p --ignore-fail-on-non-empty "$$dir"; \
+       }
+
 clean:
        rm -f *.o *.oo *.so *.a {matches,targets}.man initext.c initext4.c initext6.c initextb.c initexta.c;
        rm -f .*.d .*.dd;
index e69512092253a7267a6a084030032603fc057207..ea34c2fef0d98788333986050a4a761233b00767 100644 (file)
@@ -10,3 +10,8 @@ endif
 nobase_include_HEADERS += \
        libiptc/ipt_kernel_headers.h libiptc/libiptc.h \
        libiptc/libip6tc.h libiptc/libxtc.h libiptc/xtcshared.h
+
+uninstall-hook:
+       dir=${includedir}/libiptc; { \
+               test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; \
+       } || rmdir -p --ignore-fail-on-non-empty "$$dir"
index 2024dbf5cb88c53c2a501733b85b5bb72e338751..bab094b7c6aa9bf870851407a416805655ef6842 100644 (file)
@@ -111,3 +111,26 @@ install-exec-hook:
        for i in ${v6_sbin_links}; do ${LN_S} -f xtables-legacy-multi "${DESTDIR}${sbindir}/$$i"; done;
        for i in ${x_sbin_links}; do ${LN_S} -f xtables-nft-multi "${DESTDIR}${sbindir}/$$i"; done;
        ${LN_S} -f iptables-apply "${DESTDIR}${sbindir}/ip6tables-apply"
+
+uninstall-hook:
+       dir=${DESTDIR}${bindir}; { \
+               test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; \
+       } || { \
+               test -z "${vx_bin_links}" || ( \
+                       cd "$$dir" && rm -f ${vx_bin_links} \
+               ) \
+       }
+       dir=${DESTDIR}${sbindir}; { \
+               test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; \
+       } || { \
+               test -z "${v4_sbin_links}" || ( \
+                       cd "$$dir" && rm -f ${v4_sbin_links} \
+               ); \
+               test -z "${v6_sbin_links}" || ( \
+                       cd "$$dir" && rm -f ${v6_sbin_links} \
+               ); \
+               test -z "${x_sbin_links}" || ( \
+                       cd "$$dir" && rm -f ${x_sbin_links} \
+               ); \
+               ( cd "$$dir" && rm -f ip6tables-apply ); \
+       }
index d09a69749b85fbf0ef650d345dcd6a75262d0fbd..42bd973730194232537eae9a6a86e694df5928d6 100644 (file)
@@ -14,6 +14,11 @@ sbin_PROGRAMS += nfnl_osf
 pkgdata_DATA += pf.os
 
 nfnl_osf_LDADD = ${libnfnetlink_LIBS}
+
+uninstall-hook:
+       dir=${DESTDIR}${pkgdatadir}; { \
+               test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; \
+       } || rmdir -p --ignore-fail-on-non-empty "$$dir"
 endif
 
 if ENABLE_BPFC