[libvirt PATCH 230/351] meson: src: generate logrotate files

Pavel Hrdina phrdina at redhat.com
Thu Jul 16 09:57:46 UTC 2020


Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---
 src/Makefile.am            | 28 ----------------------------
 src/remote/Makefile.inc.am |  7 -------
 src/remote/meson.build     | 23 +++++++++++++++++++++++
 3 files changed, 23 insertions(+), 35 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 894ec5162a3..07516aa43ae 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -33,7 +33,6 @@ if WITH_DTRACE_PROBES
 tapset_DATA =
 endif WITH_DTRACE_PROBES
 RPC_PROBE_FILES =
-LOGROTATE_FILES_IN =
 
 include security/Makefile.inc.am
 include access/Makefile.inc.am
@@ -198,33 +197,6 @@ libvirt_functions.stp: $(RPC_PROBE_FILES) $(top_srcdir)/scripts/gensystemtap.py
 
 endif WITH_DTRACE_PROBES
 
-LOGROTATE_FILES := $(LOGROTATE_FILES_IN:remote/%.in=%)
-
-%.logrotate: remote/%.logrotate.in
-	$(AM_V_GEN)sed \
-	    -e 's|[@]localstatedir[@]|$(localstatedir)|g' \
-	    < $< > $@-t && \
-	mv $@-t $@
-
-if WITH_LIBVIRTD
-install-logrotate: $(LOGROTATE_FILES)
-	$(MKDIR_P) $(DESTDIR)$(sysconfdir)/logrotate.d/
-	for f in $(LOGROTATE_FILES) ; \
-	do \
-	  tgt=`echo $$f | sed -e 's/.logrotate//'`; \
-	  $(INSTALL_DATA) $$f \
-		$(DESTDIR)$(sysconfdir)/logrotate.d/$$tgt; \
-	done
-
-uninstall-logrotate:
-	rm -f $(LOGROTATE_FILES:%.logrotate=$(DESTDIR)$(sysconfdir)/logrotate.d/%)
-	rmdir $(DESTDIR)$(sysconfdir)/logrotate.d || :
-
-INSTALL_DATA_LOCAL += install-logrotate
-UNINSTALL_LOCAL += uninstall-logrotate
-endif WITH_LIBVIRTD
-
-
 install-data-local: $(INSTALL_DATA_LOCAL) \
 		$(INSTALL_DATA_DIRS:%=install-data-%)
 
diff --git a/src/remote/Makefile.inc.am b/src/remote/Makefile.inc.am
index 287dad426cb..8fbe8425b3b 100644
--- a/src/remote/Makefile.inc.am
+++ b/src/remote/Makefile.inc.am
@@ -1,12 +1,5 @@
 # vim: filetype=automake
 
-LOGROTATE_FILES_IN += \
-	remote/libvirtd.qemu.logrotate.in \
-	remote/libvirtd.lxc.logrotate.in \
-	remote/libvirtd.libxl.logrotate.in \
-	remote/libvirtd.logrotate.in \
-	$(NULL)
-
 if WITH_LIBVIRTD
 
 if WITH_SYSCTL
diff --git a/src/remote/meson.build b/src/remote/meson.build
index b18754d02c1..3b9f6117b62 100644
--- a/src/remote/meson.build
+++ b/src/remote/meson.build
@@ -99,6 +99,13 @@ libvirtd_socket_unit_files = [
 
 libvirtd_socket_conflicts = ' '.join(libvirtd_socket_unit_files)
 
+logrotate_files = [
+  'libvirtd.qemu',
+  'libvirtd.lxc',
+  'libvirtd.libxl',
+  'libvirtd',
+]
+
 if conf.has('WITH_REMOTE')
   remote_driver_lib = static_library(
     'virt_remote_driver',
@@ -196,6 +203,22 @@ if conf.has('WITH_REMOTE')
     virt_install_dirs += [
       localstatedir / 'log' / 'libvirt',
     ]
+
+    logrotate_conf = configuration_data()
+    logrotate_conf.set('localstatedir', localstatedir)
+
+    foreach name : logrotate_files
+      log_file = configure_file(
+        input: '@0 at .logrotate.in'.format(name),
+        output: '@0 at .logrotate'.format(name),
+        configuration: logrotate_conf,
+      )
+      install_data(
+        log_file,
+        install_dir: sysconfdir / 'logrotate.d',
+        rename: [ name ],
+      )
+    endforeach
   endif
 endif
 
-- 
2.26.2




More information about the libvir-list mailing list