File obs-server-2.9-0019-dist-backend-Make-backend-log-directory-configurable.patch of Package obs-server

From 2afa4668e616e1c00134666a7bc3073732594f31 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 configuration parameter
to Makefile.include that specifies directory where backend 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     | 1 +
 dist/Makefile        | 3 +++
 src/backend/Makefile | 5 +++++
 3 files changed, 9 insertions(+)

diff --git a/Makefile.include b/Makefile.include
index 94b8cc3b66..26c01dd91b 100644
--- a/Makefile.include
+++ b/Makefile.include
@@ -5,6 +5,7 @@ INITDDIR=/etc/init.d
 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_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 6eb5772e50..bd509f100c 100644
--- a/dist/Makefile
+++ b/dist/Makefile
@@ -40,6 +40,7 @@ install_initscripts: system_dirs
 	sed -i \
 	    -e 's|wwwrun:www|$(APACHE_USER):$(APACHE_GROUP)|g' \
 	    -e 's|/srv/www/obs/api|$(OBS_API_PREFIX)|g' \
+	    -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)|' \
@@ -59,6 +60,7 @@ install_logrotate: system_dirs
 	sed -i \
 	    -e 's| wwwrun www| $(APACHE_USER) $(APACHE_GROUP)|g' \
 	    -e 's|/srv/www/obs/api|$(OBS_API_PREFIX)|g' \
+	    -e 's|/srv/obs/log|$(OBS_BACKEND_LOG_DIR)|g' \
 	    -e 's|/srv/obs|$(OBS_BACKEND_DATA_DIR)|g' \
 	    $(LOGROTATE_CONFIGS:%=$(DESTDIR)/etc/logrotate.d/%)
 
@@ -66,6 +68,7 @@ install_fillups: system_dirs
 	$(INSTALL) -m 0644 sysconfig.obs-server \
 	    $(DESTDIR)$(OBS_FILLUP_DIR)/$(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 a08f45cb3a..5b994d80a0 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -35,6 +35,11 @@ install_data_dirs: prepare_dirs
 	$(foreach data_dir,$(OBS_BACKEND_DATA_SUBDIRS), \
 		$(shell $(INSTALL) -d -m 755 $(DESTDIR)$(OBS_BACKEND_DATA_DIR)/$(data_dir) ) \
 	)
+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
 
 
 test_unit: bs_config clean_cover
-- 
2.20.1