Rework per-backend package setup 00/129500/10
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Tue, 23 Jan 2018 15:22:14 +0000 (16:22 +0100)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Fri, 26 Jan 2018 10:57:01 +0000 (11:57 +0100)
This commit makes dlog use of the new "dlog.conf.d" extensible
configuration mechanism to select desired backend by installing
appropriate configuration to (/opt/)etc/dlog.conf.d.

Change-Id: I4a0db1ac3a6d708a457edb0b232f9a540cb54378

Makefile.am
configs/20-pipe.conf
configs/25-logger.conf
configs/dlog.conf [new file with mode: 0644]
packaging/dlog.spec

index 59b8b30..20c123b 100644 (file)
@@ -191,9 +191,12 @@ unit_DATA = \
        configs/dlog_logger.path \
        configs/dlog_dev-log.socket
 
-sysconf_DATA = \
-       configs/dlog.conf.pipe \
-       configs/dlog.conf.logger
+sysconf_DATA = configs/dlog.conf
+
+dlogconfdir = $(sysconfdir)/dlog.conf.d
+dlogconf_DATA = \
+       configs/20-pipe.conf \
+       configs/25-logger.conf
 
 bin_SCRIPTS = dlog_test_pipe
 
index e731c39..fa6ff06 100644 (file)
@@ -1,78 +1,39 @@
-# Lines starting with # are comments and are ignored.
-# Empty lines are also ignored.
-# Every other line is a config value and has to be in key=value format
-
 backend=pipe
 
-##### Settings used by the logging library
-
-# Platform logging. Whether logging happens at all.
-plog=1
-
-# Debugmode - whether write platform debug log or not
-debugmode=1
-
-# Limiter - whether it's enabled and the rules (check the documentation for how to create rules).
-limiter=0
-limiter|*|*=allow
-
-##### Settings used by the logging daemon
-
 # Sockets that all programs connect to to receive a logging pipe.
 main_write_sock=/run/dlog/main.wr
 apps_write_sock=/run/dlog/apps.wr
 system_write_sock=/run/dlog/system.wr
 radio_write_sock=/run/dlog/radio.wr
-kmsg_write_sock=/run/dlog/kmsg.wr
-syslog_write_sock=/run/dlog/syslog.wr
 
 # Sockets that administrative programs connect to to manipulate the daemon.
 main_ctl_sock=/run/dlog/main.ctl
 apps_ctl_sock=/run/dlog/apps.ctl
 system_ctl_sock=/run/dlog/system.ctl
 radio_ctl_sock=/run/dlog/radio.ctl
-kmsg_ctl_sock=/run/dlog/kmsg.ctl
-syslog_ctl_sock=/run/dlog/syslog.ctl
 
 # Permissions for the relevant sockets.
 main_write_sock_rights=0222
 apps_write_sock_rights=0222
 system_write_sock_rights=0222
 radio_write_sock_rights=0222
-kmsg_write_sock_rights=0222
-syslog_write_sock_rights=0222
 
 main_ctl_sock_rights=0222
 apps_ctl_sock_rights=0222
 system_ctl_sock_rights=0222
 radio_ctl_sock_rights=0222
-kmsg_ctl_sock_rights=0222
-syslog_ctl_sock_rights=0222
 
 # Size (in bytes) of internal cyclic buffers.
 main_size=1048576
 apps_size=1048576
 system_size=1048576
 radio_size=1048576
-kmsg_size=1048576
-syslog_size=1048576
-
-# link to /dev/log even if systemd did not pass the socket to logger (default 0)
-#syslog_force=1
 
 # Passive logging to file done by the daemon.
+#
+# NOTE: Do not change the following key names!  When different backend
+#       is used (eg. logger, via 25-logger.conf) these will be overriden.
 dlog_logger_conf_system=dlogutil -b system -r 2048 -n 1 -f /var/log/dlog/system.raw -v recv_realtime *:I
 dlog_logger_conf_main=dlogutil -b main -r 1024 -n 1 -f /var/log/dlog/main.raw -v recv_realtime *:W
 dlog_logger_conf_radio=dlogutil -b radio -r 256 -n 1 -f /var/log/dlog/radio.raw -v recv_realtime
 dlog_logger_conf_kmsg=dlogutil -b kmsg -r 256 -n 1 -f /var/log/dlog/kernel -v rwtime
-
-# Syslog handling currently disabled in the daemon - not needed in Tizen.
-# dlog_logger_conf_syslog=dlogutil -b syslog -r 256 -n 1 -f /var/log/dlog/syslog -v recv_realtime
-
-##### Settings used by dlogutil
-
-# Sorting time window (in milliseconds). Proportional to sorting quality, but also delay.
-util_sorting_time_window=1000
-
-# If sorting buffer is full, all logs are printed regardless of current sorting status.
-#util_sorting_buffer_size=1048576
index dab3024..62a5446 100644 (file)
@@ -1,33 +1,19 @@
 backend=logger
