Pass configuration paths directly from configure 37/168037/3
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Tue, 23 Jan 2018 15:20:11 +0000 (16:20 +0100)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Thu, 25 Jan 2018 15:15:08 +0000 (16:15 +0100)
This change removes duplicated definitions of paths,
that are now defined in just one place - configure.ac.

Change-Id: If759c41ba32b4ed728bbf9f98b46bcdfbac57715

Makefile.am
configs/20-pipe.conf [moved from configs/dlog.conf.pipe with 100% similarity]
configs/25-logger.conf [moved from configs/dlog.conf.logger with 100% similarity]
configure.ac
include/logconfig.h
packaging/dlog.spec
src/libdlog/log.c
src/shared/logconfig.c

index f90b0a6..59b8b30 100644 (file)
@@ -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::
similarity index 100%
rename from configs/dlog.conf.pipe
rename to configs/20-pipe.conf
index abc1361..49e991d 100644 (file)
@@ -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],
index cf9e129..eb010f9 100644 (file)
 #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;
index e8d5932..415fe69 100644 (file)
@@ -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
index 2aadaea..65d62e7 100644 (file)
@@ -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 *);
 
index 5cdbf71..bc49301 100644 (file)
@@ -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;