Neels Hofmeyr has uploaded this change for review. ( 
https://gerrit.osmocom.org/12861


Change subject: install: keep existing / modified etc/osmocom/*.cfg files
......................................................................

install: keep existing / modified etc/osmocom/*.cfg files

make install: If $prefix/etc/osmocom/*.cfg already exists, do not overwrite it.

make uninstall: If $prefix/etc/osmocom/*.cfg is modified, do not remove it.

Related: OS#3794
Change-Id: I95c9b5dc6117b3dd7a095b34437f5030a141c93b
---
M configure.ac
M doc/examples/Makefile.am
2 files changed, 43 insertions(+), 15 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/61/12861/1

diff --git a/configure.ac b/configure.ac
index 15976e6..6243d12 100644
--- a/configure.ac
+++ b/configure.ac
@@ -186,6 +186,11 @@
       [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
 AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])

+AC_CHECK_PROG(DIFF_PROGRAM,diff,yes)
+if test "x$DIFF_PROGRAM" != "xyes" ; then
+       AC_MSG_ERROR([Need 'diff' for 'make uninstall' to not remove modified 
cfg files])
+fi
+
 AC_MSG_RESULT([CFLAGS="$CFLAGS"])
 AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])

diff --git a/doc/examples/Makefile.am b/doc/examples/Makefile.am
index da504f4..3c185c9 100644
--- a/doc/examples/Makefile.am
+++ b/doc/examples/Makefile.am
@@ -1,30 +1,53 @@
-OSMOCONF_FILES = \
-       osmo-mgw/osmo-mgw.cfg
+ETC_OSMOCOM_CFG = \
+       $(srcdir)/osmo-mgw/osmo-mgw.cfg \
+       $(NULL)
 
-osmoconfdir = $(sysconfdir)/osmocom
-osmoconf_DATA = $(OSMOCONF_FILES)
-
-EXTRA_DIST = $(OSMOCONF_FILES)
-
-CFG_FILES = find $(srcdir) -name '*.cfg*' | sed -e 's,^$(srcdir),,'
+ALL_CFG = find $(srcdir) -name '*.cfg*' | sed -e 's,^$(srcdir),,'

 dist-hook:
-       for f in $$($(CFG_FILES)); do \
+       for f in $$($(ALL_CFG)); do \
                j="$(distdir)/$$f" && \
                mkdir -p "$$(dirname $$j)" && \
                $(INSTALL_DATA) $(srcdir)/$$f $$j; \
        done

-install-data-hook:
-       for f in $$($(CFG_FILES)); do \
+install_etc_osmocom_cfg:
+       for f in $(ETC_OSMOCOM_CFG); do \
+               bn="$$(basename "$$f")"; \
+               dst="$(DESTDIR)$(sysconfdir)/osmocom/$$bn"; \
+               test -e "$$dst" && echo "Already installed, not overwriting: 
$$dst" && continue || true; \
+               echo "Installing new cfg: $$dst" ; \
+               mkdir -p "$$(dirname "$$dst")" && \
+               $(INSTALL_DATA) "$$f" "$$dst"; \
+       done
+
+# uninstall only the $prefix/etc/osmocom cfg files that are not modified
+uninstall_etc_osmocom_cfg:
+       for f in $(ETC_OSMOCOM_CFG); do \
+               bn="$$(basename "$$f")"; \
+               dst="$(DESTDIR)$(sysconfdir)/osmocom/$$bn"; \
+               diff -q "$$f" "$$dst" || continue; \
+               $(RM) "$$dst"; \
+       done
+
+install_share_doc_cfg_examples:
+       for f in $$($(ALL_CFG)); do \
                j="$(DESTDIR)$(docdir)/examples/$$f" && \
                mkdir -p "$$(dirname $$j)" && \
                $(INSTALL_DATA) $(srcdir)/$$f $$j; \
        done

+uninstall_share_doc_cfg_examples:
+       for f in $$($(ALL_CFG)); do \
+              j="$(DESTDIR)$(docdir)/examples/$$f" && \
+              $(RM) $$j; \
+       done
+
+install-data-hook: \
+       install_etc_osmocom_cfg \
+       install_share_doc_cfg_examples
+
 uninstall-hook:
        @$(PRE_UNINSTALL)
-       for f in $$($(CFG_FILES)); do \
-               j="$(DESTDIR)$(docdir)/examples/$$f" && \
-               $(RM) $$j; \
-       done
+       $(MAKE) uninstall_etc_osmocom_cfg
+       $(MAKE) uninstall_share_doc_cfg_examples

--
To view, visit https://gerrit.osmocom.org/12861
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I95c9b5dc6117b3dd7a095b34437f5030a141c93b
Gerrit-Change-Number: 12861
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr <[email protected]>

Reply via email to