-plog=1
-debugmode=1
-limiter=0
-limiter|*|*=allow
+
 main=/dev/log_main
 apps=/dev/log_apps
 system=/dev/log_system
 radio=/dev/log_radio
-kmsg=/dev/null
-syslog=/dev/null
+
 main_size=1048576
 apps_size=1048576
 system_size=1048576
 radio_size=1048576
-kmsg_size=1048576
-syslog_size=1048576
-kmsg_ctl_sock=/run/dlog/kmsg.ctl
-kmsg_write_sock=/run/dlog/kmsg.wr
-kmsg_ctl_sock_rights=0222
-kmsg_write_sock_rights=0222
-syslog_ctl_sock=/run/dlog/syslog.ctl
-syslog_write_sock=/run/dlog/syslog.wr
-syslog_ctl_sock_rights=0222
-syslog_write_sock_rights=0222
+
+# NOTE: Do not change the following key names!  When different backend
+#       is used (eg. logger, via 25-logger.conf) these will be overriden.
 dlog_logger_conf_system=dlogutil -b system -r 2048 -n 1 -f /var/log/dlog/system -v recv_realtime *:I
 dlog_logger_conf_main=dlogutil -b main -r 1024 -n 1 -f /var/log/dlog/main -v recv_realtime *:W
 dlog_logger_conf_radio=dlogutil -b radio -r 256 -n 1 -f /var/log/dlog/radio -v recv_realtime
 dlog_logger_conf_kmsg=dlogutil -b kmsg -r 1024 -n 1 -f /var/log/dlog/kernel -v rwtime
 util_sorting_buffer_size=8192
-
-# Syslog handling currently disabled in the daemon - not needed in Tizen.
-# dlog_logger_conf_syslog=dlogutil -b syslog -r 1024 -n 1 -f /var/log/dlog/syslog -v recv_realtime
diff --git a/configs/dlog.conf b/configs/dlog.conf
new file mode 100644 (file)
index 0000000..e488db4
--- /dev/null
@@ -0,0 +1,53 @@
+# Lines starting with # are comments and are ignored.
+# Empty lines are also ignored.
+# Every other line is a config value and has to be in key=value format
+
+##### Settings used by the logging library
+
+# Platform logging. Whether logging happens at all.
+plog=1
+
+# Debugmode - whether write platform debug log or not
+debugmode=1
+
+# Limiter - whether it's enabled and the rules (check the documentation for how to create rules).
+limiter=0
+limiter|*|*=allow
+
+##### Settings used by the logging daemon
+
+kmsg=/dev/null
+syslog=/dev/null
+
+# Sockets that all programs connect to to receive a logging pipe.
+kmsg_write_sock=/run/dlog/kmsg.wr
+syslog_write_sock=/run/dlog/syslog.wr
+
+# Sockets that administrative programs connect to to manipulate the daemon.
+kmsg_ctl_sock=/run/dlog/kmsg.ctl
+syslog_ctl_sock=/run/dlog/syslog.ctl
+
+# Permissions for the relevant sockets.
+kmsg_write_sock_rights=0222
+syslog_write_sock_rights=0222
+
+kmsg_ctl_sock_rights=0222
+syslog_ctl_sock_rights=0222
+
+# Size (in bytes) of internal cyclic buffers.
+kmsg_size=1048576
+syslog_size=1048576
+
+# link to /dev/log even if systemd did not pass the socket to logger (default 0)
+#syslog_force=1
+
+# Syslog handling currently disabled in the daemon - not needed in Tizen.
+#dlog_logger_conf_syslog=dlogutil -b syslog -r 256 -n 1 -f /var/log/dlog/syslog -v recv_realtime
+
+##### Settings used by dlogutil
+
+# Sorting time window (in milliseconds). Proportional to sorting quality, but also delay.
+util_sorting_time_window=1000
+
+# If sorting buffer is full, all logs are printed regardless of current sorting status.
+#util_sorting_buffer_size=1048576
index 415fe69..526c9c0 100644 (file)
@@ -12,6 +12,8 @@ Source501:  packaging/01-dlog.rules
 # NOTE: sysconfdir will be passed to ./configure automatically
 %define _sysconfdir %{TZ_SYS_ETC}
 
+%define rpm_upgrade_state_dir %{_localstatedir}/lib/rpm-state/dlog
+
 BuildRequires: autoconf
 BuildRequires: automake
 BuildRequires: libtool
