File obs-server-2.10-0016-dist-backend-Make-backend-log-directory-configurable.patch of Package obs-server

From b2a2affd57ae153302b6c70bcf1a6caf7446cc9d Mon Sep 17 00:00:00 2001
From: Oleg Girko <ol@infoserver.lv>
Date: Sun, 17 Jul 2016 00:45:23 +0100
Subject: [PATCH] [dist][backend] Make backend log directory configurable.

This change adds OBS_BACKEND_LOG_DIR and OBS_BACKEND_SERVICE_LOG_DIR
configuration parameters to Makefile.include that specify directories
where backend logs and backend service logs will be written.

Some distributions (like Fedora) have giudelines stating that
logs should be written in /var/log directory.

Signed-off-by: Oleg Girko <ol@infoserver.lv>
---
 Makefile.include     |  2 ++
 dist/Makefile        | 11 +++++++++++
 src/backend/Makefile | 10 ++++++++++
 3 files changed, 23 insertions(+)

diff --git a/Makefile.include b/Makefile.include
index d79a819f97..73d290e6dd 100644
--- a/Makefile.include
+++ b/Makefile.include
@@ -4,6 +4,8 @@ SBINDIR=/usr/sbin
 INSTALL=$(BINDIR)/install
 OBS_BACKEND_PREFIX=/usr/lib/obs/server
 OBS_BACKEND_DATA_DIR=/srv/obs
+OBS_BACKEND_LOG_DIR=$(OBS_BACKEND_DATA_DIR)/log
+OBS_BACKEND_SERVICE_LOG_DIR=$(OBS_BACKEND_DATA_DIR)/service/log
 OBS_DOCUMENT_ROOT=/srv/www/obs
 OBS_API_PREFIX=$(OBS_DOCUMENT_ROOT)/api
 OBS_APIDOCS_PREFIX=$(OBS_DOCUMENT_ROOT)/docs
diff --git a/dist/Makefile b/dist/Makefile
index c88de86528..bca31c9c4b 100644
--- a/dist/Makefile
+++ b/dist/Makefile
@@ -55,11 +55,22 @@ install_logrotate: system_dirs
 	    -e 's|/srv/www/obs/api|$(OBS_API_PREFIX)|g' \
 	    -e 's|/srv/obs|$(OBS_BACKEND_DATA_DIR)|g' \
 	    $(LOGROTATE_CONFIGS:%=$(DESTDIR)/etc/logrotate.d/%)
+ifneq ($(OBS_BACKEND_LOG_DIR),$(OBS_BACKEND_DATA_DIR)/log)
+	sed -i \
+	    -e 's|$(OBS_BACKEND_DATA_DIR)/log|$(OBS_BACKEND_LOG_DIR)|g' \
+	    $(LOGROTATE_CONFIGS:%=$(DESTDIR)/etc/logrotate.d/%)
+endif
+ifneq ($(OBS_BACKEND_SERVICE_LOG_DIR),$(OBS_BACKEND_DATA_DIR)/service/log)
+	sed -i \
+	    -e 's|$(OBS_BACKEND_DATA_DIR)/service/log|$(OBS_BACKEND_SERVICE_LOG_DIR)|g' \
+	    $(LOGROTATE_CONFIGS:%=$(DESTDIR)/etc/logrotate.d/%)
+endif
 
 install_fillups: system_dirs
 	$(INSTALL) -m 0644 sysconfig.obs-server \
 	    $(DESTDIR)$(FILLUPDIR)/$(OBS_FILLUP_FILE)
 	sed -i \
+	    -e 's|/srv/obs/log|$(OBS_BACKEND_LOG_DIR)|g' \
 	    -e 's|/srv/obs|$(OBS_BACKEND_DATA_DIR)|g' \
 	    -e 's|5352|$(OBS_SRCSERVER_PORT)|' \
 	    -e 's|5252|$(OBS_REPOSERVER_PORT)|' \
diff --git a/src/backend/Makefile b/src/backend/Makefile
index 79db37065d..b0b198cf89 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -36,6 +36,16 @@ install_data_dirs: prepare_dirs
 		$(shell $(INSTALL) -d -m 755 $(DESTDIR)$(OBS_BACKEND_DATA_DIR)/$(data_dir) ) \
 	)
 	install -d -m 700 $(DESTDIR)$(OBS_BACKEND_DATA_DIR)/gnupg
+ifneq ($(OBS_BACKEND_LOG_DIR),$(OBS_BACKEND_DATA_DIR)/log)
+	$(INSTALL) -d -m 755 $(DESTDIR)$(OBS_BACKEND_LOG_DIR)
+	rmdir $(DESTDIR)$(OBS_BACKEND_DATA_DIR)/log
+	ln -s $(OBS_BACKEND_LOG_DIR) $(DESTDIR)$(OBS_BACKEND_DATA_DIR)/log
+endif
+ifneq ($(OBS_BACKEND_SERVICE_LOG_DIR),$(OBS_BACKEND_DATA_DIR)/service/log)
+	$(INSTALL) -d -m 755 $(DESTDIR)$(OBS_BACKEND_SERVICE_LOG_DIR)
+	rmdir $(DESTDIR)$(OBS_BACKEND_DATA_DIR)/service/log
+	ln -s $(OBS_BACKEND_SERVICE_LOG_DIR) $(DESTDIR)$(OBS_BACKEND_DATA_DIR)/service/log
+endif
 
 
 test_unit: bs_config
-- 
2.31.1