From e7a9d3393b973002a8b98cab8d6aeb5d0ca23de6 Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Tue, 23 Jan 2018 16:20:11 +0100 Subject: [PATCH] Pass configuration paths directly from configure This change removes duplicated definitions of paths, that are now defined in just one place - configure.ac. Change-Id: If759c41ba32b4ed728bbf9f98b46bcdfbac57715 --- Makefile.am | 6 ++++++ configs/{dlog.conf.pipe => 20-pipe.conf} | 0 configs/{dlog.conf.logger => 25-logger.conf} | 0 configure.ac | 2 -- include/logconfig.h | 5 ----- packaging/dlog.spec | 30 ++++++++++++---------------- src/libdlog/log.c | 1 - src/shared/logconfig.c | 2 +- 8 files changed, 20 insertions(+), 26 deletions(-) rename configs/{dlog.conf.pipe => 20-pipe.conf} (100%) rename configs/{dlog.conf.logger => 25-logger.conf} (100%) diff --git a/Makefile.am b/Makefile.am index f90b0a6..59b8b30 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,6 +4,8 @@ BUILT_SOURCES = include/dlog.h AM_CFLAGS = -I$(srcdir)/include \ -DSD_DAEMON_DISABLE_MQ \ + -DDLOG_CONFIG_PATH=\"$(sysconfdir)/dlog.conf\" \ + -DDEBUGMODE_FILE=\"$(sysconfdir)/.debugmode\" \ -I$(srcdir)/external/sd-daemon \ $(DEBUG_CFLAGS) \ -Werror \ @@ -189,6 +191,10 @@ unit_DATA = \ configs/dlog_logger.path \ configs/dlog_dev-log.socket +sysconf_DATA = \ + configs/dlog.conf.pipe \ + configs/dlog.conf.logger + bin_SCRIPTS = dlog_test_pipe dox:: diff --git a/configs/dlog.conf.pipe b/configs/20-pipe.conf similarity index 100% rename from configs/dlog.conf.pipe rename to configs/20-pipe.conf diff --git a/configs/dlog.conf.logger b/configs/25-logger.conf similarity index 100% rename from configs/dlog.conf.logger rename to configs/25-logger.conf diff --git a/configure.ac b/configure.ac index abc1361..49e991d 100644 --- a/configure.ac +++ b/configure.ac @@ -37,8 +37,6 @@ AC_CHECK_FUNCS([memset]) PKG_PROG_PKG_CONFIG PKG_CHECK_MODULES([CAPI_BASE_COMMON], [capi-base-common]) -AC_SUBST(TZ_SYS_ETC) - AC_ARG_ENABLE([server-user], AS_HELP_STRING([--enable-server-user=USER], [user dlog_server should run with]), [dlog_server_user=$enableval], diff --git a/include/logconfig.h b/include/logconfig.h index cf9e129..eb010f9 100644 --- a/include/logconfig.h +++ b/include/logconfig.h @@ -22,11 +22,6 @@ #define MAX_CONF_VAL_LEN 256 #define MAX_CONF_ENTRY_LEN (MAX_CONF_KEY_LEN + MAX_CONF_VAL_LEN + 2) // +2 for the delimiter and newline -#ifndef TZ_SYS_ETC -#define TZ_SYS_ETC "/opt/etc" -#endif - -#define DEFAULT_CONFIG_PATH TZ_SYS_ETC"/dlog.conf" #define DEFAULT_CONFIG_SUFFIX ".conf" struct log_conf_entry; diff --git a/packaging/dlog.spec b/packaging/dlog.spec index e8d5932..415fe69 100644 --- a/packaging/dlog.spec +++ b/packaging/dlog.spec @@ -9,6 +9,8 @@ Source101: packaging/dlog.manifest Source501: packaging/01-dlog.rules %define upgrade_file_path %{_datadir}/upgrade +# NOTE: sysconfdir will be passed to ./configure automatically +%define _sysconfdir %{TZ_SYS_ETC} BuildRequires: autoconf BuildRequires: automake @@ -91,10 +93,8 @@ Integration tests for dlog. cp %{SOURCE101} . %autogen --disable-static -%configure --disable-static \ - TZ_SYS_ETC=%{TZ_SYS_ETC} -make %{?jobs:-j%jobs} \ - CFLAGS+=-DTZ_SYS_ETC=\\\"%{TZ_SYS_ETC}\\\" +%configure --disable-static +make %{?jobs:-j%jobs} make check @@ -109,10 +109,6 @@ mkdir -p %{buildroot}/usr/bin/ mkdir -p %{buildroot}/usr/share/doc/dlog cp -r documentation/* %{buildroot}/usr/share/doc/dlog -mkdir -p %{buildroot}%{TZ_SYS_ETC} -install -m 0644 configs/dlog.conf.pipe %{buildroot}%{TZ_SYS_ETC}/dlog.conf.pipe -install -m 0644 configs/dlog.conf.logger %{buildroot}%{TZ_SYS_ETC}/dlog.conf.logger - mkdir -p %{buildroot}%{_unitdir}/basic.target.wants/ mkdir -p %{buildroot}%{_unitdir}/sockets.target.wants/ ln -s ../dlog_logger.service %{buildroot}%{_unitdir}/basic.target.wants/dlog_logger.service @@ -139,21 +135,21 @@ systemctl daemon-reload %post -n libdlog /sbin/ldconfig chsmack -a System /var/log/dlog -ln -s %{TZ_SYS_ETC}/dlog.conf.pipe %{TZ_SYS_ETC}/dlog.conf +ln -s %{_sysconfdir}/dlog.conf.pipe %{_sysconfdir}/dlog.conf %postun -n libdlog /sbin/ldconfig -rm %{TZ_SYS_ETC}/dlog.conf +rm %{_sysconfdir}/dlog.conf %pre -n dlogbackend-logger -rm %{TZ_SYS_ETC}/dlog.conf +rm %{_sysconfdir}/dlog.conf %post -n dlogbackend-logger -ln -s %{TZ_SYS_ETC}/dlog.conf.logger %{TZ_SYS_ETC}/dlog.conf +ln -s %{_sysconfdir}/dlog.conf.logger %{_sysconfdir}/dlog.conf %postun -n dlogbackend-logger -rm %{TZ_SYS_ETC}/dlog.conf -ln -s %{TZ_SYS_ETC}/dlog.conf.pipe %{TZ_SYS_ETC}/dlog.conf +rm %{_sysconfdir}/dlog.conf +ln -s %{_sysconfdir}/dlog.conf.pipe %{_sysconfdir}/dlog.conf %files -n dlogutil %manifest dlog.manifest @@ -166,7 +162,7 @@ ln -s %{TZ_SYS_ETC}/dlog.conf.pipe %{TZ_SYS_ETC}/dlog.conf %license LICENSE.APACHE2.0 %{_libdir}/libdlog.so.0 %{_libdir}/libdlog.so.0.0.0 -%attr(664,log,log) %{TZ_SYS_ETC}/dlog.conf.pipe +%attr(664,log,log) %{_sysconfdir}/dlog.conf.pipe %attr(755,log,log) /var/log/dlog %attr(750,log,log) %{_bindir}/dlog_logger %{_unitdir}/basic.target.wants/dlog_logger.service @@ -176,7 +172,7 @@ ln -s %{TZ_SYS_ETC}/dlog.conf.pipe %{TZ_SYS_ETC}/dlog.conf %{_udevrulesdir}/01-dlog.rules # For upgrade %{upgrade_file_path}/scripts/210.dlog_upgrade.sh -%attr(644,log,log) %{TZ_SYS_ETC}/dlog.conf.d/ +%attr(644,log,log) %{_sysconfdir}/dlog.conf.d/ %files -n libdlog-devel %manifest dlog.manifest @@ -188,7 +184,7 @@ ln -s %{TZ_SYS_ETC}/dlog.conf.pipe %{TZ_SYS_ETC}/dlog.conf %files -n dlogbackend-logger %manifest dlog.manifest %license LICENSE.APACHE2.0 -%attr(664,log,log) %{TZ_SYS_ETC}/dlog.conf.logger +%attr(664,log,log) %{_sysconfdir}/dlog.conf.logger %files -n log-syslog %manifest dlog.manifest diff --git a/src/libdlog/log.c b/src/libdlog/log.c index 2aadaea..65d62e7 100644 --- a/src/libdlog/log.c +++ b/src/libdlog/log.c @@ -30,7 +30,6 @@ #define DEFAULT_CONFIG_LIMITER 0 #define DEFAULT_CONFIG_PLOG 1 #define DEFAULT_CONFIG_DEBUGMODE 0 -#define DEBUGMODE_FILE TZ_SYS_ETC"/.debugmode" static int __write_to_log_null(log_id_t, log_priority, const char *, const char *); diff --git a/src/shared/logconfig.c b/src/shared/logconfig.c index 5cdbf71..bc49301 100644 --- a/src/shared/logconfig.c +++ b/src/shared/logconfig.c @@ -301,7 +301,7 @@ int log_config_read(struct log_config *config) config->begin = config->last = NULL; - const char *main_path = getenv("DLOG_CONFIG_PATH") ?: DEFAULT_CONFIG_PATH; + const char *main_path = getenv("DLOG_CONFIG_PATH") ?: DLOG_CONFIG_PATH; int r = log_config_read_file(config, main_path); if (r < 0) return r; -- 2.7.4