@@ -121,37 +123,43 @@ mkdir -p %{buildroot}/var/log/dlog
 
 install -D scripts/210.dlog_upgrade_30to40.sh %{buildroot}%{upgrade_file_path}/scripts/210.dlog_upgrade.sh
 
-mkdir -p %{buildroot}%{TZ_SYS_ETC}/dlog.conf.d
-
-%post
-systemctl daemon-reload
-
-%post -n dlogutil
-systemctl daemon-reload
-
-%postun -n dlogutil
-systemctl daemon-reload
+%pre -n libdlog
+# This and following sections contain workarounds for broken postun of
+# old dlog package:
+#
+#   postun -n libdlog -p rm /opt/etc/dlog.conf
+#
+# We need to preserve our new dlog.conf manually because old
+# package's postun is called after our rpm is unpacked and configured.
+# See:
+#   https://fedoraproject.org/wiki/Packaging:Scriptlets
+if [ $1 -ge 1 -a -L %{_sysconfdir}/dlog.conf ]; then
+    mkdir -vp %{rpm_upgrade_state_dir}
+fi
 
 %post -n libdlog
 /sbin/ldconfig
+systemctl daemon-reload
 chsmack -a System /var/log/dlog
-ln -s %{_sysconfdir}/dlog.conf.pipe %{_sysconfdir}/dlog.conf
-
-%postun -n libdlog
-/sbin/ldconfig
-rm %{_sysconfdir}/dlog.conf
 
-%pre -n dlogbackend-logger
-rm %{_sysconfdir}/dlog.conf
+if [ -d %{rpm_upgrade_state_dir} ]; then
+    cp -vf %{_sysconfdir}/dlog.conf %{rpm_upgrade_state_dir}/dlog.conf
+    chown -v root:root %{_sysconfdir}/dlog.conf.d || :
+    chmod -v 0755 %{_sysconfdir}/dlog.conf.d || :
+fi
 
-%post -n dlogbackend-logger
-ln -s %{_sysconfdir}/dlog.conf.logger %{_sysconfdir}/dlog.conf
+%posttrans -n libdlog
+if [ -f %{rpm_upgrade_state_dir}/dlog.conf ]; then
+    [ -L {%_sysconfdir}/dlog.conf ] && rm -v {%_sysconfdir}/dlog.conf || :
+    mv -vf %{rpm_upgrade_state_dir}/dlog.conf %{_sysconfdir}/dlog.conf
+    chsmack -a _ %{_sysconfdir}/dlog.conf
+    rmdir -v %{rpm_upgrade_state_dir} || :
+fi
+# End of workaround
 
-%postun -n dlogbackend-logger
-rm %{_sysconfdir}/dlog.conf
-ln -s %{_sysconfdir}/dlog.conf.pipe %{_sysconfdir}/dlog.conf
+%postun -n libdlog -p /sbin/ldconfig
 
-%files  -n dlogutil
+%files -n dlogutil
 %manifest dlog.manifest
 %license LICENSE.APACHE2.0
 %attr(750,log,log) %{_bindir}/dlogutil
@@ -162,7 +170,8 @@ ln -s %{_sysconfdir}/dlog.conf.pipe %{_sysconfdir}/dlog.conf
 %license LICENSE.APACHE2.0
 %{_libdir}/libdlog.so.0
 %{_libdir}/libdlog.so.0.0.0
-%attr(664,log,log) %{_sysconfdir}/dlog.conf.pipe
+%{_sysconfdir}/dlog.conf
+%{_sysconfdir}/dlog.conf.d/20-pipe.conf
 %attr(755,log,log) /var/log/dlog
 %attr(750,log,log) %{_bindir}/dlog_logger
 %{_unitdir}/basic.target.wants/dlog_logger.service
@@ -172,7 +181,6 @@ ln -s %{_sysconfdir}/dlog.conf.pipe %{_sysconfdir}/dlog.conf
 %{_udevrulesdir}/01-dlog.rules
 # For upgrade
 %{upgrade_file_path}/scripts/210.dlog_upgrade.sh
-%attr(644,log,log) %{_sysconfdir}/dlog.conf.d/
 
 %files -n libdlog-devel
 %manifest dlog.manifest
@@ -184,7 +192,7 @@ ln -s %{_sysconfdir}/dlog.conf.pipe %{_sysconfdir}/dlog.conf
 %files -n dlogbackend-logger
 %manifest dlog.manifest
 %license LICENSE.APACHE2.0
-%attr(664,log,log) %{_sysconfdir}/dlog.conf.logger
+%{_sysconfdir}/dlog.conf.d/25-logger.conf
 
 %files -n log-syslog
 %manifest dlog.manifest