[PATCH 29/31] Python IP addresses: Check for and maybe delete stale ipaddr.py

Ian Jackson ijackson at chiark.greenend.org.uk
Sat Sep 20 01:32:24 BST 2014


If ipaddr.py (or .pyc) from a previous secnet installation still
exists in /usr/share/secnet or /usr/local/share/secnet, this version
won't work.  Check for this situation in `make install' and bomb out.
Provide a `make install-force' which deletes the spurious files.

Signed-off-by: Ian Jackson <ijackson at chiark.greenend.org.uk>
---
 Makefile.in |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/Makefile.in b/Makefile.in
index 9e8afc7..0691c50 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -68,6 +68,12 @@ OBJECTS:=version.o
 TEST_OBJECTS:=
 endif
 
+STALE_PYTHON_FILES=	$(foreach e, py pyc, \
+			$(foreach p, /usr /usr/local, \
+			$(foreach l, ipaddr, \
+			$p/share/secnet/$l.$e \
+			)))
+
 %.c:	%.y
 
 %.yy.c:	%.fl
@@ -165,11 +171,23 @@ installdirs:
 	$(INSTALL) -d $(mandir)/man8
 
 install: installdirs
+	set -e; ok=true; for f in $(STALE_PYTHON_FILES); do \
+		if test -e $$f; then \
+			echo >&2 "ERROR: $$f still exists "\
+				"- try \`make install-force'"; \
+			ok=false; \
+		fi; \
+	done; \
+	$$ok
 	$(INSTALL_PROGRAM) secnet $(sbindir)/`echo secnet|sed '$(transform)'`
 	$(INSTALL_PROGRAM) ${srcdir}/make-secnet-sites $(sbindir)/`echo make-secnet-sites|sed '$(transform)'`
 	$(INSTALL) ${srcdir}/ipaddrset.py $(prefix)/share/secnet/ipaddrset.py
 	$(INSTALL) secnet.8 $(mandir)/man8/secnet.8
 
+install-force:
+	rm -f $(STALE_PYTHON_FILES)
+	$(MAKE) install
+
 clean:
 	$(RM) -f *.o *.yy.c *.tab.[ch] $(TARGETS) core version.c
 	$(RM) -f *.d *~ eax-*-test.confirm eax-*-test
-- 
1.7.10.4




More information about the sgo-software-discuss mailing list